I need help with my loot system.
#2

You can use a loop.

pawn Код:
for(new i; i < 10;  i ++)
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

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i ++)
{
     if(!IsPlayerConnected(i)) continue;
     //do your code
}
That will repeat the code for every player online, being 'i' the player.


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]);
            }
        }
    }
}
Voila, a loop within a loop also works, too, where 'i' are the players and 'a' are the different drops.
Reply


Messages In This Thread
I need help with my loot system. - by Unfriendly - 08.02.2014, 23:43
Re: I need help with my loot system. - by CuervO - 09.02.2014, 03:26
Re: I need help with my loot system. - by Unfriendly - 10.02.2014, 14:45

Forum Jump:


Users browsing this thread: 1 Guest(s)