AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to return an integer from a function? (https://forums.alliedmods.net/showthread.php?t=47750)

Minimum 11-25-2006 14:32

How to return an integer from a function?
 
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


XxAvalanchexX 11-25-2006 14:59

Re: How to return an integer from a function?
 
It already returns an integer, you just need to grab it.

Code:
new returnValue = _testsqlint("races","raceid",authid,stuff,sc_output)

Minimum 11-25-2006 20:14

Re: How to return an integer from a function?
 
Gah, should of known. Thanks.


All times are GMT -4. The time now is 06:56.

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