09.02.2014, 03:26
You can use a loop.
That declaration will create a variable named "i", and will run each time i is less than 10, ascending i by one every time it is run.
For players, you can loop like this
That will repeat the code for every player online, being 'i' the player.
Voila, a loop within a loop also works, too, where 'i' are the players and 'a' are the different drops.
pawn Код:
for(new i; i < 10; i ++)
For players, you can loop like this
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(!IsPlayerConnected(i)) continue;
//do your code
}
pawn Код:
if (PRESSED( KEY_CROUCH ))
{
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(!IsPlayerConnected(i)) continue;
for(new a = 0; a < sizeof(gasdrop[]); a ++)
{
if(IsValidDynamicObject(gasdrop[i][a]) && IsPlayerInRangeOfPoint(playerid,1.0,dX[i][a],dY[i][a],dZ[i][a]))
{
gascan[playerid] = gascan[playerid] +1;
SendClientMessage(playerid, -1, "* 1 full gas can has been added to your inventory");
DestroyDynamicObject(gasdrop[i][a]);
}
}
}
}