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));
}
}
}