Timer fu**ed up? - 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 fu**ed up? (
/showthread.php?tid=309422)
Timer fu**ed up? -
Gooday - 07.01.2012
pawn Код:
CMD:ar1(playerid, params[])
{
new id;
if(GetPlayerSkin(playerid) == 285 || GetPlayerSkin(playerid) == 282 || GetPlayerSkin(playerid) == 281 || GetPlayerSkin(playerid) == 283 || GetPlayerSkin(playerid) == 288)
if (sscanf(params, "u", id)) SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /ar1 [ID]");
else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "[INFO]Player not found");
else
{
SetPlayerPos(id, 264.29998779297, 77.800003051758, 1000.5999755859);
SetPlayerVirtualWorld(id, -1);
SetPlayerInterior(id, 6);
GivePlayerMoney(id, -1500);
ResetPlayerWeapons(id);
SendClientMessage(id, COLOR_GOLD, "[INFO]You have been Arrested, Your Sentence is 60 Seconds.");
SendClientMessage(playerid, COLOR_GOLD, "[INFO]Player Arrested succesfully. (Arrest type: 1)");
JailTime[playerid] = 60;
JailTimer[playerid] = SetTimerEx("Unjail",1000,true,"i",playerid);
}
return 1;
}
FORWARD:
pawn Код:
forward UnJail(playerid);
public Unjail(playerid)
{
if(JailTime[playerid] <= 0)
{
//teleport them out of jail
JailTime[playerid] = 0;
KillTimer(JailTimer[playerid]);
SetPlayerPos(playerid, 246.4798,67.8764,1003.6406);
SetPlayerInterior(playerid, 6);
SetPlayerVirtualWorld(playerid, -1);
SendClientMessage(playerid, COLOR_GOLD,"[INFO]You have been UnJailed, Now try to be a good civilian!");
}
return 1;
}
After 60 secs nothing happen
+REP!
Re: Timer fu**ed up? -
BlackWolf120 - 07.01.2012
you have to subtract the jail time variable in your timer with the 1 second interval
pawn Код:
forward UnJail(playerid);
public Unjail(playerid)
{
//put it here...
if(JailTime[playerid] <= 0)
{
JailTime[playerid] = 0;
KillTimer(JailTimer[playerid]);
SetPlayerPos(playerid, 246.4798,67.8764,1003.6406);
SetPlayerInterior(playerid, 6);
SetPlayerVirtualWorld(playerid, -1);
SendClientMessage(playerid, COLOR_GOLD,"[INFO]You have been UnJailed, Now try to be a good civilian!");
}
return 1;
}
//edit:
why dont u just use a timer with a false bool? You could remove the variable then and also u didnt have to kill the timer afterwards.
Also make sure you also add this to the killed timer (to prevent further issues)
Re: Timer fu**ed up? -
Aira - 07.01.2012
Delete