18.06.2015, 05:47
You can use SetPlayerAttachedObject to attach any object to the player and use it to attach the bag to the player when the robbery starts.
On the same time, create the box using CreateObject. The object id must be stored in a var or array, use a player array.
For example:
Declare a timer using SetTimerEx. For example:
Make sure you have all the required arguments in the timer.
So when the robery starts (in your script):
Now destroy the box object and the attached object from the player whenever the robbery ends (after 30 secs)
Note the index in RemovePlayerAttachedObject is 0, you can set it to other value provided the object was attached to that slot.
On the same time, create the box using CreateObject. The object id must be stored in a var or array, use a player array.
For example:
pawn Код:
new RoberyObject[MAX_PLAYERS];
pawn Код:
SetTimerEx("OnRoberyComplete", 30 * 1000, false, "i", playerid);
So when the robery starts (in your script):
pawn Код:
RoberyObject[playerid] = CreateObject(...);
SetPlayerAttachedObject(..);
SetTimerEx("OnRoberyComplete", 30 * 1000, false, "i", playerid);
pawn Код:
forward OnRoberyComplete(playerid);
public OnRoberyComplete(playerid)
{
RemovePlayerAttachedObject(playerid, 0);
DestroyObject(RoberyObjecy[playerid]);
}