PHP код:
#include a_samp
#include sscanf
#include zcmd
CMD:setname(playerid,params[]) {
if(PlayerInfo[playerid][Level] >= 3 || IsPlayerAdmin(playerid)) {
new player1, tmp2[32];
if(sscanf(params,"is[32]",player1,tmp2)) return SendClientMessage(playerid, red, "USAGE: /setname [playerid] [new name]");
new length = strlen(tmp2), string[128];
if(length < 3 || length > MAX_PLAYER_NAME+1) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
CMDMessageToAdmins(playerid,"SETNAME");
format(string, sizeof(string), "You have set \"%s's\" name to \"%s\" ", pName(player1), tmp2); SendClientMessage(playerid,blue,string);
if(player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your name to \"%s\" ", pName(playerid), tmp2); SendClientMessage(player1,blue,string); }
PlayerInfo[playerid][God] = 0;
SetPlayerHealth(player1, 100);
SetPlayerName(player1, tmp2);
return OnPlayerConnect(player1);
} else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
stock CMDMessageToAdmins(playerid,command[])
{
if(ServerInfo[AdminCmdMsg] == 0) return 0;
new string[128];
GetPlayerName(playerid,string,sizeof(string));
format(string,sizeof(string),"[ADMIN] '%s' (Level: %d) | Command: %s",string,PlayerInfo[playerid][Level],command);
MessageToAdmins(blue,string);
return 1;
}
forward MessageToAdmins(color,const string[]);
public MessageToAdmins(color,const string[])
{
foreach (new i : Player) if(IsPlayerConnected(i) == 1) if (PlayerInfo[i][Level] >= 1 || IsPlayerAdmin(i)) SendClientMessage(i, color, string);
//return 1;
}