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: Timers (
/showthread.php?tid=288023)
Timers -
Super_Panda - 05.10.2011
Hey this is my code:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(Eventomotos[playerid] == 1)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetTimer("Paro3",1000,true);
TogglePlayerControllable(playerid,0);
SetTimer("Paro",10000,true);
new string[124];
format( string, sizeof(string), "~g~ fuera! ");
GameTextForAll( string, 5000, 3 );
TogglePlayerControllable(playerid,0);
}
}
return 1;
}
I want that when the player gets in the car, then wait 1 second, so when 1 second passes, toggleplayercontrollable = 0 (Freeze) Just for 10 seconds, then after 10 seconds gametextforall "Fuera" and unfreeze the player.
Re: Timers -
brett7 - 05.10.2011
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(Eventomotos[playerid] == 1)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetTimer("Paro3",1000,true);
TogglePlayerControllable(playerid,0);
SetTimer("Paro",10000,true);
new string[124];
format( string, sizeof(string), "~g~ fuera! ");
GameTextForAll( string, 5000, 3 );
TogglePlayerControllable(playerid,0);
SetTimerEx("timer", 10000, false, "i", playerid); //create timer here
}
}
return 1;
}
pawn Код:
public timer(playerid)
{
new string[124];
format( string, sizeof(string), "~g~ fuera! ");
GameTextForAll( string, 5000, 3 );
TogglePlayerControllable(playerid,TRUE);
return 1;
}
Re: Timers -
Backwardsman97 - 06.10.2011
That would be setting the timer 500 times.
Re: Timers -
Super_Panda - 06.10.2011
How to fix it then?
Re: Timers -
Backwardsman97 - 06.10.2011
Try this.
pawn Код:
forward pFreeze(playerid);
forward pUnFreeze(playerid);
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(Eventomotos[playerid] == 1)
{
if(newstate == PLAYER_STATE_DRIVER)
{
SetTimerEx("pFreeze",1000,false,"d",playerid);
return 1;
}
}
return 1;
}
public pFreeze(playerid)
{
TogglePlayerControllable(playerid,0);
SetTimerEx("pUnFreeze",10000,false,"d",playerid);
return 1;
}
public pUnFreeze(playerid)
{
TogglePlayerControllable(playerid,1);
GameTextForAll("~g~ Fuera! ",4000,4);
return 1;
}