This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

MYSQL: Problems with understanding the dbi_nextrow..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
harbu
Senior Member
Join Date: Aug 2004
Location: Finland
Old 10-27-2004 , 11:02   MYSQL: Problems with understanding the dbi_nextrow..
Reply With Quote #1

Ok, im trying to convert twilight suzukas buggy The Specialists Economy mod amxx conversion into a working stable version. I was doing ok going to do the dbi_nextrow function, i went to check the amxmodx function library too see if anything is different and i saw this note "Unlike the AMX Mod SQL interfaces, you pass a result handle instead of an SQL handle. "
For backwards compatibility, if nothing is specifed, it will default to a global pointer.
Returns 0 on failure or end of result list.

Im not positvily sure what this means?Do u have to create a new result variable at the beginning? Do u have to use dbi_nextrow(result)?
What u put in the result variable? The last query u made or what?
Code:
public death_msg(id) {     if(!get_cvar_num("economy_deathpenalty")) return PLUGIN_CONTINUE;     new dead = read_data(2);     new authid[33];     new amount = (get_cvar_num("economy_deathpenalty"))     amount = amount * 100     get_user_authid(dead,authid,32);     new query[256];     format(query, 255, "UPDATE money SET balance=balance-%i WHERE steamid='%s'",amount,authid);     server_print("[TSX] Sending query: %s",query);     mysql_query(mysql,query);     format(query,255,"SELECT balance FROM money WHERE steamid='%s'",authid);     mysql_query(mysql,query);     new Str[256];     if(mysql_nextrow(mysql) > 0){         mysql_getfield(mysql,1,Str,255);         new balance = str_to_num(Str);

Im very sorry if this has been asked/mentioned somewhere already...
harbu is offline
Send a message via MSN to harbu
devicenull
Veteran Member
Join Date: Mar 2004
Location: CT
Old 10-27-2004 , 13:15  
Reply With Quote #2

Look
here
and
here

If they dont answer your questions, let me know
__________________
Various bits of semi-useful code in a bunch of languages: http://code.devicenull.org/
devicenull is offline
harbu
Senior Member
Join Date: Aug 2004
Location: Finland
Old 10-27-2004 , 16:16  
Reply With Quote #3

ok, well i think i got some information from those. Heres how i think it should go, probaly wrong but please check...
Code:
public death_msg(id)    {     if(!get_cvar_num("economy_deathpenalty")) return PLUGIN_CONTIUNE     new dead = read_data(2)     new authid[33]     new amount = (get_cvar_num("economy_deathpenalty"))     amount = amount *100     get_user_authid(dead,authid,32)     new query[256]     format(query, 255, "UPDATE money SET balance=balance-%i WHERE steamid='%s'",amount,authid)     server_print("[TEM] Sending query: %s", query)     result = dbi_query(dbc,query)     new Str[256]     if(dbi_nextrow(result) > 0) {     dbi_field(result,1,Str,255)
harbu is offline
Send a message via MSN to harbu
harbu
Senior Member
Join Date: Aug 2004
Location: Finland
Old 10-28-2004 , 11:31  
Reply With Quote #4

*BUMP*
harbu is offline
Send a message via MSN to harbu
devicenull
Veteran Member
Join Date: Mar 2004
Location: CT
Old 10-29-2004 , 11:54  
Reply With Quote #5

That looks fine.
Just make sure dbc is a connection to a database
__________________
Various bits of semi-useful code in a bunch of languages: http://code.devicenull.org/
devicenull 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 11:54.


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