Raised This Month: $51 Target: $400
 12% 

Solved SQL Max (Safe) Columns (Save/Load Data)


Post New Thread Reply   
 
Thread Tools Display Modes
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 11-06-2017 , 12:58   Re: SQL Max (Safe) Columns (Save/Load Data)
Reply With Quote #11

To show the skins in a menu, you don't have to play with player_weapons table, use only weapon_types or whatever you name it.

P.S. Or you want to show in that menu only the weapons that player own?

Last edited by KiLLeR.; 11-06-2017 at 13:00.
KiLLeR. is offline
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-06-2017 , 13:52   Re: SQL Max (Safe) Columns (Save/Load Data)
Reply With Quote #12

Yeah that's it, I want to show the skins that the player owns.
TheWhitesmith is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 11-06-2017 , 14:26   Re: SQL Max (Safe) Columns (Save/Load Data)
Reply With Quote #13

-- First get the player id:
DECLARE @playerId = SELECT Id FROM players
WHERE SteamId = 'STEAM_:.....'

-- Get all skins which those player has:
SELECT * FROM player_weapons
INNER JOIN weapon_name ON weapon_name .Id = player_weapons.weaponId
WHERE player_weapons.playerId = @playerId

You need to have foreign keys between tables.

Last edited by KiLLeR.; 11-06-2017 at 14:28.
KiLLeR. is offline
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-06-2017 , 14:32   Re: SQL Max (Safe) Columns (Save/Load Data)
Reply With Quote #14

This makes sense, I think pawn scripting stops here so I should go & learn about SQL commands.
Thank you for your help, really appreciate it!
TheWhitesmith is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 11-07-2017 , 17:22   Re: SQL Max (Safe) Columns (Save/Load Data)
Reply With Quote #15

What about storing every skin in 1 column as string and explode() (not sure if it's called like that in AMXX) that string in plugin, so you can retrieve amount of certain skin player has
__________________
Airkish is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-07-2017 , 17:35   Re: SQL Max (Safe) Columns (Save/Load Data)
Reply With Quote #16

Quote:
Originally Posted by Airkish View Post
What about storing every skin in 1 column as string and explode() (not sure if it's called like that in AMXX) that string in plugin, so you can retrieve amount of certain skin player has
No.
klippy is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 11-08-2017 , 02:23   Re: SQL Max (Safe) Columns (Save/Load Data)
Reply With Quote #17

Quote:
Originally Posted by Airkish View Post
What about storing every skin in 1 column as string and explode() (not sure if it's called like that in AMXX) that string in plugin, so you can retrieve amount of certain skin player has
this is even worse than what OP originally did

also, a JSON module has been added to amxx, so at least use that if you want to store aggregate data in a single cell; but please think it through because there are few scenarios where this is really the best solution
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 11-08-2017 , 17:48   Re: SQL Max (Safe) Columns (Save/Load Data)
Reply With Quote #18

Can you tell me why it's bad?
Because I have my skins stored like that and there's no issues
__________________
Airkish is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 11-08-2017 , 18:52   Re: SQL Max (Safe) Columns (Save/Load Data)
Reply With Quote #19

Quote:
Originally Posted by Airkish View Post
Can you tell me why it's bad?
Because I have my skins stored like that and there's no issues
I can, but I'd rather give an already written post by someone who knows much more about this than me
have a read here: https://stackoverflow.com/a/3653574/4478454
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever 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 19:40.


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