Demote/Promote -
Nivniv2 - 22.02.2013
Код:
CMD:makeadmin(playerid, params[]) {
if(PlayerInfo[playerid][pAdmin] < 99999)
new
iAdminValue,
iTargetID;
if(sscanf(params, "ui", iTargetID, iAdminValue)) {
SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /makeadmin [playerid] [level]");
}
else if(IsPlayerConnected(iTargetID)) {
if(PlayerInfo[iTargetID][pHelper] >= 1) {
SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot make community advisors admins!");
}
else {
new
szMessage[47 + (MAX_PLAYER_NAME * 2)];
PlayerInfo[iTargetID][pAdmin] = iAdminValue;
format(szMessage, sizeof(szMessage), "AdmCmd: %s has promoted %s to a level %d admin.", GetPlayerNameEx(playerid), GetPlayerNameEx(iTargetID), iAdminValue);
ABroadCast(COLOR_LIGHTRED,szMessage, 2);
format(szMessage, sizeof(szMessage), "You have been promoted to a level %d admin by %s.", iAdminValue, GetPlayerNameEx(playerid));
SendClientMessageEx(iTargetID, COLOR_LIGHTBLUE, szMessage);
format(szMessage, sizeof(szMessage), "You have promoted %s to a level %d admin.", GetPlayerNameEx(iTargetID),iAdminValue);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, szMessage);
}
}
else SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid player specified.");
}
else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use this command!");
return 1;
}
When i make someone admin level 3 and then admin level 2 its says that he was promoted, and he's admin level 2..
Can make it to say "demoted" expect for "promoted" if i actully demote someone?
Re: Demote/Promote -
Da_Noob - 22.02.2013
ye, you can actually. Just do something like:
pawn Код:
if(iAdminValue < PlayerInfo[iTargetID][pAdmin])
{
SendClientMessage(iTargetID, -1, "You've been demoted!");
PlayerInfo[iTargetID][pAdmin] = iAdminValue;
}
something like that
Re: Demote/Promote -
Neil. - 22.02.2013
Try:
pawn Код:
CMD:makeadmin(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1000)
{
new iAdminValue, iTargetID;
if(sscanf(params, "ui", iTargetID, iAdminValue)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /makeadmin [playerid] [level]");
if(!IsPlayerConnected(iTargetID)) return SendClientMessageEx(playerid, COLOR_WHITE, "Player is not connected lol");
if(PlayerInfo[iTargetID][pHelper] >= 1) return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot make community advisors admins!");
{
if(iAdminValue < PlayerInfo[iTargetID][pAdmin])
{
new szMessage[47 + (MAX_PLAYER_NAME * 2)];
PlayerInfo[iTargetID][pAdmin] = iAdminValue;
format(szMessage, sizeof(szMessage), "AdmCmd: %s has demoted %s to a level %d admin.", GetPlayerNameEx(playerid), GetPlayerNameEx(iTargetID), iAdminValue);
ABroadCast(COLOR_LIGHTRED,szMessage, 2);
format(szMessage, sizeof(szMessage), "You have been demoted to a level %d admin by %s.", iAdminValue, GetPlayerNameEx(playerid));
SendClientMessageEx(iTargetID, COLOR_LIGHTBLUE, szMessage);
format(szMessage, sizeof(szMessage), "You have demoted %s to a level %d admin.", GetPlayerNameEx(iTargetID),iAdminValue);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, szMessage);
}
else if(iAdminValue > PlayerInfo[iTargetID][pAdmin])
{
new szMessage[47 + (MAX_PLAYER_NAME * 2)];
PlayerInfo[iTargetID][pAdmin] = iAdminValue;
format(szMessage, sizeof(szMessage), "AdmCmd: %s has promoted %s to a level %d admin.", GetPlayerNameEx(playerid), GetPlayerNameEx(iTargetID), iAdminValue);
ABroadCast(COLOR_LIGHTRED,szMessage, 2);
format(szMessage, sizeof(szMessage), "You have been promoted to a level %d admin by %s.", iAdminValue, GetPlayerNameEx(playerid));
SendClientMessageEx(iTargetID, COLOR_LIGHTBLUE, szMessage);
format(szMessage, sizeof(szMessage), "You have promoted %s to a level %d admin.", GetPlayerNameEx(iTargetID),iAdminValue);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, szMessage);
}
}
}
else SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid player specified.");
}
else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use this command!");
return 1;
}
Re: Demote/Promote -
ryansheilds - 22.02.2013
You're using the less than statement "<" in the first argument... That means if the player admin level is less than "99999" they can use the CMD... I assume this is a mistake? You should take a look at it.
Untested:
pawn Код:
CMD:makeadmin(playerid, params[]) {
if(PlayerInfo[playerid][pAdmin] < 99999) {
new
iAdminValue,
iTargetID;
if(sscanf(params, "ui", iTargetID, iAdminValue))
return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /makeadmin [playerid] [level]");
if(IsPlayerConnected(iTargetID)) {
if(PlayerInfo[iTargetID][pHelper] >= 1)
return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot make community advisors admins!");
new
szMessage[47 + (MAX_PLAYER_NAME * 2)];
format(szMessage, sizeof(szMessage), "AdmCmd: %s has %s %s to a level %d admin.", GetPlayerNameEx(playerid), ((iAdminValue > PlayerInfo[iTargetID][pAdmin]) ? ("promoted") : ("demoted")), GetPlayerNameEx(iTargetID), iAdminValue);
ABroadCast(COLOR_LIGHTRED,szMessage, 2);
format(szMessage, sizeof(szMessage), "You have been %s to a level %d admin by %s.", ((iAdminValue > PlayerInfo[iTargetID][pAdmin]) ? ("promoted") : ("demoted")), iAdminValue, GetPlayerNameEx(playerid));
SendClientMessageEx(iTargetID, COLOR_LIGHTBLUE, szMessage);
format(szMessage, sizeof(szMessage), "You have %s %s to a level %d admin.", ((iAdminValue > PlayerInfo[iTargetID][pAdmin]) ? ("promoted") : ("demoted")), GetPlayerNameEx(iTargetID),iAdminValue);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, szMessage);
PlayerInfo[iTargetID][pAdmin] = iAdminValue;
}
else SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid player specified.");
}
else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use this command!");
return 1;
}
You should get the idea, "((iAdminValue > PlayerInfo[iTargetID][pAdmin]) ? ("promoted") : ("demoted"))" is a argument you can use within the format, if the level is higher than the admins level it'll return "promoted" else "demoted".