SA-MP Forums Archive
Get other player name - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Get other player name (/showthread.php?tid=351321)



Get other player name - MechaTech - 15.06.2012

I don't know how te get the player's name who offered a weapon list.
Example:
Someone uses /sellgun (id) to someone, he will get a message: %s offered a weapon list to you to accept use /buygun.
He will accept and types /buygun. But now if he accept the player who offered him the weapon list will get a message like: %s accepted your offer and is looking through your weapon list.
So how can i do that?


Re: Get other player name - Face9000 - 15.06.2012

pawn Код:
new tname[MAX_PLAYER_NAME]; // Who has been offered
new pname[MAX_PLAYER_NAME]; // Who offer
GetPlayerName(playerid,pname,sizeof(pname)); //Name of who offer weps
GetPlayerName(Target,tname,sizeof(tname)); // Name of who has been offered



Re: Get other player name - MechaTech - 15.06.2012

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
pawn Код:
new tname[MAX_PLAYER_NAME]; // Who has been offered
new pname[MAX_PLAYER_NAME]; // Who offer
GetPlayerName(playerid,pname,sizeof(pname)); //Name of who offer weps
GetPlayerName(Target,tname,sizeof(tname)); // Name of who has been offered
But how do he knows what the player name is its in 2 command i forgot to mention that here:
This is the /sellgun command:
pawn Код:
CMD:sellgun(playerid,params[])
{
    new pstring[128], tstring[128], Target, pname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME];
    if(sscanf(params, "u",Target)) return SendClientMessage(playerid, COLOR_RED,"Usage: /sellgun (id)");
    else if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED,"That player isn't connected.");
    else {
    GetPlayerName(playerid ,pname, MAX_PLAYER_NAME);
    GetPlayerName(playerid ,tname, MAX_PLAYER_NAME);
    format(pstring,sizeof(pstring),"%s has offered you to buy some weapons. Use /buygun if you want to buy.", pname);
    SendClientMessageToAll(COLOR_GREEN, pstring);
    format(tstring,sizeof(tstring),"You offered %s to buy your weapons. Wait if he accepts.", tname);
    SendClientMessageToAll(COLOR_GREEN, tstring);
    buygun[Target] = 1;
    SetTimerEx("buygunt", BUY_GUN, false, "i", playerid);
    }
    return 1;
}
And te /buygun command:

pawn Код:
CMD:buygun(playerid,params[])
{
    if(buygun[playerid] == 1)
    {
        SendClientMessage(playerid, COLOR_GREEN,"You are looking through %s's his weapon list.");
        ShowPlayerDialog(playerid, DIALOG_WEAPONS1, DIALOG_STYLE_LIST, "Weapons List", "Combat Shotgun{FF0000} [4000$] \n{FFFFFF}MP5{FF0000} [3000$]\n{FFFFFF}AK47{FF0000} [4000$]\n{FFFFFF}Shotgun{FF0000}[2000$]\n{FFFFFF}Armour {FF0000}[1000$]", "Buy", "Cancel");
    }
    return 1;
}
How does /buygun command knows the weapon dealers name?


Re: Get other player name - Face9000 - 15.06.2012

Use just

pawn Код:
new pname[MAX_PLAYER_NAME]; // Who offer
GetPlayerName(playerid,pname,sizeof(pname));
It will work.Or you've to save the name in a variable.