Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Resources
  • Code Requests
  • Completed Requests
  • [Completed] [ZB] Disable code for certain users
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
[Completed] [ZB] Disable code for certain users
Tweet Topic Started: Nov 5 2009, 08:07 PM (187 Views)
Swordslam46 Nov 5 2009, 08:07 PM Post #1
Member Avatar


Posts:
934
Group:
Dedicated
Member
#2,773
Joined:
Apr 9, 2009
I would like a code that will disable a certain code for users. So if Bobs name was in but Joe's wasnt Joe would have the code enabled but Bob wouldnt.
Offline Profile Goto Top
 
Gorgor Nov 5 2009, 08:19 PM Post #2
Hello

Posts:
1,187
Group:
Former Staff
Member
#2,728
Joined:
Apr 2, 2009
Coding language
PHP
Code:
 
disable = [];
disable[0] = "NAME 1"
disable[1] = "NAME 2"
a = $("#top_info strong a").html()
for(x=0;x<disable.length;x++){
if(disable[x] == a){

ENTER CODE HERE

}}
Offline Profile Goto Top
 
Swordslam46 Nov 5 2009, 08:41 PM Post #3
Member Avatar


Posts:
934
Group:
Dedicated
Member
#2,773
Joined:
Apr 9, 2009
uhh I think you forgot the script tags, and do I remove the script tags from the code thats in this code?
Offline Profile Goto Top
 
Gorgor Nov 5 2009, 08:54 PM Post #4
Hello

Posts:
1,187
Group:
Former Staff
Member
#2,728
Joined:
Apr 2, 2009
Coding language
PHP
It would be like this:
Code:
 
<script type='text/javascript'>
$(function(){
disable = [];
disable[0] = "NAME 1"
disable[1] = "NAME 2"
a = $("#top_info strong a").html()
for(x=0;x<disable.length;x++){
if(disable[x] == a){

CODE [b]WITHOUT[/b] SCRIPT TAGS

}}
})
</script>
Offline Profile Goto Top
 
Swordslam46 Nov 5 2009, 09:13 PM Post #5
Member Avatar


Posts:
934
Group:
Dedicated
Member
#2,773
Joined:
Apr 9, 2009
uhhh it enables the code for the people in the Array, I want it to disable it.
Offline Profile Goto Top
 
Gorgor Nov 5 2009, 09:32 PM Post #6
Hello

Posts:
1,187
Group:
Former Staff
Member
#2,728
Joined:
Apr 2, 2009
Coding language
PHP
Oops, instead of !=, I wrote == :P
Code:
 
<script type='text/javascript'>
$(function(){
disable = [];
disable[0] = "NAME 1"
disable[1] = "NAME 2"
a = $("#top_info strong a").html()
for(x=0;x<disable.length;x++){
if(disable[x] != a){

CODE WITHOUT SCRIPT TAGS

}}
})
</script>
Offline Profile Goto Top
 
Reid Nov 5 2009, 11:43 PM Post #7
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
That code will run the code if their name isn't such and such... however, if there is more than one user that the code is disabled for, the disabling will no longer function because their name may be NAME 1 but on the NAME 2 the check will still be true.

Try this:
Code:
 
<script type='text/javascript'>
// <![CDATA[
var disable = [ 'name 1', 'name 2' ];
function code_to_execute() {
// CODE GOES HERE
}
/* End of options */
var l = disable.length, code_enabled = true, cur_u_name = $('#top_info strong a').text();
while (l--)
if (cur_u_name == disable[l])
code_enabled = false;
if (code_enabled)
code_to_execute();
// ]]>
</script>
The options are, of course, this section:
Code:
 
var disable = [ 'name 1', 'name 2' ];
function code_to_execute() {
// CODE GOES HERE
}
Just add more names to the disable line and then stick your code where it says
Code:
 
// CODE GOES HERE
That should work. If necessary, I can make the code function for multiple codes...

This goes in above the copyright, by the way.
The Resource Board
Offline Profile Goto Top
 
Swordslam46 Nov 6 2009, 03:52 PM Post #8
Member Avatar


Posts:
934
Group:
Dedicated
Member
#2,773
Joined:
Apr 9, 2009
its works :) Your awesome Reid, so are you Gor
Offline Profile Goto Top
 
Gorgor Nov 6 2009, 04:34 PM Post #9
Hello

Posts:
1,187
Group:
Former Staff
Member
#2,728
Joined:
Apr 2, 2009
Coding language
PHP
Thanks Reid. At first I was making it so that the names would be who would be using the code, but then I changed it and forgot that it wouldn't work :P

You're welcome.
See? We can read thoughts too. ;)

Your request has been completed, and we're moving it to the correct forum. We hope it works for you; if it doesn't, feel free to post another request topic in the requests forum. Just remember: read the rules first!

Thanks,
The ZBCode Staff
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Completed Requests · Next Topic »
Locked Topic

Track Topic · E-mail Topic Time: 2:26 PM Jul 11
Hosted for free by ZetaBoards · Privacy Policy