[Plugin] [REL] MySQL Plugin (Now on github!)

Quote:
Originally Posted by Calgon
Посмотреть сообщение
The source code for R7 has been available for a while, it has only just been compiled for Windows and with a bug fix that was reported.
It took too much longer for 1 bug fix don't you think?
Reply

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
I cannot show you my way because it's very different and it's untested. But really, I'm not that what you think I am. Again thanks for the example.
Then why even mention you have something better that you don't even wish to share? this my code & concept has been tested and running properly on the server with minimal changes for over 2 years.
Reply

I'm struggling to get the login and registering working now. I'll try my best to fix it myself!
Reply

Hello. I have Debian 6 installed. When I start the server, following messages show up:

Quote:

[22:57:12] Error: Function not registered: 'SSCANF_Init'
[22:57:12] Error: Function not registered: 'SSCANF_Join'
[22:57:12] Error: Function not registered: 'SSCANF_Leave'
[22:57:12] Error: Function not registered: 'Streamer_RegisterInterface'
[22:57:12] Error: Function not registered: 'Streamer_AddPlayer'
[22:57:12] Error: Function not registered: 'Streamer_RemovePlayer'
[22:57:12] Error: Function not registered: 'Streamer_VerifyPickup'
[22:57:12] Error: Function not registered: 'Streamer_VerifyCheckpoint'
[22:57:12] Error: Function not registered: 'mysql_debug'
[22:57:12] Error: Function not registered: 'mysql_connect'
[22:57:12] Error: Function not registered: 'mysql_ping'
[22:57:12] Error: Function not registered: 'mysql_query'
[22:57:12] Error: Function not registered: 'mysql_close'
[22:57:12] Error: Function not registered: 'mysql_store_result'
[22:57:12] Error: Function not registered: 'sscanf'
[22:57:12] Error: Function not registered: 'mysql_num_rows'
[22:57:12] Error: Function not registered: 'mysql_fetch_row_format'
[22:57:12] Error: Function not registered: 'mysql_free_result'
[22:57:12] Error: Function not registered: 'mysql_real_escape_string'
[22:57:12] Error: Function not registered: 'mysql_insert_id'
[22:57:12] Error: Function not registered: 'GetGVarFloat'
[22:57:12] Error: Function not registered: 'GetGVarInt'
[22:57:12] Error: Function not registered: 'SetGVarInt'
[22:57:12] Error: Function not registered: 'SetGVarString'
[22:57:12] Error: Function not registered: 'SetGVarFloat'
[22:57:12] Error: Function not registered: 'GetGVarString'
[22:57:12] Error: Function not registered: 'DeleteGVar'
[22:57:12] Error: Function not registered: 'mysql_retrieve_row'
[22:57:12] Error: Function not registered: 'CreateDynamic3DTextLabel'
[22:57:12] Error: Function not registered: 'UpdateDynamic3DTextLabelText'
[22:57:12] Error: Function not registered: 'DestroyDynamic3DTextLabel'
[22:57:12] Error: Function not registered: 'CreateDynamicObject'
[22:57:12] Error: Function not registered: 'GetDynamicObjectPos'
[22:57:12] Error: Function not registered: 'DestroyDynamicObject'
[22:57:12] Error: Function not registered: 'IsValidDynamic3DTextLabel'
[22:57:12] Error: Function not registered: 'CreateDynamicCP'
[22:57:12] Error: Function not registered: 'CreateDynamicMapIcon'

What's wrong? How do I compile the plugin properly?
Reply

It looks like MySQL plugin is not the only one that doesn't load. In fact there are at least 4.

So open up your server log file and see if any plugins load at all. Also, see if your server.cfg has a valid plugins line (plugins suffixed with .so) and if the plugin files actually exist in the /plugins/ folder.
Reply

I got all the plugin files in the folder, the plugin string in server.cfg is as follows:
Quote:

plugins nativechecker.so mysql.so streamer.so sscanf.so gvar.so

I tried different plugin versions, none of it works properly though. It seems it depends on Linux distributive heavily.
So how do I compile it for Debian 6 myself?
Thank you.
Reply

You need to have some dependencies installed on the machine. I think you can do this using apt-get install on Debian.

Quoting the main post:
Quote:

Linux: Install gcc, gpp & mysql-client and type "make" in the source files folder.

Reply

Where's "mysql.so" file?
I have got a Windows XP but i want lauch your mysql plugins on linux server.
Reply

How to check is server connected to the database?
Even if I enter wrong user/pass, mysql_ping() will work because it's connected to the MySQL server.
Reply

If you enter wrong DB, debug will write this:

Код:
[21:20:43] >> mysql_connect(localhost, root, wrong_db, ******) on port 3306
[21:20:43] CMySQLHandler::CMySQLHandler() - constructor called.
[21:20:43] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "wrong_db" | Username: "root"
[21:20:43] CMySQLHandler::Connect() - Unknown database 'wrong_db' (Error ID: 1049)
[21:20:43] >> mysql_ping( Connection handle: 1 )
If you try to execute a query after failed connection, it will write "Dead connection".
So, you can use mysql_ping() because it isn't connected to a MySQL server.




pawn Код:
if(mysql_ping() == -1) print("Connection failed");
It works for wrong username/pass AND wrong DB.
Reply

The download link for R7 version doesn't work. Can you reupload the R7 version?
Reply

Here's something that I wrote yesterday to circumvent this problem. Requires you to have the cache enabled for that particular select query!

pawn Код:
stock mysql_fetch_int(connectionHandle)
{
    new
        rows,
        fields,
        storage[12];
       
    cache_get_data(rows, fields, connectionHandle);
   
    if(!rows)
        return cellmin;
       
    cache_get_row(0, 0, storage, connectionHandle);
    return strval(storage);
}

stock Float:mysql_fetch_float(connectionHandle)
{
    new
        rows,
        fields,
        storage[12];

    cache_get_data(rows, fields, connectionHandle);

    if(!rows)
        return Float:cellmin;

    cache_get_row(0, 0, storage, connectionHandle);
    return floatstr(storage);
}
Not yet tested, so use at your own risk!
Reply

Why is mysql_function_query the only function where you need to put in the connectionHandle?
Why not just the same as the other functions, that you can choose if you want to use a connectionHandle?
Reply

Because we have a possibility to use custom function and custom parameters (format), so script can't make sense between parameters and connection handle. That's the reason why is connection handle on first place.
Reply

Quote:
Originally Posted by Pooh7
Посмотреть сообщение
Because we have a possibility to use custom function and custom parameters (format), so script can't make sense between parameters and connection handle. That's the reason why is connection handle on first place.
Ah, i see.
Thanks for the answer.
Reply

Quote:
Originally Posted by kurta999
Посмотреть сообщение
pawn Код:
mysql_store_result();
    mysql_fetch_row(name);
    iID = strval(name);
    mysql_free_result();
Or use chace.
I just don't understand this

pawn Код:
mysql_fetch_row(name);
    iID = strval(name);
for what use is name, is it name of field or?
Reply

Hello guys. I just have a question: what is a threaded and a non-threaded script?
Reply

Quote:
Originally Posted by ThomasTailor93
Посмотреть сообщение
Hello guys. I just have a question: what is a threaded and a non-threaded script?
that doesn't exist, only threaded and non-threaded querys, it's basiclly querys with callback
Reply

Quote:
Originally Posted by System64
Посмотреть сообщение
I just don't understand this

pawn Код:
mysql_fetch_row(name);
    iID = strval(name);
for what use is name, is it name of field or?
// After query..
mysql_store_result();
mysql_fetch_row(name); // Fetch the row into the string, which is "name". This currently same as fetch_int(), but this fetch the row into the string and not return with int.

https://sampwiki.blast.hk/wiki/MySQL#mysql_fetch_row_format
Reply

thanks for reply, my friend told me that before
Now I have to fix problem with sscanf and than I'll test code you gave me!
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)