SA-MP Forums Archive
Getting a 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: Getting a other player name (/showthread.php?tid=294571)



Getting a other player name - BloodGuy - 02.11.2011

How can i get that?


I have now this;

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Random = random(8001);
    killtimer1 = SetTimerEx("killtimer2",35000,0,"d",playerid);
    new pname[24];
    new string[130];
   	GivePlayerMoney(playerid,Random);
   	GetPlayerName(playerid, pname, sizeof(pname));
   	format(string, sizeof(string), "[KILL] "white"%s "green"Is killed by "white"%s. "red"Cash reward: %d", pname, killerid, Random);
   	SendClientMessageToAll(COLOR_RED, string);
    return 1;
}
But how can i get with a code the name from the other player that killed the guy?


Re: Getting a other player name - SmiT - 02.11.2011

Well, just declare a variable with a MAX_PLAYER_NAME cell, get the killerid name and store it in the variable:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new Random = random(8001);
    killtimer1 = SetTimerEx("killtimer2",35000,0,"d",playerid);
    new pname[24];
    new string[130];
    new killername[ MAX_PLAYER_NAME ]; // New
    GivePlayerMoney(playerid,Random);
    GetPlayerName(playerid, pname, sizeof(pname));
    GetPlayerName( killerid, killername, MAX_PLAYER_NAME ); // New
    format(string, sizeof(string), "[KILL] "white"%s "green"Is killed by "white"%s. "red"Cash reward: %d", pname, killername, Random); // killerid to killername
    SendClientMessageToAll(COLOR_RED, string);
    return 1;
}



Re: Getting a other player name - BloodGuy - 02.11.2011

Mm, it repeats the name ;O? I get 2 times the name of the guy that is killed...