new playerName[MAX_PLAYERS][MAX_PLAYER_NAME];
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid, Player_Name[playerid], MAX_PLAYER_NAME);
return 1;
} // Don't mind not reseting it I know just giving an example
stock GetName(playerid)
{
new Nick[MAX_PLAYER_NAME];
GetPlayerName(playerid, Nick, sizeof(Nick));
return Nick;
}
CMD:kick(playerid, params[])
{
new
id,
reason[100];
if (sscanf(params, "rs[100]", id, reason)) return // syntax..
// ...
new
string[128],
ip[16];
GetPlayerIp(id, ip, 16);
format(string, sizeof (string), "You have been kicked by %s. Reason: %s", GetName(playerid), reason);
SendClientMessage(id, -1, string);
format(string, sizeof (string), "You kicked %s. Reason: %s", GetName(id), reason);
SendClientMessage(playerid, -1, string);
format(string, sizeof (string), "%s kicked %s. Reason: %s", GetName(playerid), GetName(id), reason);
SendClientMessageToAll(id, -1, string);
format(string, sizeof (string), "%s kicked %s [IP: %s]. Reason: %s", GetName(playerid), GetName(id), ip, reason);
SendMessageToAdmins(-1, string);
// kick player..
return 1;
}
avoid enumerated arrays because they are not arrays they work, but they don't adhere to the same rules as actual arrays so to save confusion, just use a variable and, if you're doing modules (which you should in 2018 ) use static instead of new to restrict the scope of the variable to that module only then provide access to it via functions |
static Name[MAX_PLAYERS][MAX_PLAYER_NAME + 1]
Better more if you use a anum for player data storage and get his name only once when connecting, it is better this way of course rather than using resources everytime to get a guy's name.
Of course if you want to allow players to change nick in game you will need some editings, but yeah that is |
// OnPlayerDeath(...)
format(string, sizeof string, "%s(%d) killed %s(%d) with a %s.", playerName[killerid], killerid, playerName[playerid], playerid, GetWeaponNameFromID(reason);
new playerName[MAX_PLAYERS][MAX_PLAYER_NAME]; public OnPlayerConnect(playerid) { GetPlayerName(playerid, Player_Name[playerid], MAX_PLAYER_NAME); return 1; } // Don't mind not reseting it I know just giving an example
GetName(playerid) { return playerName[playerid]; }
printf("Hello %s", GetName(playerid));