View Single Post
Author Message
juss
Senior Member
Join Date: Jan 2016
Old 03-28-2016 , 04:19   [HELP PLZ] Check if connecting client's steamid is in database
Reply With Quote #1

Im trying to write plugin that checks if a connecting player steamid in DB and if not it kicks him and show a message, but if player steamid is in DB it will check if his date is not expired (when i add the player on DB it will have date column with the future date till the player can play on the server, think of it as a billing system) so if the date is < then current date it will kick the player and show the message that his steamid is expired

So far:

PHP Code:

#include <sourcemod>
#define PLUGIN_VERSION    "1.0"

new Handle:DB INVALID_HANDLE;

public 
Plugin:myinfo = {
    
name "Mysql_SteamID_Check",
    
author "juss",
    
description "[ANY] MySQL-T check if client's steam id in DB",
    
version PLUGIN_VERSION,
    
url "rullers.ru"
};

public 
OnPluginStart()
{
    new 
String:Error[70];
    
DB SQL_Connect("Mysql_SteamID_Check"trueErrorsizeof(Error));
    if(
DB == INVALID_HANDLE)
    {
        
PrintToServer("[ERROR] Cannot connect to MySQL Server: %s"Error);
        
CloseHandle(DB);
    }
    else
    {
        
PrintToServer("Connection Successful");
    }
}

public 
OnClientPostAdminCheck(client)
{
    if (
IsClientInGame(client) && !IsFakeClient(client))
    {
        new 
String:steamid[20];
        
GetClientAuthString(clientsteamidsizeof(steamid));
        
        new 
String:query[1024];
        
FormatEx(querysizeof(query),  "SELECT * FROM TABLE WHERE steamid='%s' LIMIT 1"steamid);
         
//didnt come up yet with right select query so this one ^ is just random
        
        
SQL_TQuery(dbMysqlCheckIDqueryclient);
    }
}

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

    if    (
SQL_FetchRow(hndl))
    {
      
/////////////////////////////////////////////////////////////////////////////////////////////////////
      //from this i dont know how to manage
      //it supposed to check if steamid is in DB, next if steamid is in DB it will check if its expired, if expired it will kick the player and show the message. or else if steamid not in DB it will kick the player and show the message 
       
if(steamid == DBsteamid)
         { 
      if (
players steam id is not expired) { then player can connect to the server }
      else {  
then kick the player an show the message that his payed time is expired}
       }
      else 
      { if 
client steamid not  in DB then kick the player an show the message for examplethat his not register on this server and he can register on LINK}
     
/////////////////////////////////////////////////////////////////////////////////////////////////////////

    
}



from that im trying to make a simple billing system

thanks for the help! <3

Last edited by juss; 03-28-2016 at 07:25.
juss is offline