if(strcmp(cmd, "/setadmin", true) == 0)
{
if(pInfo[playerid][Admin] > 0)
{
tmp = strtok(cmdtext,idx), tmp2 = strtok(cmdtext,idx);
new player1, level;
player1 = strval(tmp);
level = strval(tmp2);
if(!strlen(tmp) && !strlen(tmp2))
{
SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setadmin [playerid] [level]");
}
else
{
GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
format(string,sizeof(string),"You have promoted %s to adminlevel %d ", playername, level);
SendClientMessage(playerid, gold, string);
format(string,sizeof(string),"Administrator %s has promoted %s to adminlevel %d",adminname, playername, level);
SendClientMessageToAll(gold, string);
printf("%s has promoted %s to adminlevel %d",adminname, playername, level);
pInfo[player1][Admin] = level;
}
}
return 1;
}
CMD:setadmin(playerid, o[])
{
if(IsPlayerAdmin(playerid) || pInfo[playerid][pAdmin] == 1337) {
new string[128], ID, cmdreason;
if(sscanf(o,"ui",ID,cmdreason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /setadmin (Player Name/ID) (Level [0 - 7 | 1336 - 1337])");
else if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, "The player name/ID you entered is not connected to the server.");
else if(cmdreason == pInfo[ID][pAdmin])
{
format(string,sizeof(string),"Player/Administrator %s(%d) is already at level %d.",PlayerName(ID),ID,cmdreason);
SendClientMessage(playerid,COLOR_RED,string);
}
// this one down here is the current invalid levels. the levels are between 8 and 1335.
else if(cmdreason > 7 && cmdreason < 1336) SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid level.");
else {
pInfo[ID][pAdmin] =cmdreason;
format(string,sizeof(string),"Administrator %s has set your admin level to %d.",PlayerName(playerid),cmdreason);
SendClientMessage(ID, COLOR_ADMIN, string);
format(string,sizeof(string),"You have set %s(%d)'s level to %d.",PlayerName(ID),ID,cmdreason);
SendClientMessage(playerid, COLOR_ADMIN, string);
format(string,sizeof(string),"An administrator has set %s's level to %d.",PlayerName(ID),cmdreason);
SendClientMessageToAll(COLOR_LIMEGREEN, string);
format(string,sizeof(string),"%s(%d) has set %s(%d)'s level to %d.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason);
print(string);
}
} else SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command!");
return 1;
}
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(579) : warning 213: tag mismatch
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(580) : warning 213: tag mismatch
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(1735) : warning 219: local variable "Message" shadows a variable at a preceding level
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(1800) : error 029: invalid expression, assumed zero
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(1800) : error 017: undefined symbol "cmd_makeadmin"
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(1800) : error 029: invalid expression, assumed zero
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(1800) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
4 Errors.
CMD:setadmin(playerid, params[])
Dont use the strcmp its old, stinky, buggy and annoying. Use zcmd (https://sampforum.blast.hk/showthread.php?tid=91354) to make commands on a much efficienter way
|
I really hate it when you posted that. Strcmp was the first and original pawn code for SAMP. Yes of course, its confusing but yeah, using ZCMD and Sscanf is better. Faster Command Processors. But value strcmp, because many players like me use it and its important. Scripters learn strcmp first before they learn about the others.
|