Raised This Month: $ Target: $400
 0% 

How to get unique table id?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jonatat
Senior Member
Join Date: Dec 2017
Old 06-08-2018 , 08:17   How to get unique table id?
Reply With Quote #1

Hello folks. I want to made custom info. Like current score in server.

I have table row with id 24 (like example. every time then maps reload its create a new id)

My code looks like that:

PHP Code:
public UpdateGameLIVE(id)
{
new 
szQuery[3800];

formatexszQuery3799"UPDATE `matches` SET `left_score` = '%d', `right_score` = '%d' WHERE id = '%d';"scoreCTSscoreTSid);
SQL_ThreadQueryg_hTuple"QuerySetData"szQuery);

But its does not working. Sorry for bad english. Any help?
jonatat is offline
jonatat
Senior Member
Join Date: Dec 2017
Old 06-08-2018 , 10:55   Re: How to get unique table id?
Reply With Quote #2

PHP Code:
public UpdateGameLIVE(id)
{
new 
szQuery[3800];
new 
match_id SQL_GetInsertId(szQuery);

formatexszQuery3799"UPDATE `matches` SET `left_score` = '%d', `right_score` = '%d' WHERE match_id = '%d';"scoreCTSscoreTSmatch_id);
SQL_ThreadQueryg_hTuple"QuerySetData"szQuery);

But getting error then compiling. Any ideas?

Last edited by jonatat; 06-08-2018 at 10:55.
jonatat is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-08-2018 , 11:44   Re: How to get unique table id?
Reply With Quote #3

Give us informations about this compiling error that you're getting.
__________________








CrazY. is offline
jonatat
Senior Member
Join Date: Dec 2017
Old 06-08-2018 , 11:49   Re: How to get unique table id?
Reply With Quote #4

Quote:
Originally Posted by CrazY. View Post
Give us informations about this compiling error that you're getting.
Thanks for answer CrazY!

Compiling dont giving any error after update:

PHP Code:
public UpdateGameLIVE(id)
{
new 
szQuery[3800];
new 
match_id SQL_GetInsertIdg_hTuple );

formatexszQuery3799"UPDATE `matches` SET `left_score` = '%d', `right_score` = '%d' WHERE match_id = '%d';"scoreCTSscoreTSmatch_id);
SQL_ThreadQueryg_hTuple"QuerySetData"szQuery);

But now i'm getting error in server:
PHP Code:
[MySQLInvalid query handle
PHP Code:
[AMXXRun time error 10native error (native "SQL_GetInsertId"
jonatat is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-08-2018 , 11:53   Re: How to get unique table id?
Reply With Quote #5

Try this.

Code:
formatex( szQuery, 3799, "UPDATE matches SET left_score = '%i', right_score = '%i' WHERE match_id = '%i';", scoreCTS, scoreTS, match_id);

But the real problem is in your g_hTuple. Are you sure the connection was made successfully? Also, SQL_GetInsertId will return 0 if you not use INSERT query before.
__________________









Last edited by CrazY.; 06-08-2018 at 11:56.
CrazY. is offline
jonatat
Senior Member
Join Date: Dec 2017
Old 06-08-2018 , 12:02   Re: How to get unique table id?
Reply With Quote #6

Quote:
Originally Posted by CrazY. View Post
Try this.

Code:
formatex( szQuery, 3799, "UPDATE matches SET left_score = '%i', right_score = '%i' WHERE match_id = '%i';", scoreCTS, scoreTS, match_id);

But the real problem is in your g_hTuple. Are you sure the connection was made successfully? Also, SQL_GetInsertId will return 0 if you not use INSERT query before.
Thanks CrazY. My insert into looks like that:

PHP Code:
formatex(szQuery3799"INSERT INTO matches (`match_id`, `map`, `played_at`, `left_score`, `right_score`, `state`, `server`, `left_team_id`, `right_team_id`, `game_id`) VALUES ('%s', '%s', NOW(), '0', '0', '0', 'cs.bigmatches.me', '1', '1', '3');"match_idmap_name); 
Also g_hTuple:

PHP Code:
public MySQLx_Init()
{    
g_hTuple SQL_MakeDbTuple(GAME_HOSTGAME_USERGAME_PASSWORDGAME_DATABASE);

for(new 
0sizeof szTablesi++)
{
SQL_ThreadQuery(g_hTuple"QuerySetData"szTables[i]);
}


Last edited by jonatat; 06-08-2018 at 12:03.
jonatat is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-08-2018 , 12:00   Re: How to get unique table id?
Reply With Quote #7

Show full code
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-08-2018 , 12:57   Re: How to get unique table id?
Reply With Quote #8

Hm... that's weird. If you do not want to share the source code with us, I suggest you to take a look at this.

https://forums.alliedmods.net/showth...p?t=172936#SQL
__________________








CrazY. is offline
jonatat
Senior Member
Join Date: Dec 2017
Old 06-09-2018 , 07:26   Re: How to get unique table id?
Reply With Quote #9

Quote:
Originally Posted by Natsheh View Post
Show full code
Quote:
Originally Posted by CrazY. View Post
Hm... that's weird. If you do not want to share the source code with us, I suggest you to take a look at this.

https://forums.alliedmods.net/showth...p?t=172936#SQL
Attached
Attached Files
File Type: sma Get Plugin or Get Source (newone.sma - 462 views - 49.8 KB)

Last edited by jonatat; 06-09-2018 at 07:27.
jonatat 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 04:37.


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