SA-MP Forums Archive
[FilterScript] Teleporting (to) players - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Teleporting (to) players (/showthread.php?tid=251570)



Teleporting (to) players - Anteino - 27.04.2011

With this filterscript you can teleport to players or teleport them to you, vehicles the players are in are also teleported. The commands require the player to be logged in as an (RCON) admin to work.

..:: How it works ::.

/get [playerid]
With this you teleport the player with [playerid] to yourself
/tele [playerid]
With this you teleport to with [playerid]
..:: The code ::..

pawn Код:
#include <a_samp>
#include "../include/gl_common.inc"

#define FILTERSCRIPT

#define COLOR_WHITE 0xFFFFFFFF

public OnPlayerCommandText(playerid, cmdtext[])
{
    new idx;
    new cmd[256];

    cmd = strtok(cmdtext, idx);

    if(strcmp("/tele", cmd, true) == 0)
    {
     if(IsPlayerAdmin(playerid)) {
            new tmp[256], player, Float:X, Float:Y, Float:Z, carid, seat;
            tmp = strtok(cmdtext, idx);
            player = strval(tmp);
            GetPlayerPos(player, X, Y, Z);
            if(IsPlayerInAnyVehicle(playerid)){
                carid = GetPlayerVehicleID(playerid);
                seat = GetPlayerVehicleSeat(playerid);
                SetVehiclePos(carid, X+1, Y, Z);
                PutPlayerInVehicle(playerid, carid, seat);
                return 1;
            }
            SetPlayerPos(playerid, X+1, Y, Z);
            return 1;
        }
        else{
            SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are not authorized to use this command.");
            return 1;
        }
    }
    if(strcmp("/get", cmd, true) == 0)
    {
     if(IsPlayerAdmin(playerid)) {
            new tmp[256], player, Float:X, Float:Y, Float:Z, carid, seat;
            tmp = strtok(cmdtext, idx);
            player = strval(tmp);
            GetPlayerPos(playerid, X, Y, Z);
            if(IsPlayerInAnyVehicle(player)){
                carid = GetPlayerVehicleID(player);
                seat = GetPlayerVehicleSeat(player);
                SetVehiclePos(carid, X+1, Y, Z);
                PutPlayerInVehicle(player, carid, seat);
                return 1;
            }
            SetPlayerPos(player, X+1, Y, Z);
            return 1;
        }
        else{
            SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are not authorized to use this command.");
            return 1;
        }
    }
    return 0;
}
Enjoy.


Re: Teleporting (to) players - admantis - 27.04.2011

Bad string sizes.. bad system.. bad optimization.. A sscanf2 and zcmd utilization would be good..


Re: Teleporting (to) players - Millionaire - 28.04.2011

Simple and nice