CMD:setadminname(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 5)
{
/*if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
{
SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
return 1;
}*/
new giveplayerid, name[32];
if(sscanf(params, "us[32]", giveplayerid, name))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setadminname [playerid/partofname] [name]");
return 1;
}
if(PlayerInfo[giveplayerid][pAdmin] < 1)
{
SendClientMessage(playerid, COLOR_WHITE, "The player is not an admin.");
return 1;
}
if(AdminDuty[giveplayerid] != 0)
{
SendClientMessage(playerid, COLOR_WHITE, "That admin is currently on-duty. They must go off-duty in order for you to set their admin name.");
return 1;
}
new length = strlen(name);
if(length < 3 || length > 20)
{
SendClientMessage(playerid, COLOR_WHITE, "The name can't less than 3 characters or more than 20 characters.");
return 1;
}
if(strfind(name, "_", true) != -1)
{
SendClientMessage(playerid, COLOR_WHITE, "The admin name must be one name. There can't be an underscore in the name.");
return 1;
}
if(strcmp(name, "Usama", true) == 0 && PlayerInfo[playerid][pAdmin] < 6) {
SendClientMessage(playerid, COLOR_WHITE, "stop ! im Usama ! you're not Usama !");
return 1;
}
new string[128];
format(string, sizeof(string), "AdmCmd: %s has set %s's admin name to '%s'.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), name);
ABroadCast(COLOR_LIGHTRED, string, 1);
format(PlayerInfo[giveplayerid][pAdminName], 32, name);
}
else SendClientMessage(playerid, COLOR_GRAD1, "You're not authorized to use that command!");
return 1;
}
CMD:setadminname(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 5)
{
/*if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
{
SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
return 1;
}*/
new giveplayerid, name[32];
if(sscanf(params, "us[32]", giveplayerid, name))return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setadminname [playerid/partofname] [name]");
if(PlayerInfo[giveplayerid][pAdmin] < 1)return SendClientMessage(playerid, COLOR_WHITE, "The player is not an admin.");
if(AdminDuty[giveplayerid] != 0)return SendClientMessage(playerid, COLOR_WHITE, "That admin is currently on-duty. They must go off-duty in order for you to set their admin name.");
new length = strlen(name);
if(length < 3 || length > 20)return SendClientMessage(playerid, COLOR_WHITE, "The name can't less than 3 characters or more than 20 characters.");
if(strfind(name, "_", true) != -1)return SendClientMessage(playerid, COLOR_WHITE, "The admin name must be one name. There can't be an underscore in the name.");
if(strcmp(name, "Usama", true) == 0 && PlayerInfo[playerid][pAdmin] < 6)return SendClientMessage(playerid, COLOR_WHITE, "stop ! im Usama ! you're not Usama !");
SetPlayerName(giveplayerid, name);
new string[128];
format(string, sizeof(string), "AdmCmd: %s has set %s's admin name to '%s'.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), name);
ABroadCast(COLOR_LIGHTRED, string, 1);
format(PlayerInfo[giveplayerid][pAdminName], sizeof(name), name);
}else SendClientMessage(playerid, COLOR_GRAD1, "You're not authorized to use that command!");
return 1;
}
My eyes hurt when i saw ur code....
PHP код:
|
O.T.: a player's name can have a maximum length of 24. Giving the variable a size of 25 and higher is unnecessary. Have you tested the code with a second player instead of on yourself? |
His code looks better than yours, tbh. It's easier to read through.
|
So what? I don't program like that myself, but it doesn't do any harm. In fact, it may even make it easier to analyze the code. Feel free to not do that, but don't hammer on someone who chooses to do it that way.
|
It's easier to read than yours. You don't have to put return 1; on every "error" message, you could use "else if". But OP put it.
|