Timer Problem (Y_Timers) - 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 Problem (Y_Timers) (
/showthread.php?tid=467486)
Timer Problem (Y_Timers) - Patrick - 03.10.2013
pawn Code:
task GlobalTimer[1000]()
{
new
string[ 128]
;
foreach(Player, i)
{
if(pCuffTime[i] >= 1)
{
pCuffTime[i] --;
printf("%i", pCuffTime[i]);
}
else if(pCuffTime[i] == 1)
{
format(string, sizeof(string), "[SERVER]"COL_WHITE": %s(%d) Has been uncuffed by our System, reason: Anti Abuse", PlayerName(i), i);
SendClientMessageToAll(COLOR_LIGHTYELLOW, string);
TogglePlayerControllable(i, 1);
IsPlayerCuffed[i] = false;
pCuffTime[i] = 0;
SetPlayerSpecialAction(i, SPECIAL_ACTION_NONE);
print("[pCuffTime]: pCuffTime has been executed, the player has been released");
}
}
return 1;
}
The timer counts down properly, but for some reason when the timer variable reaches to 1 it should release the player but it doesn't, I've debug alot of times as you can see on the code to check if my code is right. the debug shows perfect
Debug Information
pawn Code:
[16:24:56] 19
[16:24:58] 18
[16:24:59] 17
[16:25:00] 16
[16:25:01] 15
[16:25:02] 14
[16:25:03] 13
[16:25:04] 12
[16:25:06] 11
[16:25:07] 10
[16:25:08] 9
[16:25:09] 8
[16:25:10] 7
[16:25:11] 6
[16:25:12] 5
[16:25:13] 4
[16:25:14] 3
[16:25:16] 2
[16:25:17] 1
[16:25:18] 0
The code should work but it doesn't.
Re: Timer Problem (Y_Timers) -
Dragonsaurus - 03.10.2013
Change this:
to:
Edit: If you want to know, when the first statement (Which contains "if") is true, and the others contain "else if", they will automatically be skipped. The ">=" was actually making the first statement true, so even if it was 1, the second part would get skipped. Hope I was clear.
Re: Timer Problem (Y_Timers) - Patrick - 03.10.2013
Quote:
Originally Posted by Dragonsaurus
Change this: to:
Edit: If you want to know, when the first statement (Which contains "if") is true, and the others contain "else if", they will automatically be skipped. The ">=" was actually making the first statement true, so even if it was 1, the second part gets skipped. Hope I was clear.
|
Thanks. Because I used this method before using
SetTimer and it worked properly.
Re: Timer Problem (Y_Timers) -
Jefff - 03.10.2013
You can use that
pawn Code:
task GlobalTimer[1000]()
{
new
string[ 128 ]
;
foreach(Player, i)
{
if(pCuffTime[i] < 1) continue;
if(--pCuffTime[i] < 1)
{
format(string, sizeof(string), "[SERVER]"COL_WHITE": %s(%d) Has been uncuffed by our System, reason: Anti Abuse", PlayerName(i), i);
SendClientMessageToAll(COLOR_LIGHTYELLOW, string);
TogglePlayerControllable(i, 1);
IsPlayerCuffed[i] = false;
pCuffTime[i] = 0;
SetPlayerSpecialAction(i, SPECIAL_ACTION_NONE);
print("[pCuffTime]: pCuffTime has been executed, the player has been released");
}
}
return 1;
}