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

Getting database data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EvanChrispie
Member
Join Date: Nov 2016
Old 03-11-2017 , 08:21   Getting database data
Reply With Quote #1

Hello,

How would I go about getting the number from the tier column to then print out the map name in a menu. For example if there was a menu to show all tier 1 maps, how could that be done?
Example:
Spoiler
__________________
EvanChrispie is offline
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 03-11-2017 , 08:31   Re: Getting database data
Reply With Quote #2

Connect to a database defined in the databases.cfg file via SQL_Connect.

Prepare a query to select all items in the database where "tier" is equal to a number. Use SQL_Query

Loop through all rows and fetch the string.

An example of an Sql query:

PHP Code:
char SQL_SomeQuery[]    = "SELECT srv_group FROM sb_admins WHERE authid == 'CONSOLE'" 
svr_group being the collum, sb_admins being the table and after that is basically filters.

Last edited by Weetabix; 03-11-2017 at 08:34.
Weetabix is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 03-11-2017 , 08:40   Re: Getting database data
Reply With Quote #3

Quote:
Originally Posted by Weetabix View Post
Use SQL_Query
cough cough SQL_TQuery
__________________
xines is offline
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 03-11-2017 , 08:43   Re: Getting database data
Reply With Quote #4

Quote:
Originally Posted by xines View Post
cough cough SQL_TQuery
Yep, that's more efficient for this I guess.

Use https://sm.alliedmods.net/new-api/dbi if you get confused.
Weetabix is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 03-11-2017 , 13:30   Re: Getting database data
Reply With Quote #5

Quote:
Originally Posted by Weetabix View Post
Yep, that's more efficient for this I guess.

Use https://sm.alliedmods.net/new-api/dbi if you get confused.
It's not a matter of efficiency, but rather one which prevents your game server from freezing while the query is being executed...
headline is offline
sdz
Senior Member
Join Date: Feb 2012
Old 03-11-2017 , 19:44   Re: Getting database data
Reply With Quote #6

something like this.
Spoiler


If you need a dedicated developer, send me a PM.

Last edited by sdz; 03-11-2017 at 19:45.
sdz 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 09:57.


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