MySQL Ban List
#1

Hey!

How do you make this work?

https://pastebin.com/8iDNMVXb

Im guessing you know what I want to do
Reply
#2

Provide more detail, what errors do you get?
Reply
#3

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
Reply
#4

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(playeridparams[])
{
    
//if(pInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use that command.");
   
    
new query[32];
    
mysql_format(Databasequerysizeof query"SELECT * FROM `banned`");
    
mysql_pquery(Databasequery"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 
cache_num_rows(); 0i--)
        {
            
cache_get_value_name_int(i"ID"id);
            
cache_get_value_name(i"Username"nameMAX_PLAYER_NAME);
            
cache_get_value_name(i"Reason"reason64);
            
cache_get_value_name(i"Admin"adminMAX_PLAYER_NAME);
            
cache_get_value_name(i"Date"datestring16);
            
cache_get_value_name(i"Time"timestring);
            
format(textsizeof text"ID: %d{FF9900}Username: {AFAFAF}%s {FF9900}Reason: {AFAFAF}%s {FF9900}Admin: {AFAFAF}%s Date & Time:         {AFAFAF}%s %s\n"idnamereasonadmindatestringtimestring);
            
strcat(stringtext);
        }
        
ShowPlayerDialog(playerid20000DIALOG_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(extraidCOLOR_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.
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)