SA-MP Forums Archive
Freezing a player to let the mapping load - 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: Freezing a player to let the mapping load (/showthread.php?tid=400341)



Freezing a player to let the mapping load - Jay_Dixon - 18.12.2012

I have this falling threw the floor problem, that i've been trying to fix, and i thought "Hey, why not freeze the player?!"
Wellllllllllllllllllllll sadly that won't work. I have no idea what the hell i'm doing wrong in this one, normally i can figure problems out like this, but not this one :3

So that's what i got so far, as you can see, i set it to where the players not controllable, then it makes him controllable, but for some reason, it won't kick in, can someone tell me how to freeze a player for atleast 2 seconds?

Code:
				    if(PlayerInfo[playerid][pAdmin] >= 9999)//Jay's Special House - Brucie you want one? I'll even make one for Gonzalo too =D
				    {
				        GameTextForPlayer(playerid,"~w~Jay's House",1000,1);
				        SetPlayerInterior(playerid,5);
				        SetPlayerPos(playerid,2476.7161,1796.8595,1541.7156);
						TogglePlayerControllable(playerid,0);
				        SetTimer("StartPaintball",1000,0);
				        TogglePlayerControllable(playerid,1);
				        SetPlayerVirtualWorld(playerid,1337);
				        SetPlayerFacingAngle(playerid,0.0);
				        SetCameraBehindPlayer(playerid);
				        return 1;
					}
					else
					{
					    SendClientMessage(playerid, COLOR_LIGHTRED, "   You do not have permission to enter Jay's Lair of Doom!!");
					    return 1;
					}
				}



Re: Freezing a player to let the mapping load - [KHK]Khalid - 18.12.2012

pawn Code:
TogglePlayerControllable(playerid,1);
Should be placed in an one second timer after you freeze them.


Re: Freezing a player to let the mapping load - Jay_Dixon - 18.12.2012

Quote:
Originally Posted by HellSphinX
View Post
pawn Code:
TogglePlayerControllable(playerid,1);
Should be placed in an one second timer after you freeze them.
I have no experience freezing people like this. Think you can explain a bit more? XD


Re: Freezing a player to let the mapping load - Huxley - 18.12.2012

You should add a timer, for example like this:

pawn Code:
forward InteriorEntered(playerid); // On top of your script, belower than includes and definitions.

// Your script here
if(PlayerInfo[playerid][pAdmin] >= 9999)//Jay's Special House - Brucie you want one? I'll even make one for Gonzalo too =D
{
    GameTextForPlayer(playerid,"~w~Jay's House",1000,1);
    SetPlayerInterior(playerid,5);
    SetPlayerPos(playerid,2476.7161,1796.8595,1541.7156);
    TogglePlayerControllable(playerid,0);
    SetTimer("StartPaintball",1000,0);
    TogglePlayerControllable(playerid,false);
    SetPlayerVirtualWorld(playerid,1337);
    SetPlayerFacingAngle(playerid,0.0);
    SetCameraBehindPlayer(playerid);

    SetTimer("InteriorEntered",2000,0); // The timer here, you shouldn't put the last parameter to 1 because it will repeat the effect which we don't need to happen.
    return 1;
}

public InteriorEntered(playerid) return TogglePlayerControllable(playerid, true); // This is where the effect will take place, after the timer has ended, the effect will take place.
I hope you understand, and you can use the timer I provided because it's really needed after a player entered a mapped interior.


Re: Freezing a player to let the mapping load - iggy1 - 18.12.2012

I take it your using a streamer for your objects? Since you cant fall through the object with CreateObject. So if your using the plugin use this function right before setting the players position:

pawn Code:
Streamer_UpdateEx(playerid, Float:x, Float:y, Float:z, worldid = -1, interiorid = -1)
Use the position, world and interior that you spawn the player at as function parameters. No need to freeze the player.


Re: Freezing a player to let the mapping load - Jay_Dixon - 18.12.2012

Quote:
Originally Posted by Huxley
View Post
You should add a timer, for example like this:

pawn Code:
forward InteriorEntered(playerid); // On top of your script, belower than includes and definitions.

// Your script here
if(PlayerInfo[playerid][pAdmin] >= 9999)//Jay's Special House - Brucie you want one? I'll even make one for Gonzalo too =D
{
    GameTextForPlayer(playerid,"~w~Jay's House",1000,1);
    SetPlayerInterior(playerid,5);
    SetPlayerPos(playerid,2476.7161,1796.8595,1541.7156);
    TogglePlayerControllable(playerid,0);
    SetTimer("StartPaintball",1000,0);
    TogglePlayerControllable(playerid,false);
    SetPlayerVirtualWorld(playerid,1337);
    SetPlayerFacingAngle(playerid,0.0);
    SetCameraBehindPlayer(playerid);

    SetTimer("InteriorEntered",2000,0); // The timer here, you shouldn't put the last parameter to 1 because it will repeat the effect which we don't need to happen.
    return 1;
}

public InteriorEntered(playerid) return TogglePlayerControllable(playerid, true); // This is where the effect will take place, after the timer has ended, the effect will take place.
I hope you understand, and you can use the timer I provided because it's really needed after a player entered a mapped interior.
Works great! Now i can apply that to the rest of my custom interiors too, thanks =3


Re: Freezing a player to let the mapping load - Mike_Peterson - 18.12.2012

Why would you apply that to every custom interior?
As long as this custom interior is not the same as the interior of the entrance (outside interior = 0, inside e.g. = 5)
you can use public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
and place the timer under there.


Re: Freezing a player to let the mapping load - iggy1 - 18.12.2012

Just wondering if you are using the streamer plugin for your objects? You can cut the timer out if so. Not just that, but it will look smoother/faster for the player. I've used this method myself and it works, it loads the object before moving the player.

pawn Code:
if(PlayerInfo[playerid][pAdmin] >= 9999)//Jay's Special House - Brucie you want one? I'll even make one for Gonzalo too =D
{
    GameTextForPlayer(playerid,"~w~Jay's House",1000,1);
    Streamer_UpdateEx(playerid, 2476.7161,1796.8595,1541.7156, 1337, 5);//apply this line before setting the position to pre-stream the objects
    SetPlayerPos(playerid,2476.7161,1796.8595,1541.7156);
    SetPlayerInterior(playerid,5);
    SetPlayerVirtualWorld(playerid,1337);
    TogglePlayerControllable(playerid,0);
    SetTimer("StartPaintball",1000,0);
    SetPlayerFacingAngle(playerid,0.0);
    SetCameraBehindPlayer(playerid);
    return 1;
}