Set a timer for robbery anims.
#1

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"1100001); 
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"11000103);
                }
                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,string10003);
                    
GivePlayerCashEx(iearning);
                    
SetPlayerWantedLevelEx(iGetPlayerWantedLevel(i) + 1); //giving player 1 wanted level
                    
GivePlayerScore(i,1);
                    
pInfo[i][pStoreRobbed] ++;
                    
pInfo[i][pStoreRobbedMoney] = pInfo[i][pStoreRobbedMoney] +earning;
                } 
Reply
#2

Why isn't working? It doesn't apply animation.
Reply
#3

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.

Reply
#4

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.
Reply
#5

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"1100001); 
I mean, How can i make it this animation will be stopped automatic after 30 seconds.
Reply
#6

Put that in your command with looping 1.

On the robberycomplete (2nd reply above) ClearAnimations
Reply
#7

Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)