SA-MP Forums Archive
Nooby question about if - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Nooby question about if (/showthread.php?tid=138909)



Nooby question about if - bajskorv123 - 03.04.2010

Hey, I've havent scripted with onplayerdeath for a while and now i forgot.
Didnt find it on the wiki.

How to check for the opposite of
pawn Код:
if(killerid == INVALID_PLAYER_ID)
Instead of doing
pawn Код:
if(killerid == INVALID_PLAYER_ID)
{
}
else
{
//...
}



Re: Nooby question about if - Nero_3D - 03.04.2010

pawn Код:
if((killerid == INVALID_PLAYER_ID) == false) {}
if(!(killerid == INVALID_PLAYER_ID)) {}



Re: Nooby question about if - bajskorv123 - 03.04.2010

Will
pawn Код:
if(!killerid == INVALID_PLAYER_ID)
Work too?


Re: Nooby question about if - biltong - 03.04.2010

pawn Код:
if(killerid != INVALID_PLAYER_ID)



Re: Nooby question about if - Nero_3D - 03.04.2010

Quote:
Originally Posted by [NWA
Hannes ]
Will
pawn Код:
if(!killerid == INVALID_PLAYER_ID)
Work too?
No that would be something different

Quote:
Originally Posted by biltong
pawn Код:
if(killerid != INVALID_PLAYER_ID)
That works, too


Re: Nooby question about if - biltong - 03.04.2010

Quote:
Originally Posted by [NWA
Hannes ]
Will
pawn Код:
if(!killerid == INVALID_PLAYER_ID)
Work too?
When you say !<variable>, or !<function>, you are basically checking if your variable or function returns zero, so in this case, you are checking if 0 == INVALID_PLAYER_ID