[Help] Teleporting - 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: [Help] Teleporting (
/showthread.php?tid=433528)
[Help] Teleporting -
xXRealLegitXx - 27.04.2013
I have these two commands and it has been very useful for the development for our server:
Код:
CMD:tp(playerid, params[])
{
new targetid;
new target[MAX_PLAYER_NAME];
new Float:x, Float:y, Float:z;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Usage: /tp [id]");
GetPlayerName(targetid, target, sizeof(target));
GetPlayerPos(targetid, x, y, z);
SetPlayerPos(playerid, x, y, z);
SendClientMessage(targetid, COLOR_WHITE, "An admin has teleported to you.");
return 1;
}
and
Код:
CMD:bring(playerid, params[])
{
new targetid;
new target[MAX_PLAYER_NAME];
new Float:x, Float:y, Float:z;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Usage: /bring [id]");
GetPlayerName(targetid, target, sizeof(target));
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(targetid, x, y, z);
SendClientMessage(targetid, COLOR_WHITE, "You have been teleported to an admin by an admin.");
return 1;
}
I want them to both still do the same function, but to take your vehicle. And if it takes your vehicle, it should teleport you about 5 inches away. Is this possible?
Re: [Help] Teleporting -
MattyG - 27.04.2013
Well you'd need the following functions to do that, you should be able to work out how to use them from the wiki pages:
https://sampwiki.blast.hk/wiki/IsPlayerInAnyVehicle
https://sampwiki.blast.hk/wiki/GetPlayerVehicleID
https://sampwiki.blast.hk/wiki/SetVehiclePos
For the offset, you could do something like SetVehiclePos(vehicleid, x, y + 5, z)