SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/09/2018, 06:39 PM   #1
NoteND
Huge Clucker
 
Join Date: May 2016
Posts: 214
Reputation: 3
Default MySQL Ban List

Hey!

How do you make this work?

https://pastebin.com/8iDNMVXb

Im guessing you know what I want to do
NoteND is offline   Reply With Quote
Old 10/09/2018, 12:03 AM   #2
AmirSavand
Big Clucker
 
AmirSavand's Avatar
 
Join Date: Sep 2018
Location: Behind Schedule
Posts: 79
Reputation: 8
Default Re: MySQL Ban List

Provide more detail, what errors do you get?
AmirSavand is offline   Reply With Quote
Old 10/09/2018, 08:59 AM   #3
Banditul18
Huge Clucker
 
Join Date: Nov 2014
Location: Brasov,Romania
Posts: 402
Reputation: 32
Default Re: MySQL Ban List

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
Banditul18 is offline   Reply With Quote
Old 11/09/2018, 07:05 AM   #4
Infin1ty
Banned
 
Join Date: Feb 2018
Posts: 117
Reputation: 52
Default Re: MySQL Ban List

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 Code:
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.

Last edited by Infin1ty; 11/09/2018 at 07:43 AM.
Infin1ty is offline   Reply With Quote
Old 11/09/2018, 07:17 AM   #5
Grim_
High-roller
 
Grim_'s Avatar
 
Join Date: Sep 2008
Location: United States
Posts: 2,862
Reputation: 118
Default Re: MySQL Ban List

http://forum.sa-mp.com/showthread.php?t=56564

Go through the thread and look up the documentation. It won't help you if we simply hand you the answer.
Grim_ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ban List PCP Mysql DandyCorleone Scripting Help 7 05/01/2017 02:25 AM
[Tool/Web/Other] Ban List v1 - View an active ban list [PHP] [MYSQL] MD5 Tools and Files 11 30/06/2015 11:17 PM
MYSQL List accounts Blackazur Scripting Help 1 26/05/2013 08:14 AM
Getting a List from a MySQL table Neil. Scripting Help 1 15/02/2013 06:09 AM
Help With MySQL Ban List Script jeff223 Help Archive 21 09/08/2009 05:03 PM


All times are GMT. The time now is 07:35 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.