Well either that, or you could place them at the begining of your script.
I use PlayerName[playerid] so i don't need to use GetPlayerName and don't need those variables.
pawn Код:
new PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME]; // At top of script.
GetPlayerName(playerid, PlayerName[playerid], MAX_PLAYER_NAME); // Under OnPlayerConnect.
Example:
pawn Код:
cmd(sethp, playerid, params[])
{
new string[128];
if(IsPlayerConnectedAndLoggedIn(playerid))
{
if(PlayerInfo[playerid][pAdmin] > 0)
{
new player; new health;
if(sscanf(params, "ud",player,health))
{
SendClientMessage(playerid, COLOR_HELP, "USAGE: /sethp [ID/DioImena] [0-100]");
return 1;
}
if(health < 0 || health > 100)
{
SendClientMessage(player,COLOR_INFO,"ERROR: You can't set health below 0 or above 100.");
PlayerPlaySound(player, 1055, 0.0, 0.0, 0.0);
return 1;
}
if(IsPlayerConnectedAndLoggedIn(player))
{
if(player != INVALID_PLAYER_ID)
{
SetPlayerHealth(player,health);
format(string, sizeof(string), "AdmWarn: Administrator %s set health of %s to %d.",PlayerName[playerid],PlayerName[player],health);
SendAdminMessage(COLOR_RED,string);
}
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "ERROR: Choosed player isn't curently online or logged in.");
PlayerPlaySound(playerid,1055,0.0,0.0,0.0);
}
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "ERROR: You are not authorized to use this command.");
PlayerPlaySound(playerid, 1055, 0.0, 0.0, 0.0);
}
}
return 1;
}
Look at the AdmWarn part, there's the usage.
Hope it helps.