assign number automatically as array?
#7

If you want to use that array per player to store 5 objects each per player:
Code:
new objects[MAX_PLAYERS][5];

cmd:object(playerid, params[])
{
    objects[playerid][0] = createplayerobjectxxx
    objects[playerid][1] = createplayerobjectxxx
    objects[playerid][2] = createplayerobjectxxx
    objects[playerid][3] = createplayerobjectxxx
    objects[playerid][4] = createplayerobjectxxx

    return 1;
}
When player 3 uses this command, the server will have the value "3" for the "playerid" variable and will simply use it as a reference to access the array.
So it will create all 5 objects for player 3 in this array as if you had typed this:
Code:
new objects[MAX_PLAYERS][5];

cmd:object(playerid, params[])
{
    objects[3][0] = createplayerobjectxxx
    objects[3][1] = createplayerobjectxxx
    objects[3][2] = createplayerobjectxxx
    objects[3][3] = createplayerobjectxxx
    objects[3][4] = createplayerobjectxxx

    return 1;
}
The same will happen for player 27.
The server will simply paste "27" as the first index of the array.
Reply


Messages In This Thread
assign number automatically as array? - by Crystallize - 13.06.2018, 23:50
Re: assign number automatically as array? - by Ada32 - 14.06.2018, 00:10
Re: assign number automatically as array? - by NaS - 14.06.2018, 00:16
Re: assign number automatically as array? - by jlalt - 14.06.2018, 00:25
Re: assign number automatically as array? - by Crystallize - 14.06.2018, 10:56
Re: assign number automatically as array? - by Ada32 - 14.06.2018, 12:02
Re: assign number automatically as array? - by AmigaBlizzard - 14.06.2018, 21:42

Forum Jump:


Users browsing this thread: 1 Guest(s)