[08:47:42] [Command]: [vR]Yottabyte has used the command /banreason. [08:47:46] [debug] Server crashed while executing vR.amx [08:47:46] [debug] AMX backtrace: [08:47:46] [debug] #0 00000061 in ?? () at <unknown file>:0 [08:47:46] [debug] #1 00000061 in public cmd_banreason () at <unknown file>:0 [08:47:46] [debug] #2 native CallLocalFunction () from samp03svr [08:47:46] [debug] #3 00000a58 in public OnPlayerCommandText (playerid=0, cmdtext[]=@016e8090 "/banreason dwa") at E:\All Folders\Hobbies\Server Hosting\SA-MP\__VR\pawno\include\zcmd.inc:108
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] <= 1) return 0;
{
new ID, reason[128], str[128], plrIP[16], query[1024], bannedby[50];
if(sscanf(params, "us[100]", ID, reason)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /ban [PlayerID] [Reason]");
if(PlayerInfo[ID][pAdmin] >= PlayerInfo[playerid][pAdmin] && PlayerInfo[ID][pUCAdmin] == 0 && PlayerInfo[playerid][pAdmin] != 6) return SendClientFormattedMessage(playerid, COLOR_RED, "Error: Not enough privilages to ban %s.", GetName(ID), "");
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_GREY, "Error: That player is not found.");
format(str, sizeof(str), "[Admin Log]: %s has been banned by Administrator %s. [Reason: %s]", GetName(ID), GetName(playerid), reason);
ABroadCast(COLOR_ADMIN, str, 1);
print(str);
GetPlayerIp(ID, plrIP, sizeof(plrIP));
SaveToFile("BanLog", str);
SendClientMessage(ID,COLOR_RED,"|___________[BAN INFO]___________|");
format(str, sizeof(str), "Your name: %s.",GetName(ID));
SendClientMessage(ID, COLOR_RED, str);
format(str, sizeof(str), "Your ip is: %s.", plrIP);
SendClientMessage(ID, COLOR_RED, str);
format(str, sizeof(str), "You were banned by: %s.",GetName(playerid));
SendClientMessage(ID, COLOR_RED, str);
format(str, sizeof(str), "You were banned for: %s. Make an ban appeal on: www.vexed-rp.com",reason);
SendClientMessage(ID, COLOR_RED, str);
SendClientMessage(ID,COLOR_RED,"|___________[BAN INFO]___________|");
SetTimerEx("UnsetBan", 500, 0, "i", ID);
bannedby = GetName(playerid);
PlayerInfo[ID][pBanned] = 1;
PlayerInfo[ID][pReason] = reason;
PlayerInfo[ID][pBannedBy] = bannedby;
mysql_format(ServerMySQL, query, sizeof(query), "UPDATE `Users` SET pBanned = %d, pBannedBy = '%s', pReason = '%s', WHERE Name='%s'",1,GetName(playerid),reason, GetName(ID));
mysql_tquery(ServerMySQL, query, "", "");
}
return 1;
}
CMD:oban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 3) return 0;
{
new ID, name[128], 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 = %d, pBannedBy = '%s', pReason = '%s' WHERE Name='%s'", 1, GetName(playerid), reason, name);
mysql_tquery(ServerMySQL, query, "", "");
if (!cache_affected_rows(ServerMySQL)) 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);
if(IsPlayerConnected(ID))
{
SetTimerEx("UnsetBan", 500, 0, "i", ID);
}
}
return 1;
}
CMD:unban(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] <= 3) return 0;
new name, query[300], cmdstring[44], string[128];
if(sscanf(params, "s[24]", name)) return SendClientMessage(playerid, COLOR_WHITE,"Usage: /unban [Player Name]");
mysql_format(ServerMySQL, query, sizeof(query), "UPDATE `Users` SET pBanned = %d, pBannedBy = '%s', pReason = '%s' WHERE Name='%s'", 1, GetName(playerid), "", GetName(name));
mysql_tquery(ServerMySQL, query, "", "");
if(!cache_affected_rows(ServerMySQL)) return SendClientMessage(playerid, COLOR_RED, "Error: That player doesn't exist");
format(cmdstring, sizeof(cmdstring), "unbanip %s", PlayerInfo[name][pIP]);
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);
//UnBlockIpAddress( ip_address );
return 1;
}
CMD:banreason(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] <= 3) return 0;
new name, query[128], string[128], reason[128];
if(sscanf(params, "s[24]", name)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /banreason [Player Name]");
format(query, sizeof(query), "SELECT `pReason` FROM `Users` WHERE `Name` = '%s'", GetName(name));
mysql_query(ServerMySQL, query);
if(cache_num_rows())
{
cache_get_field_content(0, "pReason", reason);
if(!strcmp(reason, "", false, 1))
{
format(string,sizeof(string), "[BAN REASON]: %s was banned for: %s",GetName(name), reason);
SendClientMessage(playerid, COLOR_YELLOW, string);
format(amsg,sizeof(amsg), "[Admin Log]: %s is requesting ban information on %s", GetName(playerid), GetName(name));
}
else
{
SendClientMessage(playerid, COLOR_RED, "Error: That player isn't banned.");
}
}
return 1;
}
CMD:banreason(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] <= 3) return 0; new name[24], query[128], string[128], reason[128]; if(sscanf(params, "s[24]", name)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /banreason [Player Name]"); format(query, sizeof(query), "SELECT `pReason` FROM `Users` WHERE `Name` = '%s'", name); mysql_query(ServerMySQL, query); if(cache_num_rows()) { cache_get_field_content(0, "pReason", reason); if(!strcmp(reason, "", false, 1)) { format(string,sizeof(string), "[BAN REASON]: %s was banned for: %s", name, reason); SendClientMessage(playerid, COLOR_YELLOW, string); format(amsg,sizeof(amsg), "[Admin Log]: %s is requesting ban information on %s", GetName(playerid), name); // Rest of code here } else { SendClientMessage(playerid, COLOR_RED, "Error: That player isn't banned."); } } return 1; }
Actually "name" (misleading variable name) would need to be integer and you'd have to use "r" or "u" specifier in sscanf. GetName function accepts an integer, not a string so that'd give error 035.
Is that the whole code in the command? If not, post the whole command. All are natives except GetName which is still not reported even if you have -d3 flag. And remove the cache from memory otherwise you're going to have memory leaks. |
CMD:oban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 3) return 0;
{
new ID, query[250], reason[128], string[128];
if(sscanf(params, "us[24]", ID, reason)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /offlineban [Player Name] [Reason]");
mysql_format(ServerMySQL, query, sizeof(query), "UPDATE `Users` SET pBanned = %d, pBannedBy = '%s', pReason = '%s' WHERE Name='%s'", 1, GetName(playerid), reason, GetName(ID));
mysql_tquery(ServerMySQL, query, "", "");
if (!cache_affected_rows(ServerMySQL)) return SendClientMessage(playerid, COLOR_RED, "Error: That player doesn't exist");
format(string,sizeof(string), "*You have successfully banned player %s.", GetName(ID));
SendClientMessage(playerid, COLOR_ADMIN, string);
format(amsg, sizeof(amsg), "[Admin Log]: %s has offline banned player %s [Reason: %s]", GetName(playerid), GetName(ID), reason);
ABroadCast(COLOR_ADMIN,amsg, 1);
if(IsPlayerConnected(ID))
{
SetTimerEx("UnsetBan", 500, 0, "i", ID);
}
}
return 1;
}
CMD:unban(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] <= 3) return 0;
new ID, query[300], cmdstring[44], string[128];
if(sscanf(params, "u", ID)) return SendClientMessage(playerid, COLOR_WHITE,"Usage: /unban [Player Name]");
mysql_format(ServerMySQL, query, sizeof(query), "UPDATE `Users` SET pBanned = %d, pBannedBy = '%s', pReason = '%s' WHERE Name='%s'", 1, GetName(playerid), "", GetName(ID));
mysql_tquery(ServerMySQL, query, "", "");
if(!cache_affected_rows(ServerMySQL)) return SendClientMessage(playerid, COLOR_RED, "Error: That player doesn't exist");
format(cmdstring, sizeof(cmdstring), "unbanip %s", PlayerInfo[ID][pIP]);
SendRconCommand(cmdstring);
SendRconCommand("reloadbans");
format(string,sizeof(string), "*You have successfully unbanned %s.", GetName(ID));
SendClientMessage(playerid, COLOR_ADMIN, string);
format(amsg, sizeof(amsg), "[Admin Log]: %s has unbanned player %s", GetName(playerid), GetName(ID));
ABroadCast(COLOR_ADMIN,amsg, 1);
//UnBlockIpAddress( ip_address );
return 1;
}
CMD:banreason(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] <= 3) return 0;
new ID, query[128], string[128], reason[128];
if(sscanf(params, "u", ID)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /banreason [Player Name]");
format(query, sizeof(query), "SELECT `pReason` FROM `Users` WHERE `Name` = '%s'", GetName(ID));
mysql_query(ServerMySQL, query);
if(cache_num_rows())
{
cache_get_field_content(0, "pReason", reason);
if(!strcmp(reason, "", false, 1))
{
format(string,sizeof(string), "[BAN REASON]: %s was banned for: %s",GetName(ID), reason);
SendClientMessage(playerid, COLOR_YELLOW, string);
format(amsg,sizeof(amsg), "[Admin Log]: %s is requesting ban information on %s", GetName(playerid), GetName(ID));
}
else
{
SendClientMessage(playerid, COLOR_RED, "Error: That player isn't banned.");
}
}
return 1;
}
CMD:banreason(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] <= 3) return 0; new name[24], query[128], string[128], reason[128]; if(sscanf(params, "s[24]", name)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /banreason [Player Name]"); format(query, sizeof(query), "SELECT `pReason` FROM `Users` WHERE `Name` = '%s'", name); new Cache:cquery; cquery = mysql_query(ServerMySQL, query); if(cache_num_rows()) { cache_get_field_content(0, "pReason", reason); if(!strcmp(reason, "", false, 1)) { format(string,sizeof(string), "[BAN REASON]: %s was banned for: %s", name, reason); SendClientMessage(playerid, COLOR_YELLOW, string); format(amsg,sizeof(amsg), "[Admin Log]: %s is requesting ban information on %s", GetName(playerid), name); // Rest of code here } else { SendClientMessage(playerid, COLOR_RED, "Error: That player isn't banned."); } } cache_delete(cquery); return 1; }
../gamemodes/inc/admincommands.pwn(314) : error 021: symbol already defined: "query" ../gamemodes/inc/admincommands.pwn(315) : error 035: argument type mismatch (argument 2)
new Cache:query;// 314
query = mysql_query(ServerMySQL, query); //315
../gamemodes/inc/admincommands.pwn(315) : error 033: array must be indexed (variable "query")
query = mysql_query(ServerMySQL, query); //315
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
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; }
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] <= 1) return 0;
{
new ID, reason[128], str[128], plrIP[16], query[1024], bannedby[50];
if(sscanf(params, "us[100]", ID, reason)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /ban [PlayerID] [Reason]");
if(PlayerInfo[ID][pAdmin] >= PlayerInfo[playerid][pAdmin] && PlayerInfo[ID][pUCAdmin] == 0 && PlayerInfo[playerid][pAdmin] != 6) return SendClientFormattedMessage(playerid, COLOR_RED, "Error: Not enough privilages to ban %s.", GetName(ID), "");
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_GREY, "Error: That player is not found.");
format(str, sizeof(str), "[Admin Log]: %s has been banned by Administrator %s. [Reason: %s]", GetName(ID), GetName(playerid), reason);
ABroadCast(COLOR_ADMIN, str, 1);
print(str);
GetPlayerIp(ID, plrIP, sizeof(plrIP));
SaveToFile("BanLog", str);
SendClientMessage(ID,COLOR_RED,"|___________[BAN INFO]___________|");
format(str, sizeof(str), "Your name: %s.",GetName(ID));
SendClientMessage(ID, COLOR_RED, str);
format(str, sizeof(str), "Your ip is: %s.", plrIP);
SendClientMessage(ID, COLOR_RED, str);
format(str, sizeof(str), "You were banned by: %s.",GetName(playerid));
SendClientMessage(ID, COLOR_RED, str);
format(str, sizeof(str), "You were banned for: %s. Make an ban appeal on: www.vexed-rp.com",reason);
SendClientMessage(ID, COLOR_RED, str);
SendClientMessage(ID,COLOR_RED,"|___________[BAN INFO]___________|");
SetTimerEx("UnsetBan", 500, 0, "i", ID);
bannedby = GetName(playerid);
PlayerInfo[ID][pBanned] = 1;
PlayerInfo[ID][pReason] = reason;
PlayerInfo[ID][pBannedBy] = bannedby;
mysql_format(ServerMySQL, query, sizeof(query), "UPDATE `Users` SET pBanned = %d, pBannedBy = '%s', pReason = '%s', WHERE Name='%s'",1,GetName(playerid),reason, GetName(ID));
mysql_tquery(ServerMySQL, query, "", "");
}
return 1;
}