SA-MP Forums Archive
help teleport player - 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 teleport player (/showthread.php?tid=484355)



help teleport player - 26_RUSSS - 30.12.2013

help write the code to teleport all to yourself please


Re: help teleport player - Vykintas - 30.12.2013

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/tp", cmdtext, true, 2) == 0)
{
new Player, Float: MP[3];
GetPlayerPos(playerid,MP[0],MP[1],MP[2]);
for(Player=0;Player<MAX_PLAYERS,Player++)
{
if(Player!=playerid)
{
SetPlayerPos(Player,MP[0],MP[1]+1,MP[2]);
}
}
return 1;
}
return 0;
}


Re: help teleport player - Wan - 30.12.2013

This is going to teleport everyone on the server to Your position, virtual world and interior:

pawn Код:
new Interior[MAX_PLAYERS];
new VirtualWorld[MAX_PLAYERS];

CMD:getall(playerid, params[])
{
if(IsPlayerAdmin(playerid)) // Admins only
{
new Float:X, Float:Y, Float:Z;

Interior[playerid] = GetPlayerInterior(playerid);
VirtualWorld[playerid] = GetPlayerVirtualWorld(playerid);

GetPlayerPos(playerid, X, Y, Z);

for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SetPlayerPos(i, X, Y, Z);
SetPlayerInterior(i,Interior[playerid]);
SetPlayerVirtualWorld(i,VirtualWorld[playerid]);

SendClientMessage(playerid, 0x00ADFFFF, "You've teleported everyone to Your position!");
// 0x00ADFFFF {00ADFF} = aqua blue colour
}
}
}
if(!IsPlayerAdmin(playerid)) // Not Admin
{
SendClientMessage(playerid, 0xE6000000, "You're not authorized to use this command!");
// 0xE6000000 {E60000} = red colour
}
return 1;
}

// Wan



Re: help teleport player - Mattakil - 30.12.2013

pawn Код:
CMD:getall(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 0; //have to be logged into rcon
    new Float:X, Float:Y, Float:Z; // define the X. Y, Z which are used to store floats.
    GetPlayerPos(playerid, X, Y, Z); //get the position of the admin
    for(new i = 0; i <MAX_PLAYERS; i++) //we do a loop to go through every playerid
    {
        if(IsPlayerConnected(i)) //only perform if the player is connected
        {
            SetPlayerPos(i, X, Y, Z);//set the player's position to the admin
            SendClientMessage(i, -1, "Teleported to admin."); //send a message to everyone telling them they've been teleported
        }
    }
}