Help GetPlayerName
#1

pawn Код:
CMD:goto(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        new pID, string[128], Float:x, Float:y, Float:z, IGRAC1[MAX_PLAYER_NAME];
        GetPlayerName(playerid, IGRAC1, sizeof(IGRAC1));
        if(sscanf(params, "u", pID))return SendClientMessage(playerid, -1, ""HEX_PLAVA"[ERROR]"HEX_BELA" Pravilan sintaks komande: /goto [Ime/ID]");
        if(pID == INVALID_PLAYER_ID)return SendClientMessage(playerid, -1, ""HEX_PLAVA"[ERROR] "HEX_BELA"Igrac nije konektovan ili nije logovan.");
        format(string, sizeof(string), ""HEX_PLAVA"[Info]"HEX_BELA" Teleportovali ste se do igraca %s.", IGRAC1);
        GetPlayerPos(pID, x, y, z);
        SendClientMessage(playerid, -1, string);
        if(IsPlayerInAnyVehicle(playerid))return SetPlayerPos(playerid, x+3, y+3, z+3) && SetVehiclePos(GetPlayerVehicleID(playerid), x+3, y+3, z+3) && PutPlayerInVehicle(playerid, GetPlayerVehicleID(playerid), 0);
        if(IsPlayerInAnyVehicle(pID))return PutPlayerInVehicle(playerid, GetPlayerVehicleID(pID), 1);
        SetPlayerPos(playerid, x, y, z);
    }
    else
    {
        SendClientMessage(playerid, -1, ""HEX_PLAVA"[ERROR] "HEX_BELA"Niste ovlasteni da koristite ovu komandu.");
    }
    return 1;
}
This code is for my goto command it works but when i type /goto 1 (My Friends ID) its says Ti si teleportovan do Danijel_Johnson (My Name but my id is 0).
Reply
#2

The problem is here

pawn Код:
// You code
GetPlayerName( playerid, IGRAC1, sizeof( IGRAC1 ) );

//Should be
GetPlayerName( pID, IGRAC1, sizeof ( IGRAC ) );
I hope this will be works,
Reply
#3

Ohh thanks !
Reply
#4

pID is defined as zero, it's value changes after the sscanf code. GetPlayerName should also go below the sscanf part.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)