Set a timer for robbery anims. -
STONEGOLD - 18.06.2015
Hi, I'm using this anims for robbery but i want to set a timer like for 30 seconds. After 30 seconds player should be out of animation.
PHP код:
ApplyAnimation(playerid,"ROB_BANK","CAT_Safe_Rob", 1, 1, 0, 0, 0, 0, 1);
how to set a timer for it
PHP код:
if(ROBBING_PIZZA1[i] > 1) // Checking if robbery time is above 1
{
ROBBING_PIZZA1[i] --; // Decreasing time
new time[256]; //adding time variable
format(time,sizeof(time),"~y~Robbery Time: %d~n~~r~DO NOT MOVE UNTIL THE~n~ROBBERY IS COMPLETED",ROBBING_PIZZA1[i]);
GameTextForPlayer(i,time,3000,3); //shows gametext showing the time remaining for the robbery
ApplyAnimation(i,"ROB_BANK","CAT_Safe_Rob", 1, 1, 0, 0, 0, 10, 3);
}
if(ROBBING_PIZZA1[i] == 1) // IF the timer reached 1
{
new string[256], pName[MAX_PLAYER_NAME];// getting player name
GetPlayerName(i,pName,MAX_PLAYER_NAME);
ROBBING_PIZZA1[i] =0; // RESET timer
new earning =random(35000);
format(string,sizeof(string),"%s (%d) has stolen $%d from Well Stacked Pizza",pName,i,earning);
SendClientMessageToAll(COLOR_CYAN,string);
format(string,sizeof(string),"ROBBERY COMPLETED");
GameTextForPlayer(i,string, 1000, 3);
GivePlayerCashEx(i, earning);
SetPlayerWantedLevelEx(i, GetPlayerWantedLevel(i) + 1); //giving player 1 wanted level
GivePlayerScore(i,1);
pInfo[i][pStoreRobbed] ++;
pInfo[i][pStoreRobbedMoney] = pInfo[i][pStoreRobbedMoney] +earning;
}
Re: Set a timer for robbery anims. -
STONEGOLD - 18.06.2015
Why isn't working? It doesn't apply animation.
Re: Set a timer for robbery anims. -
STONEGOLD - 18.06.2015
Anyone help me. I want to set these things on my robbery system. As you can see in picture. The money bag and the box. And they both should be dissappear after 30 seconds which means robbery completed.
Re: Set a timer for robbery anims. -
Gammix - 18.06.2015
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:
pawn Код:
new RoberyObject[MAX_PLAYERS];
Declare a timer using
SetTimerEx. For example:
pawn Код:
SetTimerEx("OnRoberyComplete", 30 * 1000, false, "i", playerid);
Make sure you have all the required arguments in the timer.
So when the robery starts (in your script):
pawn Код:
RoberyObject[playerid] = CreateObject(...);
SetPlayerAttachedObject(..);
SetTimerEx("OnRoberyComplete", 30 * 1000, false, "i", playerid);
Now destroy the box object and the attached object from the player whenever the robbery ends (after 30 secs)
pawn Код:
forward OnRoberyComplete(playerid);
public OnRoberyComplete(playerid)
{
RemovePlayerAttachedObject(playerid, 0);
DestroyObject(RoberyObjecy[playerid]);
}
Note the index in RemovePlayerAttachedObject is 0, you can set it to other value provided the object was attached to that slot.
Re: Set a timer for robbery anims. -
STONEGOLD - 18.06.2015
The money bag works. ANd What is id of this box? Also, I want to add this animation too.
PHP код:
ApplyAnimation(playerid,"ROB_BANK","CAT_Safe_Rob", 1, 1, 0, 0, 0, 0, 1);
I mean, How can i make it this animation will be stopped automatic after 30 seconds.
Re: Set a timer for robbery anims. -
J0sh... - 18.06.2015
Put that in your command with looping 1.
On the robberycomplete (2nd reply above) ClearAnimations
Re: Set a timer for robbery anims. -
STONEGOLD - 18.06.2015
Thanks