cordinate teleport
#1

Hi please i need help i want to make a simple cmd that you can use to teleport to cordinates like [x y z cords].
can someone help me with this please!!
Reply
#2

STRCMP
pawn Код:
if(strcmp(cmdtext, "/teleport", true) == 0)
{
    SetPlayerPos(playerid, X, Y, Z); //Replace X, Y and Z with your coords.
    return 1;
}
ZCMD
pawn Код:
CMD:teleport(playerid,params[])
{
    SetPlayerPos(playerid, X, Y, Z); //Replace X, Y and Z with your coords.
    return 1;
}
Read this for more information: https://sampwiki.blast.hk/wiki/SetPlayerPos
Reply
#3

pawn Код:
CMD:tp(playerid, params[])
{
    new int, Float: x, Float: y, Float: z;
    if(sscanf(params, "dfff", int, x, y, z))
        return SendClientMessage(playerid, GREY, "SYNTAX: /tp [int] [x] [y] [z]");
       
    SetPlayerPos(playerid, x, y, z);
    SetPlayerInterior(playerid, int);
    return SendClientMessage(playerid, -1, "Teleport successful.");;
}
Added interior value incase you want to teleport to interiors aswell.
Reply
#4

Well that's not a very 'simple' command, not one that newbies would understand straight up.
Reply
#5

If you want to create a teleport with the vehicle support
add this to your teleport command

pawn Код:
if(IsPlayerInAnyVehicle(playerid)) //if player is in vehicle
{
SetPlayerVehiclePos(GetPlayerVehicleID(playerid), x, y, z); //change the x, y, z to your coordinate
SetPlayerVehicleZAngle(GetPlayerVehicleID(playerid), ang); //change the ang to your coordinate
LinkVehicleToInterior(GetPlayerVehicleID(playerid), int);
SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), world);
}
else //if player is onfoot
{
SetPlayerPos(playerid, x, y, z); //change the x, y, z to your coordinate
SetPlayerFacingAngle(playerid, ang); //change the ang to your coordinate
}
Reply
#6

Quote:
Originally Posted by cosbraa
Посмотреть сообщение
pawn Код:
CMD:tp(playerid, params[])
{
    new int, Float: x, Float: y, Float: z;
    if(sscanf(params, "dfff", int, x, y, z))
        return SendClientMessage(playerid, GREY, "SYNTAX: /tp [int] [x] [y] [z]");
       
    SetPlayerPos(playerid, x, y, z);
    SetPlayerInterior(playerid, int);
    return SendClientMessage(playerid, -1, "Teleport successful.");;
}
Added interior value incase you want to teleport to interiors aswell.
hi i got this errors when i compiled

C:\Users\YOUNG MONEY\Desktop\SAMP scripts\1\Newport City Roleplay\gamemodes\EG-RP.pwn(35725) : warning 217: loose indentation
C:\Users\YOUNG MONEY\Desktop\SAMP scripts\1\Newport City Roleplay\gamemodes\EG-RP.pwn(35725) : error 029: invalid expression, assumed zero
C:\Users\YOUNG MONEY\Desktop\SAMP scripts\1\Newport City Roleplay\gamemodes\EG-RP.pwn(35725) : error 017: undefined symbol "cmd_tp"
C:\Users\YOUNG MONEY\Desktop\SAMP scripts\1\Newport City Roleplay\gamemodes\EG-RP.pwn(35725) : error 029: invalid expression, assumed zero
C:\Users\YOUNG MONEY\Desktop\SAMP scripts\1\Newport City Roleplay\gamemodes\EG-RP.pwn(35725) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#7

pawn Код:
CMD:tp(playerid, params[])
{
    new int, Float: x, Float: y, Float: z;
    if(sscanf(params, "dfff", int, x, y, z)) return SendClientMessage(playerid, -1, "SYNTAX: /tp [int] [x] [y] [z]");
    SetPlayerPos(playerid, x, y, z);
    SetPlayerInterior(playerid, int);
    SendClientMessage(playerid, -1, "Teleport successful.");
    return 1;
}
Reply
#8

Quote:
Originally Posted by popystone
Посмотреть сообщение
hi i got this errors when i compiled

C:\Users\YOUNG MONEY\Desktop\SAMP scripts\1\Newport City Roleplay\gamemodes\EG-RP.pwn(35725) : warning 217: loose indentation
C:\Users\YOUNG MONEY\Desktop\SAMP scripts\1\Newport City Roleplay\gamemodes\EG-RP.pwn(35725) : error 029: invalid expression, assumed zero
C:\Users\YOUNG MONEY\Desktop\SAMP scripts\1\Newport City Roleplay\gamemodes\EG-RP.pwn(35725) : error 017: undefined symbol "cmd_tp"
C:\Users\YOUNG MONEY\Desktop\SAMP scripts\1\Newport City Roleplay\gamemodes\EG-RP.pwn(35725) : error 029: invalid expression, assumed zero
C:\Users\YOUNG MONEY\Desktop\SAMP scripts\1\Newport City Roleplay\gamemodes\EG-RP.pwn(35725) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
You forgot to add the ZCMD include, which is a fast command processor.

Download:
Put that in your server folder then into the 'pawno' folder, in the folder called 'includes' where all the .inc files are located.

Now, compile your script.
Reply
#9

pawn Код:
CMD:teleport(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
SetPlayerVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
}
else
{
SetPlayerPos(playerid, x, y, z);
}
return 1;
}
A Simple one this should work
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)