Raised This Month: $ Target: $400
 0% 

MySQL Setup


Post New Thread Reply   
 
Thread Tools Display Modes
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 09-04-2015 , 09:32   Re: MySQL Setup
Reply With Quote #11

I'm writing on a plugin where you don't need to learn sql to create a new database inside sourcemod and use it.
__________________
zipcore is offline
DJ Data
SourceMod Donor
Join Date: Dec 2012
Location: Switzerland
Old 09-04-2015 , 09:42   Re: MySQL Setup
Reply With Quote #12

Quote:
Originally Posted by zipcore View Post
I'm writing on a plugin where you don't need to learn sql to create a new database inside sourcemod and use it.
That sounds cool, but I asked the community because I want to learn ^^
__________________
SourcePawn Coding Level: Novice

Last edited by DJ Data; 09-04-2015 at 09:42.
DJ Data is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 09-04-2015 , 10:50   Re: MySQL Setup
Reply With Quote #13

PHP Code:
new Handle:g_hDB INVALID_HANDLE;

public 
OnPluginStart()
{
    
RegAdminCmd("sm_menu"Command_vipmenuADMFLAG_ROOT);
    
    
StartSQL();
}

public 
Action:Command_vipmenu(clientargs)
{
    new 
String:steamid[32];
    
GetClientAuthId(clientAuthId_Enginesteamidsizeof(steamid));
    
ShowPoints(clientsteamid);
}

ShowPoints(client, const String:steamid[])
{
    new 
String:query[128];
    
FormatEx(querysizeof(query), "SELECT points FROM Users WHERE steamid = '%s'"steamid);
    
SQL_TQuery(g_hDBcallbackqueryclient);
}

public 
callback(Handle:ownerHandle:hndl, const String:error[], any:client)
{
    if (
hndl == INVALID_HANDLE)
    {
        
LogError("error: %s"error);
        return;
    }
    
    new 
tokens 0;
    
    if(
SQL_FetchRow(hndl))
    {
        
tokens SQL_FetchInt(hndl0);
    }
        
    
    new 
Handle:menu CreateMenu(vipmenuMenuAction_Select MenuAction_End);
    
SetMenuTitle(menu"► arctekservers.com ◄");
    
    
AddMenuItem(menu"tokens""You have %d VIP Tokens"tokens);
    
    
DisplayMenu(menuclientMENU_TIME_FOREVER);
}

StartSQL()
{
    
SQL_TConnect(DB_Connect"your_database_name");
}

public 
DB_Connect(Handle:ownerHandle:hndl, const String:error[], any:client)
{
    if (
hndl == INVALID_HANDLE)
    {
        
LogError("error: %s"error);
    }
    else
    {
        
g_hDB hndl;
    }

edit: db name is second argument to tconnect btw, forgot about that

Last edited by Miu; 09-04-2015 at 13:42.
Miu is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-04-2015 , 11:43   Re: MySQL Setup
Reply With Quote #14

Quote:
Originally Posted by zipcore View Post
I'm writing on a plugin where you don't need to learn sql to create a new database inside sourcemod and use it.
How are you planning on deciding which types each column should have?

For that matter, how are you planning on avoiding the Inner-platform Effect?
__________________
Not currently working on SourceMod plugin development.

Last edited by asherkin; 09-04-2015 at 13:18. Reason: Not helpful.
Powerlord is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 09-04-2015 , 12:48   Re: MySQL Setup
Reply With Quote #15

Learn SQL, because not only is it used in Sourcemod but it is also used in virtually any programming language that provides an API to query databases.
Potato Uno is offline
DJ Data
SourceMod Donor
Join Date: Dec 2012
Location: Switzerland
Old 09-04-2015 , 16:56   Re: MySQL Setup
Reply With Quote #16

Quote:
Originally Posted by Potato Uno View Post
Learn SQL, because not only is it used in Sourcemod but it is also used in virtually any programming language that provides an API to query databases.
Yeah I hope to learn it this year in IT school ^^

Merge:

Quote:
Originally Posted by Miu View Post
PHP Code:
code 
Thanks!
1 compile error occured though:

GetClientAuthId is an undefined symbol.


Cheers
__________________
SourcePawn Coding Level: Novice

Last edited by DJ Data; 09-05-2015 at 17:00.
DJ Data is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 09-05-2015 , 19:16   Re: MySQL Setup
Reply With Quote #17

https://sm.alliedmods.net/new-api/cl...etClientAuthId ?

It returns undefined symbol? Do you have #include <sourcemod> at the top? Are you using SM 1.7 and not 1.6? Update to the latest snapshot of sourcemod.

Last edited by Potato Uno; 09-05-2015 at 19:16.
Potato Uno is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 09-06-2015 , 08:20   Re: MySQL Setup
Reply With Quote #18

use getclientauthstring instead then
Miu is offline
DJ Data
SourceMod Donor
Join Date: Dec 2012
Location: Switzerland
Old 09-06-2015 , 11:00   Re: MySQL Setup
Reply With Quote #19

Quote:
Originally Posted by Miu View Post
use getclientauthstring instead then
I'm using this and it compiled now. Thanks a lot for your help.

I'll report back if it works.
__________________
SourcePawn Coding Level: Novice
DJ Data 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:32.


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