SA-MP Forums Archive
Loading bans not working - 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: Loading bans not working (/showthread.php?tid=468499)



Loading bans not working - damian123 - 08.10.2013

So, when my gamemode starts it loads the Bans from MySql, and I can check that it starts loading in the server log, but it never loads. And also the gamemode doesn't load afterwards, the gamemode is set to "Unknown".

Here is the LoadBans code:
pawn Код:
forward LoadBans();
public LoadBans()
{
    new arrCoords[4][64];
    new row[256];
    new string[64];
    new idx;
    printf("[MYSQL]: Loading bans from MYSQL (from %s).", SQL_DB);
    while (idx < sizeof(BanInfo))
    {
        format(string, sizeof(string), "SELECT * FROM `bans` WHERE `ID` = %d", idx);
        mysql_query_ex(string);
        mysql_store_result();
        if(mysql_num_rows() > 0)
        {
            mysql_fetch_row(row);
            split(row, arrCoords, '|');
            mysql_free_result();
            strmid(BanInfo[idx][BanInfoIP], arrCoords[1], 0, strlen(arrCoords[1]), 19);
            BanInfo[idx][BanInfoTS] = strval(arrCoords[2]);
            strmid(BanInfo[idx][BanInfoReason], arrCoords[3], 0, strlen(arrCoords[3]), 128);
        }
        else
        {
            BanInfo[idx][BanInfoTS]=0;
        }
        if(BanInfo[idx][BanInfoTS]>getdate())
        {
            BanInfo[idx][BanInfoActive]=1;
        }
        mysql_free_result();
        idx++;
    }
    printf("[MYSQL]: Bans loaded from MYSQL (from %s).", SQL_DB);
    return 1;
}
And here is the server log:
Код:
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3x-R2, ©2005-2013 SA-MP Team

[21:52:20] 
[21:52:20] Server Plugins
[21:52:20] --------------
[21:52:20]  Loading plugin: nativechecker.so
[21:52:20]   Loaded.
[21:52:20]  Loading plugin: mysql.so
[21:52:20]  >> plugin.mysql: R34 successfully loaded.
[21:52:20]   Loaded.
[21:52:20]  Loading plugin: streamer.so
[21:52:20] 

*** Streamer Plugin v2.6.1 by Incognito loaded ***

[21:52:20]   Loaded.
[21:52:20]  Loading plugin: sscanf.so
[21:52:20] 

[21:52:20]  ===============================

[21:52:20]       sscanf plugin loaded.     

[21:52:20]          Version:  2.8.1        

[21:52:20]    © 2012 Alex "******" Cole  

[21:52:20]  ===============================

[21:52:20]   Loaded.
[21:52:20]  Loaded 4 plugins.

[21:52:20] 
[21:52:20] Filterscripts
[21:52:20] ---------------
[21:52:20]   Loaded 0 filterscripts.

[21:52:20]    Error: Function not registered: 'cache_get_row_count'
[21:52:20]    Error: Function not registered: 'cache_get_field_content'
[21:52:20]    Error: Function not registered: 'cache_get_field_count'
[21:52:20]    Error: Function not registered: 'cache_get_row'
[21:52:20]    Error: Function not registered: 'Streamer_CallbackHook'
[21:52:20]    Error: Function not registered: 'SSCANF_Init'
[21:52:20]    Error: Function not registered: 'SSCANF_Join'
[21:52:20]    Error: Function not registered: 'SSCANF_Leave'
[21:52:20]    Error: Function not registered: 'mysql_escape_string'
[21:52:20]    Error: Function not registered: 'mysql_connect'
[21:52:20]    Error: Function not registered: 'mysql_log'
[21:52:20]    Error: Function not registered: 'CreateDynamicPickup'
[21:52:20]    Error: Function not registered: 'CreateDynamic3DTextLabel'
[21:52:20]    Error: Function not registered: 'CreateDynamicObject'
[21:52:20]    Error: Function not registered: 'DestroyDynamicObject'
[21:52:20]    Error: Function not registered: 'sscanf'
[21:52:20]    Error: Function not registered: 'UpdateDynamic3DTextLabelText'
[21:52:20]    Error: Function not registered: 'DestroyDynamic3DTextLabel'
[21:52:20]    Error: Function not registered: 'DestroyDynamicPickup'
[21:52:20]  
[21:52:20]  ======================================= 
[21:52:20]  |                                     | 
[21:52:20]  |        YSI version 1.03.0011        | 
[21:52:20]  |        By Alex "******" Cole        | 
[21:52:20]  |                                     | 
[21:52:20]  |  Checking the latest YSI version..  | 
[21:52:20]  |                                     | 
[21:52:20]  ======================================= 
[21:52:20]  
[21:52:20] [MYSQL]: Loading bans from MYSQL (from samp).
[21:52:20] EL-RP
[21:52:20] Number of vehicle models: 0
[21:52:21]  
[21:52:21]  ========================================== 
[21:52:21]  |                                        | 
[21:52:21]  |  A new version (v3.09.0684) of YSI is  | 
[21:52:21]  |            available from:             | 
[21:52:21]  |                                        | 
[21:52:21]  |     www.y-less.com/YSI/YSI_1.0.zip     | 
[21:52:21]  |                                        | 
[21:52:21]  | Changelog:                             | 
[21:52:21]  |                                        | 
[21:52:21]  |   1.04.0000:                           | 
[21:52:21]  |                                        | 
[21:52:21]  |   RC 1 for YSI 3.0.  Available from:   | 
[21:52:21]  | http://www.y-less.com/YSI/YSI_3.0.rar  | 
[21:52:21]  | - includes MANY new libraries and      | 
[21:52:21]  | fixes, see                             | 
[21:52:21]  | http://forum.sa-mp.com/showthread.php? | 
[21:52:21]  | p=1425938 for more information, with   | 
[21:52:21]  | more topics and updates due over the   | 
[21:52:21]  | next few weeks.  In brief: Added       | 
[21:52:21]  | "y_inline", "y_text", "y_users",       | 
[21:52:21]  | "y_uvar", "y_svar", "y_remote";        | 
[21:52:21]  | updated "y_timers", "y_iter"; MANY     | 
[21:52:21]  | MANY fixes and tweaks in almost every  | 
[21:52:21]  | other library.                         | 
[21:52:21]  |                                        | 
[21:52:21]  |   3.00.0000:                           | 
[21:52:21]  |                                        | 
[21:52:21]  |   YSI 3.0 released!  Now includes the  | 
[21:52:21]  | "y_text" library for better messages,  | 
[21:52:21]  | and a reworked "y_classes" library.    | 
[21:52:21]  | Largely documented here                | 
[21:52:21]  | "http://forum.sa-mp.com/showthread.php | 
[21:52:21]  | ?t=321092".                            | 
[21:52:21]  |                                        | 
[21:52:21]  |   3.01.0002:                           | 
[21:52:21]  |                                        | 
[21:52:21]  |   Small fixes to "y_text" and          | 
[21:52:21]  | "y_classes".                           | 
[21:52:21]  |                                        | 
[21:52:21]  |   3.09.0684:                           | 
[21:52:21]  |                                        | 
[21:52:21]  |   Reverted to old download location.   | 
[21:52:21]  | Improved (and fixed) version checks;   | 
[21:52:21]  | added y_bitmap, y_areas, y_races,      | 
[21:52:21]  | y_zonenames, better documentation;     | 
[21:52:21]  | MANY other bug fixes - see the github  | 
[21:52:21]  | repository for more details:           | 
[21:52:21]  |                                        | 
[21:52:21]  ==========================================



Re: Loading bans not working - Jefff - 08.10.2013

Update your plugin includes

and that is better version

pawn Код:
public LoadBans()
{
    new row[256];
    new string[64];
    new idx;
    printf("[MYSQL]: Loading bans from MYSQL (from %s).", SQL_DB);
    while (idx < sizeof(BanInfo))
    {
        format(string, sizeof(string), "SELECT * FROM `bans` WHERE `ID` = %d LIMIT 1", idx);
        mysql_query_ex(string);
        mysql_store_result();
        if(mysql_num_rows() > 0)
        {
            mysql_fetch_row(row);
            sscanf(row,"p<|>{i}s[19]is[128]",BanInfo[idx][BanInfoIP],BanInfo[idx][BanInfoTS],BanInfo[idx][BanInfoReason]);
        }
        else
            BanInfo[idx][BanInfoTS] = 0;

        if(BanInfo[idx][BanInfoTS] > getdate())
            BanInfo[idx][BanInfoActive] = 1;

        mysql_free_result();
        idx++;
    }
    printf("[MYSQL]: Bans loaded from MYSQL (from %s).", SQL_DB);
    return 1;
}
use sscanf for split strings


Re: Loading bans not working - Konstantinos - 08.10.2013

Since you use R34, why don't you use threaded queries? It's must faster. Also instead of executing let's say 50 times a query to load each ban, you can execute only one and select all from the bans table. Then you can use a loop to store and do what you want.


Re: Loading bans not working - damian123 - 08.10.2013

I'm running the latest plugin and include, what can it be?
I'm editing a gamemode, I'm kinda new to this MySql thing...

Jeff, what's your Skype?


Re: Loading bans not working - [EnErGyS]KING - 08.10.2013

@damian123
Tip for you: Don't ask for skype Just ask question in forum, because another codder have similar problem like yours and if he found this thread it will not found a answer, because Jeff said solution in Skype


Re: Loading bans not working - Konstantinos - 08.10.2013

Oh. Anyways, it's always better to use the latest versions/methods because they're faster/better etc.

You can start off with that tutorial (it can be found: https://sampforum.blast.hk/showthread.php?tid=337810). From that tutorial I learned how to use BlueG's MySQL plugin (R7+), basically threaded queries.

Also a basic gamemode using threaded queries (it can be found: https://sampforum.blast.hk/showthread.php?tid=390428). They're really useful, if you really want to learn it I'm sure it won't take more than few days.


Re: Loading bans not working - damian123 - 08.10.2013

I'll do that, for sure, Konstantinos! Anyways, I still can't get the gamemode to start! Here's the new server log:
Код:
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3x-R2, ©2005-2013 SA-MP Team

[00:19:00] 
[00:19:00] Server Plugins
[00:19:00] --------------
[00:19:00]  Loading plugin: mysql.so
[00:19:00]  >> plugin.mysql: R34 successfully loaded.
[00:19:00]   Loaded.
[00:19:00]  Loading plugin: streamer.so
[00:19:00] 

*** Streamer Plugin v2.6.1 by Incognito loaded ***

[00:19:00]   Loaded.
[00:19:00]  Loading plugin: sscanf.so
[00:19:00] 

[00:19:00]  ===============================

[00:19:00]       sscanf plugin loaded.     

[00:19:00]          Version:  2.8.1        

[00:19:00]    © 2012 Alex "******" Cole  

[00:19:00]  ===============================

[00:19:00]   Loaded.
[00:19:00]  Loading plugin: nativechecker.so
[00:19:00]   Loaded.
[00:19:00]  Loaded 4 plugins.

[00:19:00] 
[00:19:00] Filterscripts
[00:19:00] ---------------
[00:19:00]   Loaded 0 filterscripts.

[00:19:00]  
[00:19:00]  ======================================= 
[00:19:00]  |                                     | 
[00:19:00]  |        YSI version 1.03.0011        | 
[00:19:00]  |        By Alex "******" Cole        | 
[00:19:00]  |                                     | 
[00:19:00]  |  Checking the latest YSI version..  | 
[00:19:00]  |                                     | 
[00:19:00]  ======================================= 
[00:19:00]  
[00:19:00] [MYSQL]: Loading bans from MYSQL (from samp).
[00:19:00] EL-RP
[00:19:00] Number of vehicle models: 0
[00:19:01]  
[00:19:01]  ========================================== 
[00:19:01]  |                                        | 
[00:19:01]  |  A new version (v3.09.0684) of YSI is  | 
[00:19:01]  |            available from:             | 
[00:19:01]  |                                        | 
[00:19:01]  |     www.y-less.com/YSI/YSI_1.0.zip     | 
[00:19:01]  |                                        | 
[00:19:01]  | Changelog:                             | 
[00:19:01]  |                                        | 
[00:19:01]  |   1.04.0000:                           | 
[00:19:01]  |                                        | 
[00:19:01]  |   RC 1 for YSI 3.0.  Available from:   | 
[00:19:01]  | http://www.y-less.com/YSI/YSI_3.0.rar  | 
[00:19:01]  | - includes MANY new libraries and      | 
[00:19:01]  | fixes, see                             | 
[00:19:01]  | http://forum.sa-mp.com/showthread.php? | 
[00:19:01]  | p=1425938 for more information, with   | 
[00:19:01]  | more topics and updates due over the   | 
[00:19:01]  | next few weeks.  In brief: Added       | 
[00:19:01]  | "y_inline", "y_text", "y_users",       | 
[00:19:01]  | "y_uvar", "y_svar", "y_remote";        | 
[00:19:01]  | updated "y_timers", "y_iter"; MANY     | 
[00:19:01]  | MANY fixes and tweaks in almost every  | 
[00:19:01]  | other library.                         | 
[00:19:01]  |                                        | 
[00:19:01]  |   3.00.0000:                           | 
[00:19:01]  |                                        | 
[00:19:01]  |   YSI 3.0 released!  Now includes the  | 
[00:19:01]  | "y_text" library for better messages,  | 
[00:19:01]  | and a reworked "y_classes" library.    | 
[00:19:01]  | Largely documented here                | 
[00:19:01]  | "http://forum.sa-mp.com/showthread.php | 
[00:19:01]  | ?t=321092".                            | 
[00:19:01]  |                                        | 
[00:19:01]  |   3.01.0002:                           | 
[00:19:01]  |                                        | 
[00:19:01]  |   Small fixes to "y_text" and          | 
[00:19:01]  | "y_classes".                           | 
[00:19:01]  |                                        | 
[00:19:01]  |   3.09.0684:                           | 
[00:19:01]  |                                        | 
[00:19:01]  |   Reverted to old download location.   | 
[00:19:01]  | Improved (and fixed) version checks;   | 
[00:19:01]  | added y_bitmap, y_areas, y_races,      | 
[00:19:01]  | y_zonenames, better documentation;     | 
[00:19:01]  | MANY other bug fixes - see the github  | 
[00:19:01]  | repository for more details:           | 
[00:19:01]  |                                        | 
[00:19:01]  ========================================== 
[00:19:01]
Now it doesn't have any Function not Registered from native checker but it still doesn't load the gamemode...


Re: Loading bans not working - Konstantinos - 08.10.2013

I've never used non-threaded queries so I'm not sure. Although, if you use the version of R34 then you can still use non-threaded queries but kind of different with the old style. So the plugin might be R34 but the include might be an older version of it and that's why it does not work. You can also check if there's something wrong to mysql log.


Re: Loading bans not working - damian123 - 08.10.2013

I'm also using the R34 include. The MySql log is clean...
God damnit, what should I do now?


Re: Loading bans not working - Konstantinos - 08.10.2013

If it doesn't contain many queries, I can convert them for you to threaded queries. Atleast I can get it working with something I know how to use. As long as you keep using non-threaded queries, I cannot help you (sorry).