Time Issue - 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: Time Issue (
/showthread.php?tid=579898)
Time Issue -
SkyWinder - 30.06.2015
I have a command to fill car fuel.
If I leave the pump while filling fuel it starts spamming the debug message.
It should kill the timer but it does'nt. Then i exit the vehicle and it still spams me.
Even tho on Vehicle exit there is a kill time for this.
Please help me i am very confused why this happens.
pawn Код:
CMD:refuel(playerid, params[])
{
#pragma unused params
if(!IsPlayerInAnyVehicle(playerid)) return SystemMsg(playerid, "You must be in a vehicle.");
if(!NearGasStation(playerid)) return SystemMsg(playerid, "You must be at a gas station to use this command.");
if(RFuel[playerid] == true) return SystemMsg(playerid, "Your vehicle is already being refueled.");
RFuel[playerid] = true;
RefuelTimer[playerid] = SetTimerEx("RefuelPlayer", 2000, true, "i", playerid);
return 1;
}
public RefuelPlayer(playerid)
{
if(!IsPlayerInAnyVehicle(playerid))
{
KillTimer(RefuelTimer[playerid]);
RFuel[playerid] = false;
new string[128];
format(string, sizeof(string), "ID %i, KillTimer ID : %i, RFuel : %i", playerid, KillTimer(RefuelTimer[playerid]), RFuel[playerid]);
SystemMsg(playerid ,string);
return SystemMsg(playerid, "[DEBUG] Not in vehicle. Killing timer.");
}
if(!NearGasStation(playerid))
{
KillTimer(RefuelTimer[playerid]);
RFuel[playerid] = false;
KillTimer(RefuelTimer[playerid]);
return SystemMsg(playerid, "[DEBUG] Not near gas station. Killing timer.");
}
if(TakeMoney(playerid, 20))
{
KillTimer(RefuelTimer[playerid]);
RFuel[playerid] = false;
KillTimer(RefuelTimer[playerid]);
return SendClientMessage(playerid, COLOR_LIME, "You do not have enough money! Gas costs $20 per 10 units.");
}
new vid = GetPlayerVehicleID(playerid);
if(CarFuel[vid] > 90.000000)
{
KillTimer(RefuelTimer[playerid]);
RFuel[playerid] = false;
KillTimer(RefuelTimer[playerid]);
CarFuel[vid] = 100.000000;
if(IsVehicleOwned(vid))
{
new fileid = FileID[vid];
new Lol1[25];
format(Lol1, sizeof(Lol1), "/Vehicles/%i.ini", fileid);
dini_FloatSet(Lol1, "Fuel", CarFuel[vid]);
}
return SystemMsg(playerid, "You vehicle has been refueled.");
}
CarFuel[vid] = CarFuel[vid] + 10.000000;
new string[40];
//format(string, sizeof(string), "[DEBUG] Your current fuel is: %f", CarFuel[vid]);
SystemMsg(playerid, string);
if(IsVehicleOwned(vid))
{
new fileid = FileID[vid];
new Lol1[25];
format(Lol1, sizeof(Lol1), "/Vehicles/%i.ini", fileid);
dini_FloatSet(Lol1, "Fuel", CarFuel[vid]);
}
return 1;
}
Re: Time Issue -
kloning1 - 30.06.2015
i dont think this will be working :3
pawn Код:
public RefuelPlayer(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(NearGasStation(playerid))
{
if(TakeMoney(playerid, 20))
{
KillTimer(RefuelTimer[playerid]);
RFuel[playerid] = false;
KillTimer(RefuelTimer[playerid]);
return SendClientMessage(playerid, COLOR_LIME, "You do not have enough money! Gas costs $20 per 10 units.");
}
new vid = GetPlayerVehicleID(playerid);
if(CarFuel[vid] > 90.000000)
{
KillTimer(RefuelTimer[playerid]);
RFuel[playerid] = false;
KillTimer(RefuelTimer[playerid]);
CarFuel[vid] = 100.000000;
if(IsVehicleOwned(vid))
{
new fileid = FileID[vid];
new Lol1[25];
format(Lol1, sizeof(Lol1), "/Vehicles/%i.ini", fileid);
dini_FloatSet(Lol1, "Fuel", CarFuel[vid]);
}
return SystemMsg(playerid, "You vehicle has been refueled.");
}
CarFuel[vid] = CarFuel[vid] + 10.000000;
new string[40];
//format(string, sizeof(string), "[DEBUG] Your current fuel is: %f", CarFuel[vid]);
SystemMsg(playerid, string);
if(IsVehicleOwned(vid))
{
new fileid = FileID[vid];
new Lol1[25];
format(Lol1, sizeof(Lol1), "/Vehicles/%i.ini", fileid);
dini_FloatSet(Lol1, "Fuel", CarFuel[vid]);
}
}
else
{
KillTimer(RefuelTimer[playerid]);
RFuel[playerid] = false;
KillTimer(RefuelTimer[playerid]);
return SystemMsg(playerid, "[DEBUG] Not near gas station. Killing timer.");
}
}
else
{
KillTimer(RefuelTimer[playerid]);
RFuel[playerid] = false;
new string[128];
format(string, sizeof(string), "ID %i, KillTimer ID : %i, RFuel : %i", playerid, KillTimer(RefuelTimer[playerid]), RFuel[playerid]);
SystemMsg(playerid ,string);
return SystemMsg(playerid, "[DEBUG] Not in vehicle. Killing timer.");
}}
return 1;
}
Re: Time Issue -
SkyWinder - 01.07.2015
I think its a problem with SetTimerEx fixes.
First this happened when I used fixes2 then it happened again with TimerFix.
Any good timer fixing include which doesnt mess other parts of the script?