player timer does not stop [ SOLVED ] - 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: player timer does not stop [ SOLVED ] (
/showthread.php?tid=622793)
player timer does not stop [ SOLVED ] -
Gusteakas - 26.11.2016
Hello.
I create a timer like this:
Код:
pizzaDeliveryTimer[playerid] = SetTimerEx("PizzaDeliveryTimer", 1000, true, "i", playerid);
Код:
public PizzaDeliveryTimer(playerid)
{
pizzaDeliveryTimeLeft[playerid] --;
new
string[146],
vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 448)
{
if(pizzaDeliveryTimeLeft[playerid] > 10)
{
format(string, 256, "~y~%d", pizzaDeliveryTimeLeft[playerid]);
PlayerTextDrawSetString(playerid, pizzaTextDraw7[playerid], string);
}
else if(pizzaDeliveryTimeLeft[playerid] <= 10)
{
format(string, 256, "~r~%d", pizzaDeliveryTimeLeft[playerid]);
PlayerTextDrawSetString(playerid, pizzaTextDraw7[playerid], string);
}
else if(pizzaDeliveryTimeLeft[playerid] == 0)
{
PlayerTextDrawHide(playerid, pizzaTextDraw5[playerid]);
PlayerTextDrawHide(playerid, pizzaTextDraw7[playerid]);
KillTimer(pizzaDeliveryTimer[playerid]);
return 1;
}
}
return 1;
}
When it reaches 0 it should stop but it does not. It still goes -1, -2 and so on..
What am I doing wrong?
Re: player timer does not stop -
IceBilizard - 26.11.2016
PHP код:
public PizzaDeliveryTimer(playerid)
{
pizzaDeliveryTimeLeft[playerid] --;
new string[146], vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 448)
{
if(pizzaDeliveryTimeLeft[playerid] > 10)
{
format(string, 256, "~y~%d", pizzaDeliveryTimeLeft[playerid]);
}
if(pizzaDeliveryTimeLeft[playerid] <= 10)
{
format(string, 256, "~r~%d", pizzaDeliveryTimeLeft[playerid]);
}
PlayerTextDrawSetString(playerid, pizzaTextDraw7[playerid], string);
if(pizzaDeliveryTimeLeft[playerid] == 0)
{
PlayerTextDrawHide(playerid, pizzaTextDraw5[playerid]);
PlayerTextDrawHide(playerid, pizzaTextDraw7[playerid]);
KillTimer(pizzaDeliveryTimer[playerid]);
}
}
}
Re: player timer does not stop -
Gusteakas - 26.11.2016
Thank you very much! It worked.