MySQL Ban List - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL Ban List (
/showthread.php?tid=658678)
MySQL Ban List -
NoteND - 09.09.2018
Hey!
How do you make this work?
https://pastebin.com/8iDNMVXb
Im guessing you know what I want to do
Re: MySQL Ban List -
AmirSavand - 09.09.2018
Provide more detail, what errors do you get?
Re: MySQL Ban List -
Banditul18 - 10.09.2018
Apart from not storing the cache and delete it after(probably memory leak). And missing the loop to get all the bans from the database i see no problem
Re: MySQL Ban List -
Infin1ty - 11.09.2018
First of all, you should NEVER run mysql_query within a command. Pass it on to a function and do what you need. I'm going to re-write the command for you, for MySQL r41-4. If you're using an older version it'll be at your discretion to convert.
cache_get_value_name's syntax is incorrect. It should be cache_get_value_name(0, whatever, store, len);
PHP код:
CMD:banlist(playerid, params[])
{
//if(pInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use that command.");
new query[32];
mysql_format(Database, query, sizeof query, "SELECT * FROM `banned`");
mysql_pquery(Database, query, "OnServerBanListLookup", "i", playerid);
return 1;
}
forward OnServerBanListLookup(playerid);
public OnServerBanListLookup(playerid)
{
if(!IsPlayerConnected(playerid))
return 1;
if(cache_num_rows())
{
new id,
name[MAX_PLAYER_NAME],
reason[64],
admin,
datestring,
timestring[16],
text[256], // You can increase this in the future.
string[512]; // You can increase this in the future.
SendClientMessage(playerid, -1, "{AFAFAF}----------------------{FF9900}Server Ban List{AFAFAF}----------------------");
for(new i = cache_num_rows(); i > 0; i--)
{
cache_get_value_name_int(i, "ID", id);
cache_get_value_name(i, "Username", name, MAX_PLAYER_NAME);
cache_get_value_name(i, "Reason", reason, 64);
cache_get_value_name(i, "Admin", admin, MAX_PLAYER_NAME);
cache_get_value_name(i, "Date", datestring, 16);
cache_get_value_name(i, "Time", timestring);
format(text, sizeof text, "ID: %d{FF9900}Username: {AFAFAF}%s {FF9900}Reason: {AFAFAF}%s {FF9900}Admin: {AFAFAF}%s Date & Time: {AFAFAF}%s %s\n", id, name, reason, admin, datestring, timestring);
strcat(string, text);
}
ShowPlayerDialog(playerid, 20000, DIALOG_STYLE_MSGBOX, "Server Ban List", string, "Close", "");
// Change dialog ID to a unused dialog ID, or use Dialog_Show if using easyDialog by Emmet.
return 1;
}
else
{
SendClientMessage(extraid, COLOR_GREY, "No bans have been found.");
}
return 1;
}
This should work perfectly for you (though I have not tested it). If there are any issues just post again.
EDIT: I have modified it and put some errors in. You might want to try and fix those.
Re: MySQL Ban List -
Grim_ - 11.09.2018
https://sampforum.blast.hk/showthread.php?tid=56564
Go through the thread and look up the documentation. It won't help you if we simply hand you the answer.