SA-MP Forums Archive
Timer 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer help (/showthread.php?tid=252888)



Timer help - boyan96 - 03.05.2011

How i can can put on this command timer and after 2 minutes to can spawn car again


Code:
if (strcmp("/NRG", cmdtext, true, 10) == 0)
    {
    if (PlayerInfo[playerid][pDonateRank] >= 3)
	{
    new Float:X,Float:Y,Float:Z,Float:Angle, carid;
	GetPlayerPos(playerid,X,Y,Z);
	GetPlayerFacingAngle(playerid,Angle);
    carid = GetPlayerVehicleID(playerid);
	carid = CreateVehicle(522,X,Y,Z,Angle,-1,-1,600);
	PutPlayerInVehicle(playerid,carid,0);
	TogglePlayerControllable(playerid,true);
    return SendClientMessage(playerid, 0x40FF40FF, "NRG has been spawned!");
    	 	}
	return 1;
	}



Re: Timer help - MadeMan - 03.05.2011

pawn Code:
if (strcmp("/NRG", cmdtext, true) == 0)
{
    if (PlayerInfo[playerid][pDonateRank] >= 3)
    {
        if(GetTickCount() - GetPVarInt(playerid, "LastNRG") < 120000) return SendClientMessage(playerid, 0xFF0000FF, "You have to wait 2 minutes before spawning new NRG");
        new Float:X,Float:Y,Float:Z,Float:Angle, carid;
        GetPlayerPos(playerid,X,Y,Z);
        GetPlayerFacingAngle(playerid,Angle);
        carid = GetPlayerVehicleID(playerid);
        carid = CreateVehicle(522,X,Y,Z,Angle,-1,-1,600);
        PutPlayerInVehicle(playerid,carid,0);
        TogglePlayerControllable(playerid,true);
        SetPVarInt(playerid, "LastNRG", GetTickCount());
        return SendClientMessage(playerid, 0x40FF40FF, "NRG has been spawned!");
    }
    return 1;
}