09.01.2014, 03:01
I was just wandering and it took a hour to make this. Is there something wrong with my command? Its about Admin name duty and Admin Duty command.
And here are the commands to do so.
pawn Код:
enum pInfo
{
AdminName[24],
PlayerName[24],
bool:HasSetAdminName,
OnDuty
};
new PlayerInfo[MAX_PLAYERS+1][pInfo];
pawn Код:
CMD:setadminname(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1)
{
SendClientMessageEx(playerid, COLOR_WHITE, "You are not an admin.");
}
new
adminname[24],
a_string[65]
;
if(sscanf(params, "s[24]", adminname))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setadminanme [name]");
}
PlayerInfo[playerid][AdminName] = adminname;
format(a_string, 65, "Your admin name is %s.", PlayerInfo[playerid][AdminName]);
SendClientMessage(playerid, -1, a_string);
PlayerInfo[playerid][HasSetAdminName] = true;
return 1;
}
CMD:aduty(playerid)
{
if(PlayerInfo[playerid][pAdmin] >= 2)
{
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
PlayerInfo[playerid][PlayerName] = name;
if(AdminDuty[playerid] == 0 && PlayerInfo[playerid][HasSetAdminName] = true)
{
new string[128];
SetPlayerHealth(playerid,999999);
SetPlayerColor(playerid,COLOR_RED);
SetPlayerName(playerid, PlayerInfo[playerid][AdminName]);
format(string,sizeof(string), "%s is now on duty admin.",GetPlayerNameEx(playerid));
SendClientMessageToAll(COLOR_WHITE,string);
SendClientMessage(playerid,COLOR_RED,"You are now on duty!");
AdminDuty[playerid] = 1;
}
else if(AdminDuty[playerid] == 1 && PlayerInfo[playerid][HasSetAdminName] = true)
{
new string[128];
SetPlayerHealth(playerid,100);
format(string,sizeof(string)," %s is now off Duty!",GetPlayerNameEx(playerid));
SendClientMessageToAll(COLOR_WHITE,string);
SetPlayerColor(playerid, COLOR_WHITE);
SendClientMessage(playerid, COLOR_WHITE,"You are now off duty admin");
AdminDuty[playerid] = 0;
}
else if(!PlayerInfo[playerid][HasSetAdminName])
{
SendClientMessageEx(playerid, COLOR_WHITE, "ERROR: You haven't set any admin name yet.");
}
}
else
SendClientMessage(playerid,COLOR_WHITE,"You are not an admin.");
return 1;
}