24.09.2016, 10:12
Quote:
Haha all goods thanks for offering your time.
Код:
../gamemodes/inc/admincommands.pwn(315) : error 033: array must be indexed (variable "query") PHP код:
Also with my other ban commands, /oban and /unban I get "Error: That player doesn't exist" |
Код:
cquery = mysql_query(ServerMySQL, query); //315
for /unban command, you must fetch banned player's IP first, before unban their IP.
Here are /oban and /unban commands, hope it will work
Код:
CMD:oban(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] < 3) return 0; { new name[24], query[250], reason[128], string[128]; if(sscanf(params, "s[24]s[24]", name, reason)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /offlineban [Player Name] [Reason]"); mysql_format(ServerMySQL, query, sizeof(query), "UPDATE `Users` SET pBanned = 1, pBannedBy = '%s', pReason = '%s' WHERE Name='%s'", GetName(playerid), reason, name); new Cache:c = mysql_query(ServerMySQL, query); if (!cache_affected_rows(ServerMySQL)) { cache_delete©; return SendClientMessage(playerid, COLOR_RED, "Error: That player doesn't exist"); } format(string,sizeof(string), "*You have successfully banned player %s.", name); SendClientMessage(playerid, COLOR_ADMIN, string); format(amsg, sizeof(amsg), "[Admin Log]: %s has offline banned player %s [Reason: %s]", GetName(playerid), name, reason); ABroadCast(COLOR_ADMIN,amsg, 1); foreach(new i : Player) { GetPlayerName(i, string, 24); if(!strcmp(string, name, true)) { SetTimerEx("UnsetBan", 500, 0, "i", i); break; } } cache_delete©; } return 1; } CMD:unban(playerid,params[]) { if(PlayerInfo[playerid][pAdmin] <= 3) return 0; new name[24], query[300], cmdstring[44], string[128]; if(sscanf(params, "s", name)) return SendClientMessage(playerid, COLOR_WHITE,"Usage: /unban [Player Name]"); mysql_format(ServerMySQL, query, sizeof(query), "UPDATE `Users` SET pBanned = 0, pBannedBy = '%s', pReason = '' WHERE Name='%s'", GetName(playerid), name); new Cache:c = mysql_query(ServerMySQL, query); if(!cache_affected_rows(ServerMySQL)) { cache_delete©; return SendClientMessage(playerid, COLOR_RED, "Error: That player doesn't exist"); } cache_delete©; mysql_format(ServerMySQL, query, sizeof(query), "SELECT `IP_COLUMN_NAME_HERE` FROM `Users` WHERE Name='%s'", name); // You need to fetch player IP first c = mysql_query(ServerMySQL, query); if(cache_num_rows()) { new playerip[16]; cache_get_field_content(0, 'IP_COLUMN_NAME_HERE', playerip, ServerMySQL, 16); format(cmdstring, sizeof(cmdstring), "unbanip %s", playerip); SendRconCommand(cmdstring); SendRconCommand("reloadbans"); } format(string,sizeof(string), "*You have successfully unbanned %s.", name); SendClientMessage(playerid, COLOR_ADMIN, string); format(amsg, sizeof(amsg), "[Admin Log]: %s has unbanned player %s", GetName(playerid), name); ABroadCast(COLOR_ADMIN,amsg, 1); cache_delete©; return 1; }