Freeze timer
#1

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

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
Reply
#3

It works now. Great, thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)