It's me again..
#1

PHP код:
CMD:repairmycar(playeridparams[])
{
    if(!
IsPlayerInAnyVehicle(playerid))
        return 
SendErrorMessage(playerid"You are not in a vehicle!");
    if(
GetPlayerState(playerid) != 2)
        return 
SendErrorMessage(playerid"You are not in the driver seat!");
    if(!
IsPlayerInRangeOfPoint(playerid15.0, -2417.77442303.79791.8781))
        return 
SendErrorMessage(playerid"You should be in range of the point to /repairmycar !");
    
SendClientMessage(playeridCOLOR_WHITE"Your vehicle will be ready in a half of hour (30 seconds).");
    
RemovePlayerFromVehicle(playerid);
    
SetTimerEx("RepairMyCar",30000,false,"d",GetPlayerVehicleID(playerid));
    
GivePlayerMoney(playerid, - 150);
    return 
1;
}
forward RepairMyCar(pvehicleid);
public 
RepairMyCar(pvehicleid)
{
    
RepairVehicle(pvehicleid);
    return 
1;

I am trying to make so if you leave the point
PHP код:
if(!IsPlayerInRangeOfPoint(playerid15.0, -2417.77442303.79791.8781)) 
the repairing process stops.
Reply
#2

Create a timer, and in timer function check if player is range of point.

https://sampwiki.blast.hk/wiki/SetTimer

Btw, don't forget to kill/stop the timer later on.
Reply
#3

Okay, but how to stop the repairing?

I got this for now: (the things that I added are marked in red)

Код:
CMD:repairmycar(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid))
        return SendErrorMessage(playerid, "You are not in a vehicle!");

    if(GetPlayerState(playerid) != 2)
        return SendErrorMessage(playerid, "You are not in the driver seat!");

    if(!IsPlayerInRangeOfPoint(playerid, 15.0, -2417.7744, 2303.7979, 1.8781))
        return SendErrorMessage(playerid, "You should be in range of the point to /repairmycar !");

    SendClientMessage(playerid, COLOR_WHITE, "Your vehicle will be ready in a half of hour (30 seconds).");

    RemovePlayerFromVehicle(playerid);
    SetTimerEx("RepairMyCar",30000,false,"d",GetPlayerVehicleID(playerid));
    SetTimer(RepairCheck, 30, false);
    GivePlayerMoney(playerid, - 150);
    return 1;
}

public RepairCheck()
{
    if(!IsPlayerInRangeOfPoint(playerid, 15.0, -2417.7744, 2303.7979, 1.8781))
}


forward RepairMyCar(pvehicleid);
public RepairMyCar(pvehicleid)
{
    RepairVehicle(pvehicleid);
    return 1;
}
Reply
#4

https://sampwiki.blast.hk/wiki/KillTimer
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)