What's the problem with this /get?
#1

pawn Код:
COMMAND:get(playerid,params[]) {
    new
        Float:pos1,
        Float:pos2,
        Float:pos3,
        interior,
        temp[30],
        id,
        name1[30],
        name2[30],
        text[128];
    if(sscanf(params,"s",temp))
        return SendClientMessage(playerid,red,"USAGE: /get [part of name]");
    id = GetPlayerID(temp);
    if(PlayerInfo[playerid][pAdminLevel] >= 3) {
        if(IsPlayerConnected(id)) {
            GetPlayerName(playerid,name1,sizeof(name1));
            GetPlayerName(id,name2,sizeof(name2));
            GetPlayerPos(playerid,pos1,pos2,pos3);
            format(text,sizeof(text),"Administrator \"%s\" has teleported \"%s\" to his / her position.",name1,name2);
            SendClientMessageToAll(medblue,text);
            interior = GetPlayerInterior(playerid);
            SetPlayerPos(id,pos1+2,pos2+2,pos3);
            SetPlayerInterior(id,interior);
        } else {
            return SendClientMessage(playerid,red,"Invalid name.");
        }
    } else {
        return SendClientMessage(playerid,red,"Only lvl3 admins can use this command.");
    }
    return 1;
}
When I do /get [my name..] and it says Invalid name.
Can u help me?

Please correct, not rewrite the code.

P.S.: oh almost forgot:
pawn Код:
stock GetPlayerID(const Name[])
{
    for(new i; i<MAX_PLAYERS; i++)
    {
      if(IsPlayerConnected(i))
      {
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(i, pName, sizeof(pName));
        if(strcmp(Name, pName, true)==0)
        {
          return i;
        }
      }
    }
    return -1;
}
Reply
#2

use "if(sscanf(params,"u",temp))" not "if(sscanf(params,"s",temp))"



EDIT:-

"u" => User name/id (bots and players)
Reply
#3

still Invalid name.
Reply
#4

Use This:
pawn Код:
COMMAND:get(playerid,params[])
{
    new
        Float:X,
        Float:Y,
        Float:Z,
        str[64],
        ID,
        vehicle,
        pName[MAX_PLAYER_NAME],
        pName2[MAX_PLAYER_NAME]
    ;
    if(PlayerInfo[playerid][pAdminLevel] < 3)
        return SendClientMessage(playerid, -1, "Only lvl3 admins can use this command.");
    if(sscanf(params, "u", ID))
        return SendClientMessage(playerid, -1, "USAGE: /get [PlayerID/Name]");
    if(IsPlayerConnected(ID) && ID != INVALID_PLAYER_ID)
    {
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(ID, pName2, MAX_PLAYER_NAME);
        if(IsPlayerInAnyVehicle(ID))
        {
            GetPlayerPos(playerid, X, Y, Z);
            vehicle = GetPlayerVehicleID(ID);
            SetVehiclePos(vehicle, X+2, Y+2, Z);
            PutPlayerInVehicle(ID, vehicle, 0);
            LinkVehicleToInterior(vehicle,GetPlayerInterior(ID));
        }
        else
        {
            GetPlayerPos(playerid, X, Y, Z);
            SetPlayerPos(ID, X+2, Y, Z);
            SetPlayerInterior(playerid,GetPlayerInterior(ID));
        }
        format(str,sizeof(str),"Administrator \"%s\" has teleported \"%s\" to his / her position.",pName, pName2);
        SendClientMessageToAll(-1,str);
    }
    else return SendClientMessage(playerid, -1,"ERROR: Player is not connected or is yourself.");
    return 1;
}
Edit: You can't use this command on Yourself.
Reply
#5

Why can't I use that on myself? I removed ID !== INVALID_ID but still not working.
Reply
#6

Quote:
Originally Posted by Seven_of_Nine
Посмотреть сообщение
Why can't I use that on myself? I removed ID !== INVALID_ID but still not working.
Hmm try this:
pawn Код:
COMMAND:get(playerid,params[])
{
    new
        Float:X,
        Float:Y,
        Float:Z,
        str[64],
        ID,
        vehicle,
        pName[MAX_PLAYER_NAME],
        pName2[MAX_PLAYER_NAME]
    ;
    if(PlayerInfo[playerid][pAdminLevel] < 3)
        return SendClientMessage(playerid, -1, "Only lvl3 admins can use this command.");
    if(sscanf(params, "u", ID))
        return SendClientMessage(playerid, -1, "USAGE: /get [PlayerID/Name]");
    else if(ID == INVALID_PLAYER_ID)
        return SendClientMessage(playerid, -1, "Enter a valid player ID/name!");
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    GetPlayerName(ID, pName2, MAX_PLAYER_NAME);
    if(IsPlayerInAnyVehicle(ID))
    {
        GetPlayerPos(playerid, X, Y, Z);
        vehicle = GetPlayerVehicleID(ID);
        SetVehiclePos(vehicle, X+2, Y+2, Z);
        PutPlayerInVehicle(ID, vehicle, 0);
        LinkVehicleToInterior(vehicle,GetPlayerInterior(ID));
    }
    else
    {
        GetPlayerPos(playerid, X, Y, Z);
        SetPlayerPos(ID, X+2, Y, Z);
        SetPlayerInterior(playerid,GetPlayerInterior(ID));
    }
    format(str,sizeof(str),"Administrator \"%s\" has teleported to \"%s's\" position.",pName, pName2);
    SendClientMessageToAll(-1,str);
    return 1;
}
Edit: What version of sscanf you're using?
Reply
#7

sscanf2
Reply
#8

bump?!
Reply
#9

Quote:
Originally Posted by Rules
Only Bumping after 12 hours is allowed.
Learn rules

Quote:
Originally Posted by sa-mp.com
This forum requires that you wait 120 seconds between posts. Please try again in 1 seconds.
Reply
#10

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
...You dont seem to know a lot.
Don't spam idiot (learn the rules trolololololo) that is not useful information, so try to figure out whats wrong with it instead.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)