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

mysql help scripting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Johnoclock
Member
Join Date: Oct 2014
Location: denmark
Old 04-25-2022 , 09:41   mysql help scripting
Reply With Quote #1

I want to make a plugin that check when a player joins the server and matching it on database if it return true. Give the permissions to the sm_settag. If it returns false do nothing

heres is what i got so far
Code:
#include <sourcemod>

#pragma newdecls required
#pragma semicolon 1

#define PLUGIN_VERSION "1.0"  

Handle DB = INVALID_HANDLE;


public Plugin myinfo =
{  
    name = "[CSGO] Cutome tags with mysql",
    author = "John`Oclock",
    description = "Cutome tags with mysql",
    version = PLUGIN_VERSION,
    url = "tickrate.dk"
};
// plugin start op
public void OnPluginStart()
{
    RegServerCmd("sm_settag", settag);

    char Error[70];
    DB = SQL_Connect("CustomTags", true, Error, sizeof(Error));
    if(DB == INVALID_HANDLE)
    {
        PrintToServer("cannot connect to MYsql server: %s", Error);
    }
    else
    {
        PrintToServer("Connection Successful");
    }
    //makes the table
    SQL_Query(DB, "CREATE TABLE IF NOT EXISTS `Customtags` (`Steamid` VARCHAR(64),`Tag` VARCHAR(128));");
}
 
public Action settag(int args)
{
    return Plugin_Handled;
}


//check the joining players on join server
public void OnClientAuthorized(int client)
{
    char steamId[32];
    GetClientAuthId(client, AuthId_SteamID64, steamId, sizeof(steamId));

    char query[150];
    Format(query, sizeof(query), "SELECT steamid FROM Customtags WHERE steamid=`%s`", steamId);
    SQL_TQuery(DB, SQL_QueryCallback, query);
}


public void SQL_QueryCallback(Handle owner, Handle hndl, const char[] error, any data)
{
    if(hndl != INVALID_HANDLE)
    {
        while (SQL_FetchRow(hndl)) 
        {
            char HsteamId[32];
            SQL_FetchString(hndl, 1, HsteamId, sizeof(HsteamId));
        } 
    }
}
Johnoclock is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-26-2022 , 06:14   Re: mysql help scripting
Reply With Quote #2

what is this sm_settag ?
__________________
Do not Private Message @me
Bacardi is offline
BeepIsla
Member
Join Date: Mar 2020
Location: Germany
Old 04-27-2022 , 14:03   Re: mysql help scripting
Reply With Quote #3

You need to make a global variable (Probably bool g_bAllowed[MAXPLAYERS + 1]) to store the database result and then check that variable in the sm_settag command
BeepIsla 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 00:17.


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