Small issue with playerstate
#1

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
Reply
#2

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 )
Reply
#3

Thank you very much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)