AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   amxmodx 1.01 plugin using dbi (https://forums.alliedmods.net/showthread.php?t=17924)

onosrider 09-11-2005 20:51

amxmodx 1.01 plugin using dbi
 
hi,

ill try to write my own plugin but im not sure about the code and it wont compile ... some errors in line 26. i downt know anything about small and the code but i hope it isent all false what i have written.

my try is a stats output for psychostats to lern and understand the code.

i hope some one will help me :)

Code:

#include <amxmodx>
#include <amxmisc>
#include <dbi>

#define mysql_host        "127.0.0.1"
#define mysql_user        "user"
#define mysql_pass        "pass"
#define mysql_db        "psychostats"

public CheckMySats(id)
{

new authid[34], username[65], rank[10]

get_user_authid ( id, authid, 33 )
get_user_name ( id, username, 65 )

dbi_connect ( mysql_host, mysql_user, mysql_pass, mysql_db )
dbi_query ( "SELECT rank FROM pstats_plr WHERE wordid='%s'", authid )

if( dbi_query == RESULT_FAILED )
  client_print(id,print_chat,"[STATS] You are not RANKED yet!", username )
  return PLUGIN_HANDLED

dbi_field( dbi_query, rank, 10 )

client_print( id, print_chat, "[STATS] %s is RANK %s", username, rank )

dbi_close()

return PLUGIN_CONTINUE
}

public plugin_init()
{
        register_plugin( "Statstest", "0.0.1", "myownhand" )
        register_clcmd( "say /rank", "CheckMySats" )
        return PLUGIN_CONTINUE
}


and the error line 26 is this part

Code:

dbi_field( dbi_query, rank, 10 )
thanks

{NM}Jason 09-11-2005 21:11

Sql has and will be updated in 1.60 > look in CVS and compile the new ver.

onosrider 09-11-2005 22:21

ok but i still use amx 1.01 on my server so i want to run it there, i cant compile for a version i dident use yet.

{NM}Jason 09-12-2005 00:16

sql in . 1.01 dosent work quite well

BAILOPAN 09-12-2005 00:53

you're not passing a column to dbi_field

onosrider 09-12-2005 15:15

does anyone have a link or simple example for a short sql query and data output? maybe 1.01 isent the best version for sql but some plugins are still working and use dbi under 1.01 so i hope i can do this too :)

onosrider 09-16-2005 02:00

after reading devicenul's sql tut and testing and whining and ... im happy to have a working sql plugin for amxx 1.01 :)

thanks :)

Code:
#include <amxmodx> #include <dbi> new Sql:dbc new Result:result public plugin_init() {     register_plugin("my stupid sql qurry","0.0.0","myhand")     register_clcmd("say /rank","CheckMySats")     register_cvar("mysql_host","127.0.0.1")     register_cvar("mysql_user","user")     register_cvar("mysql_pass","password")     register_cvar("mysql_db","psychostats")     set_task(Float:10.0,"sql_init") } public sql_init() {     new host[64], username[32], password[32], dbname[32], error[32]     get_cvar_string("mysql_host",host,64)     get_cvar_string("mysql_user",username,32)     get_cvar_string("mysql_pass",password,32)     get_cvar_string("mysql_db",dbname,32)     dbc = dbi_connect(host,username,password,dbname,error,32)     if (dbc == SQL_FAILED)         log_amx("[AMXX] RANK SQL Connection Failed") } public CheckMySats(id) {     if (dbc == SQL_FAILED)     return PLUGIN_HANDLED         new authid[32]         new username[64]         get_user_authid(id, authid, 32)         get_user_name(id, username, 64)                 result = dbi_query(dbc,"SELECT rank FROM pstats_plr WHERE worldid='%s'",authid)         for (new i=1;i<=dbi_num_rows(result);i++) {         new rank[32]         dbi_nextrow(result)         dbi_result(result,"rank",rank,32)         client_print(id,print_chat,"[RANK] %s is RANK %s",username,rank)         }     dbi_free_result(result)     return PLUGIN_HANDLED }


All times are GMT -4. The time now is 14:21.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.