Raised This Month: $ Target: $400
 0% 

SQLx help again :P


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 12-30-2008 , 15:37   SQLx help again :P
Reply With Quote #1

So basically, what I'm looking for is a way to store multiple values in a single field, and a way to read only the values I need from that field. An example field:

Code:
1337|57|96|48|32
Something like that. But I need a way to update it so that I can add new flags without disturbing previous flags, and also a way to cleanly read those values. I've seen this done, I just don't know how to do it.
Spunky is offline
Send a message via AIM to Spunky
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 12-30-2008 , 16:04   Re: SQLx help again :P
Reply With Quote #2

Why can't you use multiple fields?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 12-30-2008 , 17:37   Re: SQLx help again :P
Reply With Quote #3

Because it would look like shit. You think I haven't thought of that?
Spunky is offline
Send a message via AIM to Spunky
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 12-30-2008 , 18:01   Re: SQLx help again :P
Reply With Quote #4

Not sure what you mean but I wouldn't do that. If I am going to be managing each value separately, I would save them to a field by itself. The only reason why I would save it all to one field is if I using it for history purposes only. Personally, I would find that it looks much nicer if it was in separate fields, but it is your plugin after all.


If you really want to do this, you can use strtok
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-30-2008 , 18:42   Re: SQLx help again :P
Reply With Quote #5

What I do whenever I need that functionality is just build the table as a keytable. Then I have two fields:

Code:
key | value
-----------
    |
    |
    |
The key contains whatever I'm looking for on the user along with whatever key component of them I'm looking for:

Code:
key                  | value
--------------------------------------
STEAM_0:0:1|name     | Hawk
STEAM_0:0:1|kills    | 7
STEAM_0:0:1|deaths   | 0
etc...
Of course, you have many more rows, but it's the only way to make it truly dynamic. You can also separate them into different tables, but I think that's more cumbersome and harder to maintain. Another advantage of this method is that you can also make each key unique.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 12-30-2008 , 20:01   Re: SQLx help again :P
Reply With Quote #6

Hawk, you're familiar with Harbu's plugins, right? You've seen the items table and such right? I'm trying to do something like that, but I really don't want to dig through Harbu's horrible code.
Spunky is offline
Send a message via AIM to Spunky
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-30-2008 , 21:17   Re: SQLx help again :P
Reply With Quote #7

Quote:
Originally Posted by Spunky View Post
Hawk, you're familiar with Harbu's plugins, right? You've seen the items table and such right? I'm trying to do something like that, but I really don't want to dig through Harbu's horrible code.
Yes, I'm familiar with HWRP and I've written a few plugins for it. I also wrote a total rewrite of it called Apollo RP. I'm kinda surprised you've never heard of it. It uses the exact structure I was talking about and has an API in it which allows other plugins to use that structure for other applications.

Check it out; it's in my sig.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 12-31-2008 , 00:37   Re: SQLx help again :P
Reply With Quote #8

I know about ARP, I've just never run a server with it. Never cared to. I guess I'll check it out, but I hate combing through other people's code just for something simple...

Edit: I'm not gonna look through all of that...

Last edited by Spunky; 12-31-2008 at 00:42.
Spunky is offline
Send a message via AIM to Spunky
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-31-2008 , 00:44   Re: SQLx help again :P
Reply With Quote #9

If you're trying to write something for a TSRP server, ARP is probably the better way to go because it has a complete API making it easier to develop stuff. The thing you're trying to do can probably be automated by the natives supplied in the data layer, so you'll never need to access the SQL database. The data layer is an API which allows you to manipulate and save a keytable into SQL automatically. My description may be simplifying it because it does much more than that, but that's all you really need to know for now. If you're interested or want to know more about it, feel free to post on the ARP board.

EDIT: Your loss. I tried to help. It's the best solution, but if you want to make more crap code like Harbu then be my guest.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Reply


Thread Tools
Display Modes

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 09:06.


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