Raised This Month: $ Target: $400
 0% 

amxmodx 1.01 plugin using dbi


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
onosrider
Member
Join Date: Jul 2005
Old 09-11-2005 , 20:51   amxmodx 1.01 plugin using dbi
Reply With Quote #1

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
onosrider is offline
{NM}Jason
AMX Mod X Beta Tester
Join Date: Mar 2004
Location: Texas
Old 09-11-2005 , 21:11  
Reply With Quote #2

Sql has and will be updated in 1.60 > look in CVS and compile the new ver.
__________________
http://forums.alliedmods.net/showthr...396#post451396
Quote:
Originally Posted by BAILOPAN View Post
Shortly after posting that image, Jason crushed the truck into a ball with his hands, and tossed it over his shoulder.
{NM}Jason is offline
Send a message via ICQ to {NM}Jason Send a message via AIM to {NM}Jason Send a message via MSN to {NM}Jason Send a message via Yahoo to {NM}Jason
onosrider
Member
Join Date: Jul 2005
Old 09-11-2005 , 22:21  
Reply With Quote #3

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.
onosrider is offline
{NM}Jason
AMX Mod X Beta Tester
Join Date: Mar 2004
Location: Texas
Old 09-12-2005 , 00:16  
Reply With Quote #4

sql in . 1.01 dosent work quite well
__________________
http://forums.alliedmods.net/showthr...396#post451396
Quote:
Originally Posted by BAILOPAN View Post
Shortly after posting that image, Jason crushed the truck into a ball with his hands, and tossed it over his shoulder.
{NM}Jason is offline
Send a message via ICQ to {NM}Jason Send a message via AIM to {NM}Jason Send a message via MSN to {NM}Jason Send a message via Yahoo to {NM}Jason
BAILOPAN
Join Date: Jan 2004
Old 09-12-2005 , 00:53  
Reply With Quote #5

you're not passing a column to dbi_field
__________________
egg
BAILOPAN is offline
onosrider
Member
Join Date: Jul 2005
Old 09-12-2005 , 15:15  
Reply With Quote #6

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 is offline
onosrider
Member
Join Date: Jul 2005
Old 09-16-2005 , 02:00  
Reply With Quote #7

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 }
onosrider is offline
Reply



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

Forum Jump


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


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