How can i fix the timer problem? -
Moustafa - 26.07.2009
Hey, i have bout 12 or less/more timers, i want to know how to fix it so it wont SPAM..
here are the timers:
pawn Код:
public liftup1(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 1 ... ");
SetTimer("liftup2", 2500, 1);
return 1;
}
public liftup2(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 2 ... ");
SetTimer("liftup3", 2500, 1);
return 1;
}
public liftup3(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 3 ... ");
SetTimer("liftup4", 2500, 1);
return 1;
}
public liftup4(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 4 ... ");
SetTimer("liftup", 2500, 1);
return 1;
}
public liftup(playerid)
{
elevused[playerid] = 1;
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Roof ... ");
SendClientMessage(playerid, 0xFF8080FF, " Elevator doors will close in 5 seconds, please type /exit to get out ! ");
SetTimer("liftdown", 5000, 1);
return 1;
}
public liftdown(playerid)
{
elevused[playerid] = 0;
SendClientMessage(playerid, 0xFF0000FF, " Elevator doors are now closed. ");
SetTimer("liftdown1", 2500, 1);
return 1;
}
public liftdown1(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 4 ... ");
SetTimer("liftdown2", 2500, 1);
return 1;
}
public liftdown2(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 3 ... ");
SetTimer("liftdown3", 2500, 1);
return 1;
}
public liftdown3(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 2 ... ");
SetTimer("liftdown4", 2500, 1);
return 1;
}
public liftdown4(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 1 / Basement ... ");
elevused[playerid] = 1;
SendClientMessage(playerid, 0xFF0000FF, " Elevator doors are now opened, please type /exit to get out, or else type /roof to go up again ");
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == liftupp)
{
GameTextForPlayer(playerid, "Hospital's Elevator ~n~ To enter the elevator type /enter ", 3000, 5);
SetTimer("liftupdelay", 1000, 0);
}
return 1;
}
I hope you can help me
Re: How can i fix the timer problem? -
Correlli - 26.07.2009
I see you're repeating them by using 1, use 0 if you don't want to repeat them.
Re: How can i fix the timer problem? -
Moustafa - 26.07.2009
Ooooooooooh thats why! okay thanks
Re: How can i fix the timer problem? -
Moustafa - 26.07.2009
After testing it myself, also after editing 1 to 0, it is still Spamming it continuously
Re: How can i fix the timer problem? -
member - 26.07.2009
You need to use SetTimerEx not SetTimer if you wish to use the "playerid" correctly and also turn off the repeating parameter.
https://sampwiki.blast.hk/wiki/SetTimerEx
Try this:
pawn Код:
public liftup1(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 1 ... ");
SetTimerEx("liftup2", 2500, false, "d", playerid);
return 1;
}
public liftup2(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 2 ... ");
SetTimerEx("liftup3", 2500, false, "d", playerid);
return 1;
}
public liftup3(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 3 ... ");
SetTimerEx("liftup4", 2500, false, "d", playerid);
return 1;
}
public liftup4(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 4 ... ");
SetTimerEx("liftup", 2500, false, "d", playerid);
return 1;
}
public liftup(playerid)
{
elevused[playerid] = 1;
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Roof ... ");
SendClientMessage(playerid, 0xFF8080FF, " Elevator doors will close in 5 seconds, please type /exit to get out ! ");
SetTimerEx("liftdown", 5000, false, "d", playerid);
return 1;
}
public liftdown(playerid)
{
elevused[playerid] = 0;
SendClientMessage(playerid, 0xFF0000FF, " Elevator doors are now closed. ");
SetTimerEx("liftdown1", 2500, false, "d", playerid);
return 1;
}
public liftdown1(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 4 ... ");
SetTimerEx("liftdown2", 2500, false, "d", playerid);
return 1;
}
public liftdown2(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 3 ... ");
SetTimerEx("liftdown3", 2500, false, "d", playerid);
return 1;
}
public liftdown3(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 2 ... ");
SetTimerEx("liftdown4", 2500, false, "d", playerid);
return 1;
}
public liftdown4(playerid)
{
SendClientMessage(playerid, 0xFF8080FF, " Elevator: Floor 1 / Basement ... ");
elevused[playerid] = 1;
SendClientMessage(playerid, 0xFF0000FF, " Elevator doors are now opened, please type /exit to get out, or else type /roof to go up again ");
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == liftupp)
{
GameTextForPlayer(playerid, "Hospital's Elevator ~n~ To enter the elevator type /enter ", 3000, 5);
SetTimerEx("liftupdelay", 1000, false, "d", playerid);
}
return 1;
}
You can kill the timer if you want to be on the safe side.