SA-MP Forums Archive
Help? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help? (/showthread.php?tid=609708)



Help? - Micko123 - 15.06.2016

I made /robbank and it works good. But i want to know how can i make command that will show time left for robbery. I have no idea where ot start from. Can i get little help from you??


Re: Help? - Sime30 - 15.06.2016

You create a player timer that will repeat itself every second. In the callback/public, you create Player textdraw that will update itself and show on the screen whenever timer is called. You kill the timer when the time runs out


Re: Help? - Micko123 - 15.06.2016

well that is good start .


Re: Help? - TwinkiDaBoss - 15.06.2016

Its quite simple

PHP Code:

#define TIME_NEEDED_TO_ROB 60   //change 60 to how many seconds you want of the player to stand inside
new BankRobbing[MAX_PLAYERS],
    
RobbingTimer[MAX_PLAYERS];
CMD:robbank(playerid,params[]) {
    new 
currenttime gettime();
    if(
currenttime BankRobbing[playerid]) return SendClientMessage(playerid,COLOR_RED,"You are still robbing the bank!");
    
BankRobbing[playerid] += TIME_NEEDED_TO_ROB;
    
RobbingTimer[playerid] = SetTimerEx("timer_Robbing",1000,true,"i",playerid);
    
SendClientMessageToAll(COLOR_GREEN,"Bank is being robbed!");
    return 
true;
}
forward timer_Robbing(playerid);
public 
timer_Robbing(playerid) {
    new 
calc BankRobbing[playerid]-gettime(); //this will get you how many seconds they have left
    
if(calc <= 0) { //if the time passed
        
KillTimer(RobbingTimer[playerid]); 
        return 
true;
    }
    
    new 
string[128];
     
format(string,sizeof(string),"Time left %i",calc);
      
SendClientMessage(playerid,COLOR_RED,string);
    return 
true;