Problem with my alarm command
#1

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?
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)