AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved query question (https://forums.alliedmods.net/showthread.php?t=332371)

lexzor 05-07-2021 21:04

query question
 
Hello again. Sorry for spaming with posts.

I have this query:
PHP Code:

formatex(szQuerycharsmax(szQuery), "UPDATE `%s` SET `frags` = '15' , `deaths` = '5' , `headshots` = '8' , `score` = '4' , `lastvisit` = '%s' , `total_played_time` = '%s' WHERE `name` = '%s'",
        
g_szTables[5],/* g_iPlayersInfo[id][Frags], g_iPlayersInfo[id][Deaths], g_iPlayersInfo[id][Headshots], g_iPlayersInfo[id][Score],*/ g_iPlayersInfo[id][LastVisit], g_iPlayersInfo[id][PlayedTime], g_iPlayersInfo[id][Name]) 

and this is how i create the table where i want to introduce that data from query
PHP Code:

"( `id` INT(11) NOT NULL AUTO_INCREMENT , `name` VARCHAR(36) NOT NULL , `ipaddress` VARCHAR(36) NOT NULL , `steamid` VARCHAR(36) NOT NULL , `frags` INT(11) NOT NULL , `deaths` INT(11) NOT NULL , `headshots` INT(11) NOT NULL , `score` INT(11) NOT NULL , `played_time` VARCHAR(33) NOT NULL , PRIMARY KEY (`id`))" 

the problem is that the data from columns frags, deaths, headshots, score don t update just the last 2 of them. i tried with numbers (as you can see) but same thing. Some ideas?

Bugsy 05-07-2021 21:15

Re: query question
 
Try removing the quotes around the numbers.

Shadows Adi 05-08-2021 04:00

Re: query question
 
Try to create the table without declaring the INTs size, since they are 4 bytes signed:
PHP Code:

"( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(36) NOT NULL , `ipaddress` VARCHAR(36) NOT NULL , `steamid` VARCHAR(36) NOT NULL , `frags` INT NOT NULL , `deaths` INT NOT NULL , `headshots` INT NOT NULL , `score` INT NOT NULL , `played_time` VARCHAR(33) NOT NULL)" 


lexzor 05-08-2021 12:23

Re: query question
 
none of them worked, but somehow works with numbers (15, 5 or what ever), but don't work with %i

maybe there isn t enough time for native get_user_frags/get_user_deaths to stock the data into variable ?

Bugsy 05-08-2021 12:30

Re: query question
 
Output your query as a string to verify how it's reaching the SQL module, and go from there. Doubtful it's a timing issue.

lexzor 05-08-2021 13:27

Re: query question
 
ok i found the problem: i use this function in client_disconnected and the function can't take users frags and deaths because he disconnected. is there any solution to create a prethink of client_disconnected to get the data?

Shadows Adi 05-08-2021 14:37

Re: query question
 
Use fakemeta's FM_ClientDisconnect forward, this should be called before any AMXX module, so client isn't marked as disconnected.

Bugsy 05-08-2021 14:39

Re: query question
 
The values are usually still accessible at client_disconnect(). If the above doesn't work, just store the values for each player in a variable, update kills/deaths at DeathMsg() for killer & victim.

lexzor 05-09-2021 12:13

Re: query question
 
I used DeathMsg to store their data.
Thanks.


All times are GMT -4. The time now is 02:38.

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