07.10.2014, 12:36
Hi, I have this command here to promote players to admin
i tried that and gives me errors:
lines 469-471:
Код:
CMD:promote(playerid, params[]) { new targetid, adminlvl, string[128], string2[128], adminstring[32]; if(PlayerInfo[playerid][pAdmin] == 0) { return 0; } else { if(sscanf(params, "dd", targetid, adminlvl)) return SendClientMessage(playerid, COLOR_GOLDENROD, "Usage: /promote [id] [level]"); if(adminlvl < 0 || adminlvl > 4) return SendClientMessage(playerid, COLOR_GOLDENROD, "Invalid Admin Level!"); if(playerid == targetid) return SendClientMessage(playerid, COLOR_GOLDENROD, "You can't promote yourself!"); if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GOLDENROD, "This player is not connected!"); if(PlayerInfo[playerid][pAdmin] >= 3) { switch(adminlvl) { case 1: adminstring[32] = "moderator(1)"; break; case 2: adminstring[32] = "administrator(2)"; break; case 3: adminstring[32] = "manager(3)"; break; case 4: adminstring[32] = "owner(4)"; break; default: adminstring[32] = "regular player(0)"; break; } format(string, sizeof(string), "You have been promoted to %s by %s", adminstring, GetName(playerid)); format(string2, sizeof(string2), "You have promoted %s to %s", GetName(targetid), adminstring); SendClientMessage(playerid, COLOR_GOLDENROD, string); SendClientMessage(targetid, COLOR_GOLDENROD, string2); PlayerInfo[targetid][pAdmin] = adminlvl; new INI:File = INI_Open(UserPath(targetid)); INI_SetTag(File, "data"); INI_WriteInt(File, "Admin", PlayerInfo[targetid][pAdmin]); INI_Close(File); return 1; } else return SendClientMessage(playerid, COLOR_GOLDENROD, "You can't promote if your not a manager or higher admin level!"); } }
Код:
E:\test samp serber\gamemodes\dmxtreme.pwn(469) : error 032: array index out of bounds (variable "adminstring") E:\test samp serber\gamemodes\dmxtreme.pwn(469) : error 006: must be assigned to an array E:\test samp serber\gamemodes\dmxtreme.pwn(470) : error 002: only a single statement (or expression) can follow each "case" E:\test samp serber\gamemodes\dmxtreme.pwn(470) : error 036: empty statement E:\test samp serber\gamemodes\dmxtreme.pwn(471) : warning 217: loose indentation E:\test samp serber\gamemodes\dmxtreme.pwn(471) : error 014: invalid statement; not in switch E:\test samp serber\gamemodes\dmxtreme.pwn(471) : warning 215: expression has no effect E:\test samp serber\gamemodes\dmxtreme.pwn(471) : error 001: expected token: ";", but found ":" E:\test samp serber\gamemodes\dmxtreme.pwn(471) : error 029: invalid expression, assumed zero E:\test samp serber\gamemodes\dmxtreme.pwn(471) : fatal error 107: too many error messages on one line
Код:
switch(adminlvl) { case 1: adminstring[32] = "moderator(1)"; //469 break; //470 case 2: //471..etc adminstring[32] = "administrator(2)"; break; case 3: adminstring[32] = "manager(3)"; break; case 4: adminstring[32] = "owner(4)"; break; default: adminstring[32] = "regular player(0)"; break; }