AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQLx issue (https://forums.alliedmods.net/showthread.php?t=120309)

Min2liz 03-03-2010 06:32

SQLx issue
 
Hi,

I'm new on amxx scripting so please don't laugh ;)

Here is a code:

Code:

                new qcolAuth = SQL_FieldNameToNum(Query, "user")
                new qcolPass = SQL_FieldNameToNum(Query, "password")
                new qcolAccess = SQL_FieldNameToNum(Query, "access")
                new qcolPoints = SQL_FieldNameToNum(Query, "points")
               
                new AuthData[44]
                new Password[44]
                new Access[32]
                new Float:Points
               
                SQL_ReadResult(Query, qcolAuth, AuthData, sizeof(AuthData)-1)
                SQL_ReadResult(Query, qcolPass, Password, sizeof(Password)-1)
                SQL_ReadResult(Query, qcolAccess, Access, sizeof(Access)-1)
                SQL_ReadResult(Query, qcolPoints, Points,0)
               
               
               
                get_user_info(id, "_pw", pass, 31)
               
                // netinka pass
                if (!equal(Password,pass)) {
                        server_cmd("kick #%d Wrong pass", get_user_userid(id))
                }
                // Registruotas
                else {
                        PlayerXP[id] = Points
                        PlayerCon[id] = true
                        log_amx("SELECT * FROM %s WHERE `user`='%s'",SQL_TABLE,name)
                        log_amx("%s points: %i",AuthData,Points)
                }

Everything looks working, but Points all the time I get 0. In DB i write for example: 15, but after this I still get 0. No errors, no warnings don't get.


Sorry for bad english...

xPaw 03-03-2010 08:40

Re: SQLx issue
 
Try
Points = SQL_ReadResult( Query, qcolPoints );

Bugsy 03-03-2010 09:21

Re: SQLx issue
 
Quote:

Originally Posted by xPaw (Post 1106305)
Try
Points = SQL_ReadResult( Query, qcolPoints );

This should do the trick. You are attempting to retrieve an integer and the function thinks you want a string so you are getting no result.

http://www.amxmodx.org/funcwiki.php?go=func&id=1105
Code:

SQL_ReadResult ( Handle:query, column, {Float,_}:... )

Retrieves the current result.
A successful query starts at the first result, so you should not call SQL_NextRow() first.

Passing no extra params - return int
Passing one extra param - return float in 1st extra arg
Passing two extra params - return string in 1st arg, max length in 2nd


Min2liz 03-03-2010 20:05

Re: SQLx issue
 
Thanks a lot guys. Works fine now


All times are GMT -4. The time now is 08:35.

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