11.04.2012, 02:51
You started out pretty good, what you did wrong, is that you SendClientMessage before you format the "Promoted" "Demoted" strings, that's why it gives blank lines. This should work:
You don't need two strings. Just one is enough and you format it according to promote or demote function.
About your second problem, ain't that big deal. You just have to put a return after checking if the param is null. Here:
Now, what you did wrong, is that you didn't return the command and it continued till the end, therefor sending an empty message. Now, after it checks if the param is null, if it's true, it'll return sending the admin a message, that he needs to insert a parameter. Returning the command, will not continue what's after the return. So, no other message will be sent.
pawn Код:
CMD:setadmin(playerid, params[])
{
if(IsAdmin(playerid, 4))
{
new target, level, String[128];
if(sscanf(params, "ri", target, level))
if(level > 5) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] You can not set a Administrator Level higher than level 5.");
new PlayerName[MAX_PLAYER_NAME], TargetName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
GetPlayerName(target, TargetName, sizeof(TargetName));
if( level > PlayerInfo[target][Administrator] )
format(String, sizeof(String), "%s %s has promoted %s to a Level %d Administrator.", GetAdminRank(playerid), PlayerName, TargetName, level);
else if( level < PlayerInfo[target][Administrator] )
format(String, sizeof(String), "%s %s has demoted %s to a Level %d Administrator.", GetAdminRank(playerid), PlayerName, TargetName, level);
PlayerInfo[target][Administrator] = level;
SendClientMessage(target, -1, String);
}
else return SendClientMessage(playerid, COLOR_RED, "[CONSOLE] You are not allowed to use this command.");
return 1;
}
About your second problem, ain't that big deal. You just have to put a return after checking if the param is null. Here:
pawn Код:
CMD:achat(playerid, params[])
{
new PlayerName[128], String[128];
if(PlayerInfo[playerid][Administrator] < 1)
if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] /achat [Chat]");
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(String, sizeof(String),"%s %s: %s", GetAdminRank(playerid), PlayerName, params);
SendAdminMessage(COLOR_RED, String);
return 1;
}