Timer Help
#1

Код:
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
Reply
#2

Код:
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!");
}
Reply
#3

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;
}
Reply
#4

okey thanks both. fixed i think now..
Reply
#5

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)
Reply
#6

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
Reply
#7

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)
Reply
#8

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

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

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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)