Teleport
#1

how can I create a command that teleports a player to me ? I can't start it.
Reply
#2

here you go

pawn Код:
if(strcmp(cmd, "/gethere", true) == 0)     {
    if(PlayerInfo[playerid][Level] >= 3) {
        new player1, tmp[256];
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))    {
           SendClientMessage(playerid, red, "USAGE: /gethere [playerid]");
        return 1;    }
        player1 = strval(tmp);

         if(IsPlayerConnected(player1))        {
            CMDMessageToAdmins(playerid,"GETHERE");
            new Float:x, Float:y, Float:z;    GetPlayerPos(playerid,x,y,z); SetPlayerInterior(player1,GetPlayerInterior(playerid));
            SetPlayerVirtualWorld(player1,GetPlayerVirtualWorld(playerid));
            if(GetPlayerState(player1) == 2)    {
                new VehicleID = GetPlayerVehicleID(player1);
                SetVehiclePos(VehicleID,x+3,y,z);   LinkVehicleToInterior(VehicleID,GetPlayerInterior(playerid));
                SetVehicleVirtualWorld(GetPlayerVehicleID(player1),GetPlayerVirtualWorld(playerid));
            } else    {
                SetPlayerPos(player1,x+2,y,z);        }
            GetPlayerName(player1, playername, sizeof(playername));        GetPlayerName(playerid, adminname, sizeof(adminname));
            format(string,256,"You have been teleported to Administrator %s's location",adminname);    SendClientMessage(player1,blue,string);
            format(string,256,"You have teleported %s to your location", playername); SendClientMessage(playerid,blue,string);
               return 1;
        } else {
         SendClientMessage(playerid, red, "Player is not connected");
         return 1;    }
    } else     {
    SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");   }
     return 1;    }
Reply
#3

at this moment im not in the mood to script but did u even ever thought about the other? this is just a copy/paste from ur script with functions he doesnt has... (he can modify it though)
Reply
#4

Yupp. Rafa, that command won't work for him.
Reply
#5

ehh well idk what to do other xD
Reply
#6

Try that out, if it works it will work in every player, just add the admins checker line yourself if u want
DON'T BE LAZY!

pawn Код:
if(strcmp(cmd, "/gethere", true) == 0)    
 {
        new player1, tmp[256];
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))  
        {
             SendClientMessage(playerid, red, "USAGE: /gethere [playerid]");
             return 1;    
        }
        player1 = strval(tmp);
        if(IsPlayerConnected(player1))      
        {
            new Float:x, Float:y, Float:z;  
            GetPlayerPos(playerid,x,y,z);
            SetPlayerInterior(player1,GetPlayerInterior(playerid));
            SetPlayerVirtualWorld(player1,GetPlayerVirtualWorld(playerid));
            if(GetPlayerState(player1) == 2)    
            {
                new VehicleID = GetPlayerVehicleID(player1);
                SetVehiclePos(VehicleID,x+3,y,z);   LinkVehicleToInterior(VehicleID,GetPlayerInterior(playerid));
                SetVehicleVirtualWorld(GetPlayerVehicleID(player1),GetPlayerVirtualWorld(playerid));
            }
            else    
            {
                SetPlayerPos(player1,x+2,y,z);        
            }
               return 1;
        }
       else
        {
         SendClientMessage(playerid, red, "Player is not connected");
         return 1;    
        }
        return 1;
    }
Reply
#7

Quote:
Originally Posted by Hamza'
Посмотреть сообщение
Try that out, if it works it will work in every player, just add the admins checker line yourself if u want
DON'T BE LAZY!

pawn Код:
Some long code that is using strtok, and 256 size arrays to get a player's ID.
I wouldn't recommend using that, a 256 cell array is useless as the command is searching for a player's ID. I wouldn't think someone's playerid will be 256 characters long, am I wrong?

pawn Код:
if(!strcmp(cmdtext, "/get", true))
{
     if(strlen(cmdtext[4]))
         return SendClientMessage(playerid, 0xFFFFFFF, ">> /get <id>");
     
     if(!IsPlayerConnected(strval(cmdtext[4]))
         return SendClientMessage(playerid, 0xFFFFFFF, "The playerid is non-existant.");

     new
             Float:PlayerPos[3]
     ;
 
     GetPlayerPos(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
     SetPlayerPos(strval(cmdtext[4]), PlayerPos[0], PlayerPos[1], PlayerPos[2]+3);
     SetPlayerInterior(strval(cmdtext[4]), GetPlayerInterior(playerid));
     SetPlayerVirtualWorld(strval(cmdtext[4]), GetPlayerVirtualWorld(playerid));
}
This is better.
Reply
#8

And this is imo even better.

pawn Код:
if( !strcmp( cmdtext, "/get", true ))
    {
        new iPlayer;

        if( cmdtext[ 4 ] == '\0' || ( cmdtext[ 4 ] == '\1' && cmdtext[ 5 ] == '\0'  ))
            return SendClientMessage(playerid, 0xFFFFFFF, ">> /get <id>");
        iPlayer = strval( cmdtext[ 5 ] );
        if( !IsPlayerConnected( iPlayer ))
            return SendClientMessage(playerid, 0xFFFFFFF, "The playerid is non-existant.");

        new
            Float:fX,
            Float:fY,
            Float:fZ;

        new
            iInt = GetPlayerInterior( playerid ),
            iVehicle = GetPlayerVehicleID( iPlayer );
        GetPlayerPos( playerid, fX, fY, fZ );

        if( iVehicle )
        {
            SetVehiclePos( iVehicle, fX + 1.0, fY, fZ + 0.5 );
            LinkVehicleToInterior( iVehicle, iInt );
        }
        else
        {
            SetPlayerPos( iPlayer, fX, fY, fZ + 0.5 );
            SetPlayerInterior( iPlayer, iInt );
        }
        SetPlayerVirtualWorld( iPlayer, GetPlayerVirtualWorld( playerid ));
        return true;
    }
Reply
#9

Quote:
Originally Posted by Hamza'
Посмотреть сообщение
Try that out, if it works it will work in every player, just add the admins checker line yourself if u want
DON'T BE LAZY!

pawn Код:
if(strcmp(cmd, "/gethere", true) == 0)    
 {
        new player1, tmp[256];
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))  
        {
             SendClientMessage(playerid, red, "USAGE: /gethere [playerid]");
             return 1;    
        }
        player1 = strval(tmp);
        if(IsPlayerConnected(player1))      
        {
            new Float:x, Float:y, Float:z;  
            GetPlayerPos(playerid,x,y,z);
            SetPlayerInterior(player1,GetPlayerInterior(playerid));
            SetPlayerVirtualWorld(player1,GetPlayerVirtualWorld(playerid));
            if(GetPlayerState(player1) == 2)    
            {
                new VehicleID = GetPlayerVehicleID(player1);
                SetVehiclePos(VehicleID,x+3,y,z);   LinkVehicleToInterior(VehicleID,GetPlayerInterior(playerid));
                SetVehicleVirtualWorld(GetPlayerVehicleID(player1),GetPlayerVirtualWorld(playerid));
            }
            else    
            {
                SetPlayerPos(player1,x+2,y,z);        
            }
               return 1;
        }
       else
        {
         SendClientMessage(playerid, red, "Player is not connected");
         return 1;    
        }
        return 1;
    }
warning
PHP код:
local variable "tmp" shadows a variable at a preceding level 
Reply
#10

Tried my code?

EDIT: There were some errors/warnings in my code, but fixed.
Try it - it should work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)