Robtimer help
#6

Quote:
Originally Posted by Escobabe
View Post
Thank you everyone, works like a charm now.
Hello regarding your problem, I think it will not work 100%, because if the player can disconnect and connect with another ID and you can steal again unless you have a system to save, another thing that may happen is that the player is disconnected and the timer will continue to run and the player that connects with that ID will tell him that he can steal again, in my case I would use gettime ()

I will give you an example and it is much better because this way you can not abuse the command.

PHP Code:
new JustRobTime[MAX_PLAYERS]; 
PHP Code:
CMD:robbank(playerid,params[]) 

    if(
PlayerInfo[playerid][pVIP] == && JustRobTime[playerid] < gettime()) //Check if you can steal by comparing the time
    

        if(
GetPlayerInterior(playerid) == 3
        { 
                new 
rand=75000 +(random(35000)); 
                new 
Pname[MAX_PLAYER_NAME]; 
                
GetPlayerName(playeridPnamesizeof(Pname)); 
                new 
str[100]; 
                
JustRobTime[playerid] = gettime()+1800;//1800 Seconds = 30 Minuts
                
format(str,sizeof(str),"You've robbed the bank and got $ %d from the robbery"rand); 
                
SendClientMessage(playerid,COLOR_WHITE,str); 
                
format(str,sizeof(str)," %s has robbed the bank of Las Venturas and stole $ %d"Pnamerand); 
                
SendClientMessageToAll(COLOR_ORANGE,str);  
                
GivePlayerMoney(playeridrand); 
                
SetPlayerWantedLevel(playeridGetPlayerWantedLevel(playerid) + 4); 
        } 
        else 
SendClientMessage(playerid,COLOR_RED,"You're not inside the bank to rob it."); 
    } 
    else 
SendClientMessage(playerid,COLOR_RED,"You're not a VIP Member to rob the bank."); 
    return 
1

With this command you can see how much time you need to steal again.

PHP Code:
CMD:robtime(playeridparmas[])
{
    if(
JustRobTime[playerid] < gettime()) return SendClientMessage(playerid, -1"You can steal again");
    new 
RobString[72];
    
format(RobStringsizeof(RobString), "[Rob]  Wait {37B9F5}%d minut(s){FFFAFF} to re-steal",  (JustRobTime[playerid] - gettime()/60)); 
    
SendClientMessage(playerid, -1RobString);
    return 
1;

I would do it this way avoided using Timer.
I did that so I can give you the minutes even if I did not try or compile it, do it and tell me if it works, remember to delete the variable when the player disconnects and load it where you load your users account.

And as they say above do not use two variables to give the format with one is enough I leave the code without the two variables. Another thing is that if you use timer with parameter for example playerid. Use SetTimerEx in SetTimer because the code you passed uses SetTimer.
Reply


Messages In This Thread
Robtimer help - by Escobabe - 28.09.2017, 20:18
Re: Robtimer help - by 10MIN - 28.09.2017, 20:26
Re: Robtimer help - by aoky - 28.09.2017, 20:41
Re: Robtimer help - by Kane - 28.09.2017, 20:50
Re: Robtimer help - by Escobabe - 28.09.2017, 21:08
Re: Robtimer help - by Swankeh - 28.09.2017, 22:53

Forum Jump:


Users browsing this thread: 2 Guest(s)