How do I SCM when this timer hits 0?
#1

How do I do a SCM when this timer hits 0?

PHP Code:
CMD:repaircar(playeridparams[]) 

    if(
gettime() - GetPVarInt(playerid,"last_time_repaircar") < 5) return SendClientMessage(playerid0xAA3333AA"[INFO]: You can only use this command once every 15 minutes.");
    
    new 
Float:vehhp;
    
GetVehicleHealth(GetPlayerVehicleID(playerid), vehhp);
    if(!
IsPlayerInRangeOfPoint(playerid52073.6338, -1831.224213.5469))    return SendClientMessage(playerid, -1"[INFO]: You are not at of the repair center");
    if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid0xAA3333AA"[INFO]: You must be in vehicle to use this command!");
    if(
vehhp == 1000) return SendClientMessage(playerid0xAA3333AA"[INFO] Your car doesn't need to be repaired.");            
    if(
GetPlayerMoney(playerid) < 850) return SendClientMessage(playerid0xAA3333AA"[INFO]: You don't have enough money to repair your car!");
    
    
SetPVarInt(playerid,"last_time_repaircar",gettime( ));
    
RepairVehicle(GetPlayerVehicleID(playerid));
    
GivePlayerMoney(playerid, -850); 
    
SendClientMessage(playerid, -1"You paid $850 to repair your vehicle.");
    
    
PlayerPlaySound(playerid1133000);
    
    return 
1

I tried this but it doesn't work.

PHP Code:
forward OnPlayerRepairTimerZero(playerid);
public 
OnPlayerRepairTimerZero(playerid)
{
    if(
gettime() - GetPVarInt(playerid,"last_time_repaircar") < 1SendClientMessage(playerid, -1"[INFO]: You can now use the repair center again.");
    return 
1;

Reply
#2

You have to set a timer that will call the public function OnPlayerRepairTimerZero after the desired time interval.

https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#3

Quote:
Originally Posted by SyS
View Post
You have to set a timer that will call the public function OnPlayerRepairTimerZero after the desired time interval.

https://sampwiki.blast.hk/wiki/SetTimerEx
Just as Georgia said you need to set a player timer, which does everything exactly like SetTimer but you use it for player functions.
Reply
#4

Quote:
Originally Posted by Coox
View Post
Just as Georgia said you need to set a player timer, which does everything exactly like SetTimer but you use it for player functions.
who the fuck is Georgia ? lmao
Reply
#5

So then how do I get the timer value after that?

For example after /repaircar ---> it sets a timer for 10mins

How do I get the timer value so that if someone types /repaircar while the timer is still on, they get a msg saying, "You cant use this cmd now"?

Do I just...

new timer = SetTimerEx(blah blah);

??
Reply
#6

Quote:
Originally Posted by aKnoxx
View Post
So then how do I get the timer value after that?

For example after /repaircar ---> it sets a timer for 10mins

How do I get the timer value so that if someone types /repaircar while the timer is still on, they get a msg saying, "You cant use this cmd now"?

Do I just...

new timer = SetTimer(blah blah);

??
Since you are going to use SetTimerEx and you are not showing rest of time to wait,you don't have to use gettime,instead use an array say CarRepairLock

PHP Code:
//global array or just add as an enum constant if you already have one
new bool:CarRepairLock[MAX_PLAYER];
//....
CMD:repaircar(playeridparams[]){ 
    if(
CarRepairLock[playerid]){
        
//send error message
        
return 1
    }
    
//rest of the cmd...... 
    //settimer
    
CarRepairLock[playerid] = true;
    return 
1;
}
forward OnPlayerRepairTimerZero(playerid); 
public 
OnPlayerRepairTimerZero(playerid){ 
    
SendClientMessage(playerid, -1"[INFO]: You can now use the repair center again."); 
    
//no more restriction..
    
CarRepairLock[playerid] = false;
    return 
1

Reply
#7

TYVM. +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)