Need a little help with scripting a function
#1

Well, because of the Object Streamer, when I teleport to an interior I fall down from sky because the objets haven't appear yet, so I wanted to ask you how can I make a function that will "freeze" the player for 2 seconds right after he typed /enter and got into the interior, to make sure he will not fall down from sky.
I would like to understand how to do that, thank you.
Reply
#2

You'll need a timer, and the TogglePlayerControllable.

wiki.sa-mp.com/wiki/SetTimer
wiki.sa-mp.com/wiki/SetTimerEx
wiki.sa-mp.com/wiki/KillTimer
wiki.sa-mp.com/TogglePlayerControllable




Dude, you are lucky because I had nothing to do, and then I did it for you. Here you go:

pawn Код:
#include <a_samp>

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/teleport", cmdtext, true, 0) == 0)
{
SetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
TogglePlayerControllable(playerid, false);
SetTimer("Timer",2000,0);
return 1;
}
return 0;
}

forward Timer(playerid);
public Timer(playerid)
{
TogglePlayerControllable(playerid, true);
return 0;
}
But take a look at it, don't just copy and paste it... Otherwise you won't learn anything!
Reply
#3

Quote:
Originally Posted by еddy
You'll need a timer, and the TogglePlayerControllable.

wiki.sa-mp.com/wiki/SetTimer
wiki.sa-mp.com/wiki/SetTimerEx
wiki.sa-mp.com/wiki/KillTimer
wiki.sa-mp.com/TogglePlayerControllable




Dude, you are lucky because I had nothing to do, and then I did it for you. Here you go:

pawn Код:
#include <a_samp>

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/teleport", cmdtext, true, 0) == 0)
{
SetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
TogglePlayerControllable(playerid, false);
SetTimer("Timer",2000,0);
return 1;
}
return 0;
}

forward Timer(playerid);
public Timer(playerid)
{
TogglePlayerControllable(playerid, true);
return 0;
}
But take a look at it, don't just copy and paste it... Otherwise you won't learn anything!
Thanks Eddy, but I already did it by reading on the webside you sent me, thank you anyway
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)