Freeze timer - 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: Freeze timer (
/showthread.php?tid=369102)
Freeze timer -
Shredmaster - 15.08.2012
Hi.
Today I was scripting a house (entering/exiting interior, entering/exiting balcony...).
I had ad little problem with exit/enter. When you enter/exit house, sometimes objects don't load in time so you fall through ground...
I put a little timer which freezes you when you type /enter, and unfreezes you after 1 second.
Here is a part of the code:
Код:
forward unfreeze(playerid);
public unfreeze(playerid)
{
TogglePlayerControllable(playerid, 1);
}
CMD:enter(playerid, params[])
{
TogglePlayerControllable(playerid, 0);
SetPlayerPos(playerid,491.1090,1398.9766,1080.2578);
etPlayerInterior(playerid, 2);
SetTimer("unfreeze", 1000, false);
SetPlayerFacingAngle( playerid, 0 );
return 1;
}
The problem is that this worked only for the first player to type /enter. All other players stay frozen.
Please help me to fix this problem, I am a beginner at this.
Re: Freeze timer -
Kindred - 15.08.2012
You are using SetTimer for a timer that has a parameter, therefore you MUST use SetTimerEx. Use this code:
pawn Код:
forward unfreeze(playerid);
public unfreeze(playerid)
{
TogglePlayerControllable(playerid, 1);
}
CMD:enter(playerid, params[])
{
TogglePlayerControllable(playerid, 0);
SetPlayerPos(playerid,491.1090,1398.9766,1080.2578);
SetPlayerInterior(playerid, 2);
SetTimerEx("unfreeze", 1000, false, "i", playerid);
SetPlayerFacingAngle(playerid, 0);
return 1;
}
This should work
Re: Freeze timer -
Shredmaster - 15.08.2012
It works now. Great, thank you!