17.05.2015, 13:25
Having "box1" and "box2" as global variables and more than 1 player use them at a time will mess the IDs up.
Let's say player A uses the command and it creates the two objects. Player B uses the command too and "box1", "box2" hold the objectid from the player B. When player A is done and you want to delete the objects, you haven't stored them anywhere as they were overwritten by player B so it destroys the objects from player B.
If each player can have 2 boxes, then create a global array:
When you destroy them, set the variables to INVALID_OBJECT_ID as in OnPlayerConnect.
Let's say player A uses the command and it creates the two objects. Player B uses the command too and "box1", "box2" hold the objectid from the player B. When player A is done and you want to delete the objects, you haven't stored them anywhere as they were overwritten by player B so it destroys the objects from player B.
If each player can have 2 boxes, then create a global array:
pawn Код:
// global:
new Player_Box[2][MAX_PLAYERS];
// OnPlayerConnect:
Player_Box[0][playerid] = Player_Box[1][playerid] = INVALID_OBJECT_ID;
pawn Код:
Player_Box[0][playerid] = CreateObject(id ,0,0,-1000,0,0,0,100);
Player_Box[1][playerid] = CreateObject(id,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(Player_Box[0][playerid], GetPlayerVehicleID(playerid), 0.000000,-0.750000,0.300000,0.000000,0.000000,89.099983);
AttachObjectToVehicle(Player_Box[1][playerid], GetPlayerVehicleID(playerid), 0.075000,-0.750000,0.449999,0.000000,0.000000,89.099983);