Raised This Month: $ Target: $400
 0% 

Save player data to mysql


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jonatat
Senior Member
Join Date: Dec 2017
Old 06-01-2018 , 04:14   Re: Save player data to mysql
Reply With Quote #1

Quote:
Originally Posted by Bugsy View Post
You can also use REPLACE INTO if your table is created properly.

Code:
REPLACE works exactly like INSERT , except that if an old row in the table has 
the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is 
deleted before the new row is inserted. See Section 12.2.5, “ INSERT Syntax”. 
REPLACE is a MySQL extension to the SQL standard.
You can make the steam ID your primary key since this value is static.
Code:
CREATE TABLE IF NOT EXISTS tblPlayerData (SteamID VARCHAR(34) PRIMARY KEY , PlayerName VARCHAR(32), PlayTime INTEGER);

REPLACE INTO tblPlayerData (SteamID, PlayerName, PlayTime) VALUES ('STEAM123','bugsy',1);
You really helped me with PRIMARY_KEY!

Does it okay?

Code:
formatex( szQuery, 3799, "UPDATE `users` SET `steam_id` = '%s', `player_name` = '%s', `kills` = '%d', `deaths` = '%d', `headshots` = '%d', `aces` = '%d', `m_aces` = '%d', `mix_played` = '%d', `mix_lost` = '%d', `mix_won` = '%d', `mix_draw` = '%d', `points` = '%d' WHERE `steam_id` = '%s';", steam, GetSecureName(Name), pKills[id], pDeaths[id], pHeadshots[id], pAces[id], pMiniAces[id], pMixPlayed[id], pMixLost[id], pMixWon[id], pMixDraw[id], pPoints[id], steam);

Last edited by jonatat; 06-01-2018 at 04:16.
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:43.


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