Retrieve data from sql
Hi, could anyone help me with a piece of code for a RANK function?
For example, I have this top function: PHP Code:
PHP Code:
"[AMXX] Your rank is m/n with a data1 b data2 c data3 d data4" Where 'm' is the current rank of the player (or position in the DB, I'm not sure how it would come), 'n' is the total entries in the DB, and a, b, c, d are other integer values. |
Re: Retrieve data from sql
Hi. Do you have the code for "CREATE TABLE ..." query? Can you post it?
|
Re: Retrieve data from sql
Quote:
PHP Code:
|
Re: Retrieve data from sql
1 Attachment(s)
Its fine, try this. Do you know how to re-compile .sma file?
You need to edit this part of the code: #define TABLE "zm_top" Replace "zm_top" with your actual table name. You should have a definition '#define TABEL' inside your code which has the name of your table, then recompile. After that it 'should' work. Once running, write amx_rank in console, or say /rank This will do a full table scan on each command, therefore I've added antispamming. In non-technical terms, if your database has 100s of thousands of rows, this command will be rather slow and might even cause lag if the server is really bad. However I doubt your database has that many players so it should be fine. If you run into any performance issues, we can optimize it further. But for now this should do. You may edit the displayed chat message to your liking. This plugin will use connection info specified in amxmodx/configs/sql.cfg: amx_sql_host "127.0.0.1" amx_sql_user "root" amx_sql_pass "" amx_sql_db "amx" amx_sql_type "mysql" |
Re: Retrieve data from sql
Quote:
|
Re: Retrieve data from sql
So, I've looked over the code. I don't want to use "SQL_MakeStdTuple()" because I'm using SQLite and it doesn't help me that much.
Returning to the code, what you gave me doesn't work. I just want a simple function to retrieve the player's position from MySQL and its related information, that's all. |
Re: Retrieve data from sql
Have you tried going to amxmodx/configs/sql.cfg, and changing the driver type from "mysql" to -> "sqlite"?
Code:
amx_sql_host "<fill in your actual host>" Quote:
SQL_MakeStdTuple is not the issue, as the name of the library <sqlx> suggests, its supposed to work with both MySQL and SQLite. Saying "it doesn't work" is not very helpful. If you have issues, provide any error logs with debug turned on. In your plugins.ini: Code:
zm_rank.amxx debug |
Re: Retrieve data from sql
This is the error
PHP Code:
This is what I currently have in the script: PHP Code:
PHP Code:
|
Re: Retrieve data from sql
You're trying to integrate the plugin I just gave you inside your own code, you don't need to do all that. You're better off just using the plugin that I posted, and fixing your sql.cfg
The error however is caused by a lack of line breaks. Look closer at the code I posted:
Spoiler
There's a line break character '\' which is used to continue a line of code on the next line without breaking the syntax. Since you've removed all of them, the syntax breaks, and throws this error. Its saying "You have no rank", because the query doesn't return any results due to the broken syntax. |
Re: Retrieve data from sql
I attached the backslash as well (https://prnt.sc/36U_6dAPr96T), but I don't know why it wasn't attached. I don't want another plugin; I want it to be integrated into what I already have
|
All times are GMT -4. The time now is 18:47. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.