order of conditions in if()

Started by .nnnnn1
22 Dec 2008, 16:49
Page 1 of 2
22 Dec 2008, 16:49(edited 2 Jan 2009, 22:17)

<{
if(!is_user_alive(id) || g_iBestClimber != id || g_fStartTime[id])
{
return 1;
}
if(!get_user_noclip(id))
{
set_user_noclip(id,1)
set_hudmessage(0, 255, 0, 0.6, 0.01, 2, 7.0, 8.0, 0.1, 1.0, -1);
show_hudmessage(id, "Noclip Activated.");
}
else
{
set_user_noclip(id,0)
set_hudmessage(0, 255, 0, 0.6, 0.01, 2, 7.0, 8.0, 0.1, 1.0, -1);
show_hudmessage(id, "Noclip Disabled.");
}
return PLUGIN_HANDLED
} >>

hi. i hope that someone can help me with this line:

if(!is_user_alive(id) || g_iBestClimber != id || g_fStartTime[id])

first, it`s verified if the user is alive, than if he is the 1337 climber (bestclimber) than if that player have the timer running. if he pass all conditions, he will recieve noclip reward. i want to use noclip if i am only admin, not necessarly bestclimber. i know that something should be added to that line, something like "&& is_user_admin(id)", i`ve tried, but nothing happened, except all players were allowed to use that reward.

22 Dec 2008, 17:57

if(!is_user_alive(id) && (is_user_admin(id) || g_iBestClimber != id) && g_fStartTime[id])

22 Dec 2008, 18:10

still nothing

22 Dec 2008, 19:19(edited 23 Dec 2008, 14:06)

public clcmd_noclip(id)
{
if(is_user_alive(id) && g_iBestClimber[id] && g_fStartTime[id])
{
return 1;
}
if(!get_user_noclip(id))
{
set_user_noclip(id,1)
set_hudmessage(0, 255, 0, 0.6, 0.01, 2, 7.0, 8.0, 0.1, 1.0, -1);
show_hudmessage(id, "Noclip Activated.");
}
else
{
set_user_noclip(id,0)
set_hudmessage(0, 255, 0, 0.6, 0.01, 2, 7.0, 8.0, 0.1, 1.0, -1);
show_hudmessage(id, "Noclip Disabled.");
}
return PLUGIN_HANDLED
}

//mod edit:
pls do not use code tags -schlumpf

22 Dec 2008, 19:31

and what`s the connection between "&&" and admin flag acces ?

23 Dec 2008, 13:21(edited 23 Dec 2008, 14:06)

public clcmd_noclip( id ) {
if(!is_user_alive(id) && (is_user_admin(id) || g_iBestClimber != id) && g_fStartTime[id])
return PLUGIN_HANDLED;

set_hudmessage(0, 255, 0, 0.6, 0.01, 2, 7.0, 8.0, 0.1, 1.0, -1);

if(!get_user_noclip(id)) {
set_user_noclip(id, 1);
show_hudmessage(id, "Noclip Activated.");
} else {
set_user_noclip(id, 0);
show_hudmessage(id, "Noclip Disabled.");
}
return PLUGIN_HANDLED;
}


//mod edit:
pls do not use code tags -schlumpf

23 Dec 2008, 15:46(edited 23 Dec 2008, 15:55)

i don`t know what to do, it really doesn`t want to work with everything that i`m trying to do. xpaw, still nothing ... 8-| it gives noclip to everyone, not only for admins ...

23 Dec 2008, 15:59

change
if(!is_user_alive(id) && (is_user_admin(id) || g_iBestClimber != id) && g_fStartTime[id])

to

if(!is_user_alive(id) && (is_user_admin(id) || g_iBestClimber == id) && g_fStartTime[id])

23 Dec 2008, 16:12

not working ... i`ve tried it with if(!is_user_alive(id) && ((get_user_flags(id) & ADMIN_LEVEL_B) || g_iBestClimber != id) && g_fStartTime[id]) too and it doesn`t works ... i don`t think is possible to work ..

23 Dec 2008, 17:34(edited 23 Dec 2008, 17:35)

if(is_user_alive(id) && (is_user_admin(id) || g_iBestClimber == id) && g_fStartTime[id])

why the fuck there was !is_user_alive

23 Dec 2008, 18:40(edited 23 Dec 2008, 18:41)

because after those negations was "return 1;", and g_fStartTime[id] must be false in order to continue plugin

23 Dec 2008, 18:58(edited 23 Dec 2008, 18:59)

http://ampaste.net/d70cc6819

23 Dec 2008, 23:20

yes xpaw, i tested that, and it`s giving noclip to everybody, not only admins.

24 Dec 2008, 14:54

Test this: Link

24 Dec 2008, 17:33

but there is a problem with this cmd

if( (is_user_alive(id) && g_fStartTime[id]) && (is_user_admin(id) || g_iBestClimber == id) )

if player is BestClimber = ok = noclip on

someone beat his time and he wants to turn off noclip, he can't =)

24 Dec 2008, 19:36

no, i made a command to activate and deactivate it xD here only it gives acces to activate/deactivate

1 Jan 2009, 18:16

if(!is_user_alive(id) || !is_user_admin(id) || g_iBestClimber != id || g_fStartTime[id])

1 Jan 2009, 19:24

thanks it worked

1 Jan 2009, 21:24

Originally posted by doktor
if(!is_user_alive(id) || !is_user_admin(id) || g_iBestClimber != id || g_fStartTime[id])


So he must be and admin and best climber...

Use this:

if(!is_user_alive(id) || !(is_user_admin(id) || g_iBestClimber == id) || g_fStartTime[id])

2 Jan 2009, 11:05

thx a lot numb xD

Page 1 of 2

Reply

Please log in to post replies.