Problem with my alarm command - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with my alarm command (
/showthread.php?tid=124019)
Problem with my alarm command -
Torran - 28.01.2010
pawn Код:
dcmd_alarm(playerid, params[])
{
#pragma unused params
if(Alarm[playerid] == 0)
{
SendClientMessage(playerid, RED, "Alarm Sounded");
Alarm1 = SetTimerEx("IPIAA", 500, 1, "i", playerid);
Alarm[playerid] = 1;
}
else if(Alarm[playerid] == 1)
{
SendClientMessage(playerid, RED, "Alarm Stopped");
for(new i; i<GetMaxPlayers(); i++) PlayerPlaySound(i, 1134, 0.0, 0.0, 0.0);
KillTimer(Alarm1);
}
return 1;
}
If i type /alarm, It starts the timer and plays the sound, And says, Alarm Sounded,
If i type /alarm again, It kills the timer and plays a wash sound and says, Alarm Stopped, ( like i wanted it to )
But if i type /alarm again, It plays a wash sound and says, Alarm stopped, But it should start the alarm again,
Why is it doing this?
Re: Problem with my alarm command -
Moglizorz. - 28.01.2010
pawn Код:
dcmd_alarm(playerid, params[])
{
#pragma unused params
if(Alarm[playerid] == 0)
{
SendClientMessage(playerid, RED, "Alarm Sounded");
Alarm1 = SetTimerEx("IPIAA", 500, 1, "i", playerid);
Alarm[playerid] = 1;
}
else if(Alarm[playerid] == 1)
{
SendClientMessage(playerid, RED, "Alarm Stopped");
for(new i; i<GetMaxPlayers(); i++) PlayerPlaySound(i, 1134, 0.0, 0.0, 0.0);
KillTimer(Alarm1);
Alarm[playerid] = 0;
}
return 1;
}
Not tested, hope it works.