26.12.2018, 20:10
Quote:
PHP код:
targetid = GetPlayerID(""); Also, using a player ID when the player is offline is useless.. what do you think targetid would be if the player was offline? |
Код:
./inc/admin.inc(68) : error 033: array must be indexed (variable "target") ./inc/admin.inc(75) : error 033: array must be indexed (variable "target") ./inc/admin.inc(78) : error 033: array must be indexed (variable "target")
Код:
CMD:makeadmin(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] < 4) { SCM(playerid,COLOR_ERROR,"ERROR: You do not have the required access to execute this command."); SCM(playerid,COLOR_INFO,"INFO: You need admin level 4 or above to use this command."); } else { new target[24], value, str[128], query[128]; if(sscanf(params, "s[24]i", target, value)) { format(str, sizeof(str), "INFO: /admin [full name(case sensitive)] [0-%i]",MAX_ADMIN_LEVEL); SCM(playerid, COLOR_INFO, str); } if(value < 0 || value > MAX_ADMIN_LEVEL) { format(str, sizeof(str), "ERROR: You can only use a value between 0 and %i.",MAX_ADMIN_LEVEL); SCM(playerid, COLOR_ERROR, str); } new targetid = GetPlayerID(target); if( targetid == playerid ) return SCM(playerid, COLOR_ERROR, "ERROR: You can not use this command on yourself."); if(IsPlayerConnected(targetid)) { PlayerInfo[targetid][pAdmin] = value; mysql_format(ourConnection, query, sizeof(query),"UPDATE `accounts` SET `admin` = %i WHERE `acc_name` = %e",PlayerInfo[targetid][pAdmin], PlayerInfo[targetid][pAccName]); mysql_tquery(ourConnection, query); format(str,sizeof(str),"SERVER: You have set {FFFFFF}%s(%i){ADD8E6} their admin level to {FFFFFF}%i{ADD8E6}.",ReturnName(targetid), targetid, value); SCM(playerid, COLOR_LIGHTBLUE, str); format(str,sizeof(str),"SERVER: Your admin level was set to {FFFFFF}%i{ADD8E6} by {FFFFFF}%s(%i){ADD8E6}.",value, ReturnName(playerid), playerid); SCM(targetid, COLOR_LIGHTBLUE,str); } else { new rows, fields; mysql_format(ourConnection, query, sizeof(query), "SELECT * FROM accounts WHERE acc_name = '%e'",PlayerInfo[target][pAccName]); mysql_tquery(ourConnection, query); cache_get_data(rows, fields, ourConnection); if(!rows) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: That account does not exist."); PlayerInfo[target][pAdmin] = value; PlayerInfo[playerid][pAdminRankMsg] = true; // sends the player a message when they login informing them that their admin rank was adjusted. mysql_format(ourConnection, query, sizeof(query),"UPDATE `accounts` SET `admin` = %i WHERE `acc_name` = %e",PlayerInfo[target][pAdmin], PlayerInfo[target][pAccName]); mysql_tquery(ourConnection, query); format(str, sizeof(str), "SERVER: You have set {FFFFFF}%s{ADD8E6} their admin level to {FFFFFF}%i{A7A7A7}.",target, value); SCM(playerid, COLOR_LIGHTBLUE, str); } } return 1; }