[Help] Teleports with press TAB system - 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: [Help] Teleports with press TAB system (
/showthread.php?tid=85623)
[Help] Teleports with press TAB system -
Cr0ssFir3 - 08.07.2009
Hi, im trying to make a Press TAB enter system.
Like: You see some icons and they say "Press TAB" you press TAB and they teleport somewhere.
I already have the icons in place but i dont known how to edit this command, help me out pls gods of scripting:
pawn Код:
//---------------This is my pickups text(working without problems------
public OnPlayerPickupPickup(playerid, pickupid)
{
if (pickupid == entradatorre)
{
GameTextForPlayer(playerid, "~w~Carega TAB", 50000, 1);
}
else if (pickupid == saidatorre)
{
GameTextForPlayer(playerid, "~w~Carrega TAB", 50000, 1);
}
return 1;
}
//-------------------------------------------------------------------
//-----------This is what i need to change, to make players get teleported if they press TAB on that cords----
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys & KEY_ACTION)
{
SetPlayerPos(playerid,1570.6917,-1380.5925,326.2183);
}
else if (newkeys & KEY_ACTION)
{
SetPlayerPos(playerid,1590.8424,-1350.7782,16.4844);
}
return 1;
}
Re: [Help] Teleports with press TAB system -
-Sneaky- - 08.07.2009
You can use IsPlayerInRange:
pawn Код:
stock IsPlayerInRange(playerid, Float:X, Float:Y, Float:Z, Float:Range, Float:ZRange=4.0 )
{
new Float:pX,Float:pY,Float:pZ;
GetPlayerPos( playerid, pX, pY, pZ );
if ( floatsqroot( floatpower( floatabs( floatsub( X, pX ) ),2 ) + floatpower ( floatabs (floatsub( Y, pY ) ),2 ) ) < Range && ( pZ < Z + ZRange ) && ( pZ > Z - ZRange ) )
return 1;
else
return 0;
}
>
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys & KEY_ACTION && IsPlayerInRange(playerid, x, y, z, 5.0)) // replace, x, y, z with the coordinates of that pickup called entradatorre
{
SetPlayerPos(playerid,1570.6917,-1380.5925,326.2183);
}
else if (newkeys & KEY_ACTION && IsPlayerInRange(playerid, x, y, z, 5.0)) // replace, x, y, z with the coordinates of that pickup called saidatorre
{
SetPlayerPos(playerid,1590.8424,-1350.7782,16.4844);
}
return 1;
}
Re: [Help] Teleports with press TAB system -
Cr0ssFir3 - 08.07.2009

God save Sneaky!