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

Level rank plugin Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cristianronaldo
Member
Join Date: Sep 2015
Old 05-27-2016 , 16:47   Level rank plugin Help
Reply With Quote #1

Hello,i need a plugin for block players join to my server,if they dont have 1000 points or more.This points are extracted from a MySql DB.Thanks I really appreciate help
@EasSidezz help!!!

Last edited by cristianronaldo; 05-27-2016 at 16:49.
cristianronaldo is offline
cristianronaldo
Member
Join Date: Sep 2015
Old 05-27-2016 , 19:07   Re: Level rank plugin Help
Reply With Quote #2

@EasSidezz
I have making this plugin,but i need help
See the .sp
This semi-plugin is for the players can know his points.
Attached Files
File Type: sp Get Plugin or Get Source (this.sp - 169 views - 1.6 KB)

Last edited by cristianronaldo; 05-27-2016 at 20:21.
cristianronaldo is offline
sdz
Senior Member
Join Date: Feb 2012
Old 05-29-2016 , 10:55   Re: Level rank plugin Help
Reply With Quote #3

Someone mentioned you were looking for me, lol.
Well you'll want to look into threading your SQL Queries, because running nonthreaded queries will lag the almighty hell out of your server.

-SQL_TConnect
-SQL_TQuery

I can give you some example database code of how it should be looking..

PHP Code:
#include <sourcemod>

enum Player_Data
{    
    
String:SteamID[32],
    
Money,
    
Bank,
};
new 
g_playerData[MAXPLAYERS 1][Player_Data]

new 
Handle:dbConnection INVALID_HANDLE;

public 
OnPluginStart()
{
    
SQL_TConnect(connectCB"database");
}

//We'll use something similar to this if we want to load data
public connectCB(Handle:ownerHandle:child, const String:error[], any:data)
{
    if(
child == INVALID_HANDLE)
    {
        
LogError("[ERROR] >> %s"error); //Error Preface
        
PrintToServer("[ERROR] >> %s"error);
        
SQL_TConnect(connectCB"db");
        return;
    }

    
dbConnection child;
    
PrintToServer(">> Connected to MySQL Database! :D :D");
    return;
}

//Standard, non customized callback for queries of which do not return results
public sql_Callback(Handle:queryHandle:child, const String:error[], any:data)
{
    if(
query == INVALID_HANDLE || child == INVALID_HANDLE)
    {
        
LogError("[ERROR] >> %s"error); //Error Preface
        
return;
    }
}

public 
OnClientPutInServer(client)
{
    
GetClientAuthId(clientAuthId_Steam3g_playerData[client][SteamID], 32);

    
decl String:query[256];
    
Format(querysizeof(query), "SELECT * FROM player_stats WHERE steam_id = '%s'"g_playerData[Client][SteamID]);
    
SQL_TQuery(dbConnectionsql_LoadqueryGetClientUserId(Client));
}

public 
sql_Load(Handle:nothingHandle:result, const String:error[], any:data)
{
    new 
Client GetClientOfUserId(data)
    if(
IsFakeClient(Client))
    {
        return;
    }

    if(
Client == 0)
    {
        return;
    }

    if(
result == INVALID_HANDLE)
    {
        
LogError("[ERROR] >> %s"error); //Error Preface
        
return;
    }

    
//Load Stats
    
if(!SQL_GetRowCount(result))
    {
        
decl String:query[256];
        
Format(querysizeof(query), "INSERT INTO player_stats (steam_id) VALUES ('%s');"g_playerData[Client][SteamID]);
        
SQL_TQuery(sqlDBsqlQueryquery);
        
PrintToChat(Client"Data not found for you, so we'll set you up with an account..");
    }
    else if(
SQL_FetchRow(result))
    {
        
g_playerData[Client][Money] = SQL_FetchInt(result1);
        
g_playerData[Client][Bank] = SQL_FetchInt(result2);
    }

That's generally how you'll want to approach this

Last edited by sdz; 06-09-2016 at 03:27.
sdz is offline
cristianronaldo
Member
Join Date: Sep 2015
Old 05-29-2016 , 12:39   Re: Level rank plugin Help
Reply With Quote #4

Quote:
Originally Posted by EasSidezz View Post
Someone mentioned you were looking for me, lol.
Well you'll want to look into threading your SQL Queries, because running nonthreaded queries will lag the almighty hell out of your server.

-SQL_TConnect
-SQL_TQuery

I can give you some example database code of how it should be looking..

PHP Code:
#include <sourcemod>

enum Player_Data
{    
    
String:SteamID[32],
    
Money,
    
Bank,
};
new 
g_playerData[MAXPLAYERS 1][Player_Data]

new 
Handle:dbConnection INVALID_HANDLE;

public 
OnPluginStart()
{
    
SQL_TConnect(connectCB"database");
}

//We'll use something similar to this if we want to load data
public connectCB(Handle:ownerHandle:child, const String:error[], any:data)
{
    if(
child == INVALID_HANDLE)
    {
        
LogError("[ERROR] >> %s"error); //Error Preface
        
PrintToServer("[ERROR] >> %s"error);
        
SQL_TConnect(connectCB"db");
        return;
    }

    
dbConnection child;
    
PrintToServer(">> Connected to MySQL Database! :D :D");
    return;
}

//Standard, non customized callback for queries of which do not return results
public sql_Callback(Handle:queryHandle:child, const String:error[], any:data)
{
    if(
query == INVALID_HANDLE || child == INVALID_HANDLE)
    {
        
LogError("[ERROR] >> %s"error); //Error Preface
        
return;
    }
}

public 
OnClientPutInServer(client)
{
    
GetClientAuthId(clientAuthId_Steam3g_playerData[client][SteamID], 32);

    
decl String:query[256];
    
Format(querysizeof(query), "SELECT * FROM player_stats WHERE steam_id = '%s'"g_playerData[Client][SteamID]);
    
SQL_TQuery(dbConnectionsql_LoadqueryGetClientUserId(Client));
}

public 
sql_Load(Handle:nothingHandle:result, const String:error[], any:data)
{
    new 
Client GetClientOfUserId(data)
    if(
IsFakeClient(Client))
    {
        return;
    }

    if(
Client == 0)
    {
        return;
    }

    if(
result == INVALID_HANDLE)
    {
        
LogError("[ERROR] >> %s"error); //Error Preface
        
return;
    }

    
//Load Stats
    
if(!SQL_GetRowCount(result))
    {
        
decl String:query[256];
        
Format(querysizeof(query), "INSERT INTO player_stats (steam_id) VALUES ('%s');"g_playerData[Client][SteamID]);
        
SQL_TQuery(sqlDBsqlQueryquery);
        
PrintToChat(Client"\x01\x04[RP]\x10 Data not found for you, so we'll set you up with an account..");
    }
    else if(
SQL_FetchRow(result))
    {
        
g_playerData[Client][Money] = SQL_FetchInt(result1);
        
g_playerData[Client][Bank] = SQL_FetchInt(result2);
    }

That's generally how you'll want to approach this
Thanks, I'll try and then upload the code
cristianronaldo is offline
ElaMeMamou
Member
Join Date: May 2016
Old 05-29-2016 , 15:00   Re: Level rank plugin Help
Reply With Quote #5

hey there we want the samething.. if you had success please share..

https://forums.alliedmods.net/showthread.php?p=2423049


thank you
ElaMeMamou is offline
cristianronaldo
Member
Join Date: Sep 2015
Old 05-29-2016 , 20:23   Re: Level rank plugin Help
Reply With Quote #6

Quote:
Originally Posted by ElaMeMamou View Post
hey there we want the samething.. if you had success please share..

https://forums.alliedmods.net/showthread.php?p=2423049


thank you
hello bro.i need extract the score from Mysql Database,and them if player dont have the minimum score for entry to this server,the server kick him.
cristianronaldo is offline
Jackol1234
Senior Member
Join Date: Apr 2015
Old 05-30-2016 , 00:46   Re: Level rank plugin Help
Reply With Quote #7

I threw this together. Can't guarantee that it'll work, but it did compile:

PHP Code:
#include <ckSurf>

#pragma semicolon 1

#define PLUGIN_VERSION "0.1"

public Plugin:myinfo =
{
    
name "ckSurf Kicker",
    
author "DeweY",
    
version PLUGIN_VERSION,
    
description "Kicks clients with 1000 points or more.",
    
url "http://Omegagaming.org/"
};

Handle g_hDatabase null;

char g_sSteamID[MAXPLAYERS+1][64];

public 
void OnPluginStart()
{
    
SQL_TConnect(SQLCallback_Connect"ckSurf");
}

public 
SQLCallback_Connect(Handle ownerHandle hndl, const char[] errorany data)
{
    if (
hndl == null)
    {
        
SetFailState("Error connecting to database. %s"error);
    }

    
g_hDatabase hndl;
}

public 
void OnClientPostAdminCheck(client)
{
    
GetClientAuthId(clientAuthId_SteamID64g_sSteamID[client], sizeof(g_sSteamID[]));
    
CheckRank(client);
}

public 
CheckRank(int client)
{
    
char query[255];
    
Format(query255"SELECT `points` FROM `ck_playerrank` WHERE `steamid`='%s' LIMIT 1"g_sSteamID[client]);
    
SQL_TQuery(g_hDatabaseSQLCallback_LoadPlayerPointsqueryGetClientUserId(client));
}

public 
SQLCallback_LoadPlayerPoints(Handle ownerHandle hndl, const char[] errorany data)
{
    if (
hndl == null)
    {
        
SetFailState("Error grabbing player points. %s"error);
    }

    
int client GetClientOfUserId(data);


    if (
SQL_GetRowCount(hndl) == 1)
    {
        
SQL_FetchRow(hndl);
        
int playerpoints SQL_FetchInt(hndl0);
        if (
playerpoints >= 1000)
        {
            
KickClient(client"This server is for beginners.");
        }
    }

EDIT: I now see this isn't for ckSurf, but it should still work for what you're trying to do just change the connecting database and also the SQL format line.

Last edited by Jackol1234; 05-30-2016 at 00:49.
Jackol1234 is offline
cristianronaldo
Member
Join Date: Sep 2015
Old 05-30-2016 , 06:47   Re: Level rank plugin Help
Reply With Quote #8

Quote:
Originally Posted by Jackol1234 View Post
I threw this together. Can't guarantee that it'll work, but it did compile:

PHP Code:
#include <ckSurf>

#pragma semicolon 1

#define PLUGIN_VERSION "0.1"

public Plugin:myinfo =
{
    
name "ckSurf Kicker",
    
author "DeweY",
    
version PLUGIN_VERSION,
    
description "Kicks clients with 1000 points or more.",
    
url "http://Omegagaming.org/"
};

Handle g_hDatabase null;

char g_sSteamID[MAXPLAYERS+1][64];

public 
void OnPluginStart()
{
    
SQL_TConnect(SQLCallback_Connect"ckSurf");
}

public 
SQLCallback_Connect(Handle ownerHandle hndl, const char[] errorany data)
{
    if (
hndl == null)
    {
        
SetFailState("Error connecting to database. %s"error);
    }

    
g_hDatabase hndl;
}

public 
void OnClientPostAdminCheck(client)
{
    
GetClientAuthId(clientAuthId_SteamID64g_sSteamID[client], sizeof(g_sSteamID[]));
    
CheckRank(client);
}

public 
CheckRank(int client)
{
    
char query[255];
    
Format(query255"SELECT `points` FROM `ck_playerrank` WHERE `steamid`='%s' LIMIT 1"g_sSteamID[client]);
    
SQL_TQuery(g_hDatabaseSQLCallback_LoadPlayerPointsqueryGetClientUserId(client));
}

public 
SQLCallback_LoadPlayerPoints(Handle ownerHandle hndl, const char[] errorany data)
{
    if (
hndl == null)
    {
        
SetFailState("Error grabbing player points. %s"error);
    }

    
int client GetClientOfUserId(data);


    if (
SQL_GetRowCount(hndl) == 1)
    {
        
SQL_FetchRow(hndl);
        
int playerpoints SQL_FetchInt(hndl0);
        if (
playerpoints >= 1000)
        {
            
KickClient(client"This server is for beginners.");
        }
    }

EDIT: I now see this isn't for ckSurf, but it should still work for what you're trying to do just change the connecting database and also the SQL format line.
It work!!!!!!Thanks.I need to make a explode, because in my DB the steam are saved only with the numbers, that is, not saved STEAM_1: xxxxx .you could make explode the steam will select only the DB part of the numbers?Thanks
cristianronaldo is offline
Jackol1234
Senior Member
Join Date: Apr 2015
Old 05-30-2016 , 15:08   Re: Level rank plugin Help
Reply With Quote #9

Quote:
Originally Posted by cristianronaldo View Post
It work!!!!!!Thanks.I need to make a explode, because in my DB the steam are saved only with the numbers, that is, not saved STEAM_1: xxxxx .you could make explode the steam will select only the DB part of the numbers?Thanks
This should do what you're looking for. Change OnClientPostADmincheck to this:

PHP Code:
public void OnClientPostAdminCheck(client

    
CheckRank(client); 

And add this to CheckRank:

PHP Code:
public CheckRank(int client)
{
    
char query[255];
    
char SteamID[32];
    
GetClientAuthId(clientAuthId_Steam2SteamID32);
    
Format(query255"SELECT `points` FROM `ck_playerrank` WHERE `steamid`='%s' LIMIT 1"g_sSteamID[10]);
    
SQL_TQuery(g_hDatabaseSQLCallback_LoadPlayerPointsqueryGetClientUserId(client));

Then of course remove "char g_sSteamID[MAXPLAYERS+1][64];" at the top of the plugin since it isn't global anymore.
__________________
Accepting PM's for private requests!
Jackol1234 is offline
cristianronaldo
Member
Join Date: Sep 2015
Old 05-30-2016 , 20:39   Re: Level rank plugin Help
Reply With Quote #10

Quote:
Originally Posted by Jackol1234 View Post
This should do what you're looking for. Change OnClientPostADmincheck to this:

PHP Code:
public void OnClientPostAdminCheck(client

    
CheckRank(client); 

And add this to CheckRank:

PHP Code:
public CheckRank(int client)
{
    
char query[255];
    
char SteamID[32];
    
GetClientAuthId(clientAuthId_Steam2SteamID32);
    
Format(query255"SELECT `points` FROM `ck_playerrank` WHERE `steamid`='%s' LIMIT 1"g_sSteamID[10]);
    
SQL_TQuery(g_hDatabaseSQLCallback_LoadPlayerPointsqueryGetClientUserId(client));

Then of course remove "char g_sSteamID[MAXPLAYERS+1][64];" at the top of the plugin since it isn't global anymore.
This will be just like that.does not fail,But dont work.Please check it.Thanks!!!!!!!
Attached Files
File Type: sp Get Plugin or Get Source (KICK MMR.sp - 361 views - 1.5 KB)

Last edited by cristianronaldo; 05-30-2016 at 21:19.
cristianronaldo 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 22:30.


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