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)
+--- Thread: Timer Help (/showthread.php?tid=486161)



Timer Help - ReD_HunTeR - 07.01.2014

Код:
new iLastFixCar[MAX_PLAYERS];

CMD:mfix(playerid, params[])
{
    new iCount = GetTickCount();
	if(gClass[playerid] == ENGINEER)
	{
	  if(iCount - iLastFixCar[playerid]) > 10000)
	  {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You must be in vehicle to fix it");
        new VehicleID = GetPlayerVehicleID(playerid);
	    RepairVehicle(VehicleID);
	    GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~Vehicle ~g~Repaired!",3000,3);
	    return SetVehicleHealth(VehicleID, 1000);
	  }
	  else return SendClientMessage(playerid,RED,"You need to wait 10 Seconds to fix car again!");
	}
	else return SendClientMessage(playerid,red,"You Are Not An Engineer to fix your car!");
}
its not working ? why? its just saying You need to wait 10 seconds to fix car again


Re: Timer Help - offon - 07.01.2014

Код:
CMD:mfix(playerid, params[])
{
    new iCount = GetTickCount();
	if(gClass[playerid] == ENGINEER)
	{
 		if(iCount - iLastFixCar[playerid]) > 10000) return SendClientMessage(playerid,RED,"You need to wait 10 Seconds to fix car again!");
	  	else {
        	if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You must be in vehicle to fix it");
        	new VehicleID = GetPlayerVehicleID(playerid);
		    RepairVehicle(VehicleID);
	    	GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~Vehicle ~g~Repaired!",3000,3);
	    	return SetVehicleHealth(VehicleID, 1000);
	  	}
	}
	else return SendClientMessage(playerid,red,"You Are Not An Engineer to fix your car!");
}



Re: Timer Help - Patrick - 07.01.2014

Why GetTickCount(..)? you could use gettime(..) instead, I suggest you use gettime instead of GetTickCount

pawn Код:
CMD:mfix(playerid, params[])
{
    new
        iLastFixCar[MAX_PLAYERS]
    ;

    if(gClass[playerid] != ENGINEER)
        return SendClientMessage(playerid,red,"You Are Not An Engineer to fix your car!");
   
    if(gettime() - iLastFixCar[playerid]) > 1)
        return SendClientMessage(playerid,RED,"You need to wait 10 Seconds to fix car again!");

    if(!IsPlayerInAnyVehicle(playerid))
        return SendClientMessage(playerid,red,"You must be in vehicle to fix it");

    new VehicleID = GetPlayerVehicleID(playerid);
    RepairVehicle(VehicleID);
    GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~Vehicle ~g~Repaired!",3000,3);
    SetVehicleHealth(VehicleID, 1000);
    return iLastFixCar[playerid] = gettime()+10;
}



Re: Timer Help - ReD_HunTeR - 07.01.2014

okey thanks both. fixed i think now..


Re: Timer Help - ReD_HunTeR - 07.01.2014

getting error at this line offone
Код:
if(iCount - iLastFixCar[playerid]) > 10000) return SendClientMessage(playerid,RED,"You need to wait 10 Seconds to fix car again!");
getting error at this line pds2k12
Код:
    if(gettime() - iLastFixCar[playerid]) > 1)



Re: Timer Help - CutX - 07.01.2014

Quote:
Originally Posted by BlackBomb
Посмотреть сообщение
getting error at this line offone
Код:
if(iCount - iLastFixCar[playerid]) > 10000) return SendClientMessage(playerid,RED,"You need to wait 10 Seconds to fix car again!");
getting error at this line pds2k12
Код:
    if(gettime() - iLastFixCar[playerid]) > 1)
if(iCount - iLastFixCar[playerid]) > 10000)

if(gettime() - iLastFixCar[playerid]) > 1)

one bracked too much in both lines


Re: Timer Help - Patrick - 07.01.2014

Quote:
Originally Posted by BlackBomb
Посмотреть сообщение
getting error at this line offone
Код:
if(iCount - iLastFixCar[playerid]) > 10000) return SendClientMessage(playerid,RED,"You need to wait 10 Seconds to fix car again!");
getting error at this line pds2k12
Код:
    if(gettime() - iLastFixCar[playerid]) > 1)
Sorry was missing another bracket, this should work

pawn Код:
if((gettime() - iLastFixCar[playerid]) > 1)



Re: Timer Help - ReD_HunTeR - 07.01.2014

no errors, i think fixed, if not ill tel if yes ill tell that also thanks


Re: Timer Help - ReD_HunTeR - 08.01.2014

i thought it was fixed but not, its showing this msg "you must was 10 second before hea..


Re: Timer Help - CutX - 08.01.2014

Quote:
Originally Posted by BlackBomb
Посмотреть сообщение
i thought it was fixed but not, its showing this msg "you must was 10 second before hea..
well... you didn't really say 10 seconds in the script ^^
Quote:
Originally Posted by BlackBomb
Посмотреть сообщение
Код:
	  if(iCount - iLastFixCar[playerid]) > 10000)
your condition here is to wait 10000 seconds. Which would be 2.77777778 hours

just write 10 instead of 10000

keep in mind that gettime returns the number of seconds passed since Thursday, 1 January 1970.
not in milliseconds.

btw. what'll happen on January 19, 2038?
cuz On this date the Unix Time Stamp will cease to work due to a 32-bit overflow.
that's going 2 be interesting and maybe even dangerous since a lot of stuff, like µControllers rely on it,
using the timestamp to check for extremely important updates and so on...
Imagine an nuclear reactor going nuts :P (well, it won't get that worse, hopefully)