Small issue with playerstate - 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)
+--- Thread: Small issue with playerstate (
/showthread.php?tid=601360)
Small issue with playerstate -
notaromanian - 20.02.2016
Hey there.
I was wondering if you guys could help me with getting 2 playerstates work simultaneously but not having both mandatory at the same time. Having something like X or Y instead of X and Y
Код:
stock GetPlayersOnBlueTeam()
{
new BlueTeam=0;
for (new i=0;i<MAX_PLAYERS;i++)
{
if(GetPlayerState(i) == PLAYER_STATE_ONFOOT && GetPlayerState(i) == PLAYER_STATE_DRIVER && GetPVarInt(i, "team") == 1 && GetPVarInt(i, "spectating") == 0 )
{
BlueTeam++;
}
}
return BlueTeam;
}
With this, the player has to be both on foot and driving in order to be added to the counter, and I want to have it like "if the player is either on foot or driving, add him to the counter"
Thank you
Re: Small issue with playerstate -
Chump - 20.02.2016
The logical OR operator "||" is what you're looking for. If the first statement is false, then it will check if the second one is true and so on.
pawn Код:
if((GetPlayerState(i) == PLAYER_STATE_ONFOOT || GetPlayerState(i) == PLAYER_STATE_DRIVER) && GetPVarInt(i, "team") == 1 && GetPVarInt(i, "spectating") == 0 )
Re: Small issue with playerstate -
notaromanian - 21.02.2016
Thank you very much!