Need a little help with scripting a function - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need a little help with scripting a function (
/showthread.php?tid=85659)
Need a little help with scripting a function -
tomnidi - 08.07.2009
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.
Re: Need a little help with scripting a function -
refshal - 08.07.2009
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!
Re: Need a little help with scripting a function -
tomnidi - 08.07.2009
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