Raised This Month: $ Target: $400
 0% 

How to return an integer from a function?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Minimum
Senior Member
Join Date: Jun 2006
Old 11-25-2006 , 14:32   How to return an integer from a function?
Reply With Quote #1

Nothing in the tutorial section covers this. So I thought I should post here. I need to know how to make a function return an integer. Heres what I have so far but it will not work. I am really flying blind without any proper documentation on this.

Code:
/*      Test Integer Function */  public _testsqlint(table[],index[],authid[],equals[16],output) {     if(dbc < SQL_OK) return 0     format(query,255,"SELECT %s FROM %s WHERE steamid = '%s'",index,table,authid)     result = dbi_query(dbc,query)     for(new i=0;i < 16;i++) {         if(equals[i] == result) output = 1     }     if(output == 0) {         dbi_free_result(result)         format(query,255,"SELECT * FROM admins WHERE steamid = '%s' AND full_access = 1",authid)         result = dbi_query(dbc,query)         if(dbi_nextrow(result) > 0) output = 1     }     dbi_free_result(result)     return output } public testinteger(id) {     new sc_output, authid[32], stuff[16]     stuff[0] = 1     stuff[1] = 4     stuff[2] = 5     get_user_authid(id,authid,31)     _testsqlint("races","raceid",authid,stuff,sc_output)     server_print("Stuff[0] = %i ^n Stuff[1] = %i ^n Stuff[2] = %i ^n sc_output[i] = %i ^n sc_output[s] = %s ^n authid = %s",stuff[0],stuff[1],stuff[2],sc_output,sc_output,authid) }

I had my friend try the command in the server and it printed this to the server console.

Code:
 Stuff[0] = 1
 Stuff[1] = 4
 Stuff[2] = 5
 sc_output[i] = 0
 sc_output[s] =
 authid = STEAM_0:0:1632207
Minimum is offline
Send a message via AIM to Minimum Send a message via MSN to Minimum
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 11-25-2006 , 14:59   Re: How to return an integer from a function?
Reply With Quote #2

It already returns an integer, you just need to grab it.

Code:
new returnValue = _testsqlint("races","raceid",authid,stuff,sc_output)
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Minimum
Senior Member
Join Date: Jun 2006
Old 11-25-2006 , 20:14   Re: How to return an integer from a function?
Reply With Quote #3

Gah, should of known. Thanks.
Minimum is offline
Send a message via AIM to Minimum Send a message via MSN to Minimum
Reply


Thread Tools
Display Modes

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 06:56.


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