22.07.2010, 16:10
Hey!
If I use KillTimer when the timer do not active it crashes my server?
Nonameman
If I use KillTimer when the timer do not active it crashes my server?
Nonameman
Can you show us the line where you use SetTimer or SetTimerEx pls?
|
new pvptimer;
dcmd_pvp(playerid, params[])
{
#pragma unused params
new
Pvp = GetPVarInt(playerid, "Pvp");
if(Pvp == 0)
{
KillTimer(pvptimer);
SetPVarInt(playerid, "Pvp", 1);
SendClientMessage(playerid, colorPVP, "PVP Bekapcsolva!");
}
else if(Pvp == 1)
{
SendClientMessage(playerid, colorPVP, "Vбrnod kell 5 percet hogy kikapcsoljon a PVP!");
pvptimer = SetTimerEx("PvpOff", 5*60*1000, false, "d", playerid);
}
return 1;
}
forward PvpTimer(playerid);
public PvpTimer(playerid)
{
SetPVarInt(playerid, "Pvp", 0);
SendClientMessage(playerid, colorPVP, "PVP Kikapcsolva!");
return 1;
}
new pvptimer[MAX_PLAYERS];
dcmd_pvp(playerid, params[]) { #pragma unused params new Pvp = GetPVarInt(playerid, "Pvp"); if(Pvp == 0) { KillTimer(pvptimer); //if the value starts at 0 then the timer is not even running SetPVarInt(playerid, "Pvp", 1); SendClientMessage(playerid, colorPVP, "PVP Bekapcsolva!"); } if(Pvp == 1) { SendClientMessage(playerid, colorPVP, "Vбrnod kell 5 percet hogy kikapcsoljon a PVP!"); pvptimer[playerid] = SetTimerEx("PvpOff", 300000, 0, "i", playerid); } return 1; }
forward PvpTimer(playerid); public PvpTimer(playerid) { SetPVarInt(playerid, "Pvp", 0); SendClientMessage(playerid, colorPVP, "PVP Kikapcsolva!"); return 1; }
Try this :
Код:
new pvptimer; Код:
dcmd_pvp(playerid, params[]) { #pragma unused params new Pvp = GetPVarInt(playerid, "Pvp"); if(Pvp == 0) { KillTimer(pvptimer); SetPVarInt(playerid, "Pvp", 1); SendClientMessage(playerid, colorPVP, "PVP Bekapcsolva!"); } if(Pvp == 1) { SendClientMessage(playerid, colorPVP, "Vбrnod kell 5 percet hogy kikapcsoljon a PVP!"); pvptimer = SetTimerEx("PvpOff", 300000, 0, "i", playerid); } return 1; } Код:
forward PvpTimer(playerid); public PvpTimer(playerid) { SetPVarInt(playerid, "Pvp", 0); SendClientMessage(playerid, colorPVP, "PVP Kikapcsolva!"); return 1; } |
new pvptimer = -1;
if(pvptimer != -1) KillTimer(pvptimer);
The problem is that PVars are by default 0 up to the moment when we set them to an another value.
So when you use this command you're firstly trying to kill a timer who haven't started yet. Try: pawn Код:
pawn Код:
You should use: new pvptimer[MAX_PLAYERS] = -1; or PVars to save the timerid, because when you kill this timer, you kill it for everybody xD ^^ |