/get Help!
#1

I created a /Get command to teleport a player to my location but it says he is not online and teleports myself to my location? O.o


pawn Код:
CMD:get(playerid, params[])
{
 new OtherPlayer, Float:x, Float:y, Float:z, PortMsg[128], IntID, WorldID, Name[24];
 if (sscanf(params, "u", OtherPlayer)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/get [id]\"");
 if (IsPlayerConnected(OtherPlayer))
 GetPlayerName(OtherPlayer, Name, sizeof(Name));
 GetPlayerPos(playerid, x, y, z);
 IntID = GetPlayerInterior(playerid);
 WorldID = GetPlayerVirtualWorld(playerid);
 SetPlayerVirtualWorld(OtherPlayer, WorldID);
 SetPlayerInterior(OtherPlayer, IntID);
 SetPlayerPos(OtherPlayer, x, y, z + 3.0);
 format(PortMsg, 128, "|-You teleported %s to your location-|", Name);
 SendClientMessage(playerid, COLOR_RED, PortMsg);
 }
 else
 SendClientMessage(playerid, COLOR_RED, "{FF0000}Error: {FFFFFF}That player is not online");
 return 1;
}
I'm still new into this..
Reply
#2

Why use IsPlayerConnected?
If you can do if(OtherPlayer == INVALID_PLAYER_ID)

pawn Код:
CMD:get(playerid, params[])
{
    new OtherPlayer, Float:x, Float:y, Float:z, PortMsg[128], IntID, WorldID, Name[24];
    if (sscanf(params, "u", OtherPlayer)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/get [id]\"");
    if (OtherPlayer == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "{FF0000}Error: {FFFFFF}That player is not online");
    GetPlayerName(OtherPlayer, Name, sizeof(Name));
    GetPlayerPos(playerid, x, y, z);
    IntID = GetPlayerInterior(playerid);
    WorldID = GetPlayerVirtualWorld(playerid);
    SetPlayerVirtualWorld(OtherPlayer, WorldID);
    SetPlayerInterior(OtherPlayer, IntID);
    SetPlayerPos(OtherPlayer, x, y, z + 3.0);
    format(PortMsg, 128, "|-You teleported %s to your location-|", Name);
    SendClientMessage(playerid, COLOR_RED, PortMsg);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)