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

Level rank plugin Help


Post New Thread Reply   
 
Thread Tools Display Modes
cristianronaldo
Member
Join Date: Sep 2015
Old 06-01-2016 , 14:20   Re: Level rank plugin Help
Reply With Quote #21

Quote:
Originally Posted by Jackol1234 View Post
I don't know if it's possible to grab the port. The one thing I found using google was:

PHP Code:
int iPort GetConVarInt(FindConVar("hostport")); 
but this requires you to use hostport in the command-line while starting up your server. To test this out and see if it works for you, change your OnPluginStart code to this:

PHP Code:
public void OnPluginStart()
{
    
SQL_TConnect(SQLCallback_Connect"ckSurf");

    
int iPort GetConVarInt(FindConVar("hostport"));
    
LogMessage("This servers port is %i"iPort);

Then look in your console or your log files and see what it says. If it shows "This servers port is " then it will not work, otherwise I'll code something up for you.
In the console,appears this
Attached Thumbnails
Click image for larger version

Name:	port1.png
Views:	78
Size:	2.8 KB
ID:	155144  

Last edited by cristianronaldo; 06-01-2016 at 14:25.
cristianronaldo is offline
Jackol1234
Senior Member
Join Date: Apr 2015
Old 06-01-2016 , 14:35   Re: Level rank plugin Help
Reply With Quote #22

Is the server port actually 111?
__________________
Accepting PM's for private requests!
Jackol1234 is offline
cristianronaldo
Member
Join Date: Sep 2015
Old 06-01-2016 , 15:26   Re: Level rank plugin Help
Reply With Quote #23

Quote:
Originally Posted by Jackol1234 View Post
Is the server port actually 111?
yes
cristianronaldo is offline
Jackol1234
Senior Member
Join Date: Apr 2015
Old 06-01-2016 , 16:56   Re: Level rank plugin Help
Reply With Quote #24

Alright this took a while for me to get and it's my first try with Key Values, but here you go:

PHP Code:
int iPoints;

char g_sPortPath[PLATFORM_MAX_PATH];

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

    
BuildPath(Path_SMg_sPortPathsizeof(g_sPortPath), "configs/ports.cfg");

    
FindPort();
}

public 
void FindPort()
{
    
int iPort GetConVarInt(FindConVar("hostport"));
    
Handle hPorts CreateKeyValues("Ports");
    
    if(!
FileExists(g_sPortPath))
    {
        
SetFailState("Configuration file %s not found!"g_sPortPath);
        return;
    }

    if(!
FileToKeyValues(hSettingsg_sPortPath))
    {
        
SetFailState("Improper structure for configuration file %s!"g_sPortPath);
        return;
    }

    if(
KvGotoFirstSubKey(hSettings))
    {
        do
        {
            
char Port[7];
            
KvGetString(hPorts"port"Port7);
            
kv_iPort StringToInt(Port);
            if (
iPort == kv_iPort)
            {
                
char Points[32];
                
KvGetString(hPorts"points"Points32);
                
iPoints StringToInt(Points);
                break;
            }
            
        } while(
KvGotoNextKey(hSettingsfalse));
    }

    else
    {
        
SetFailState("Can't find first subkey in configuration file %s!"g_sPortPath);
        return;
    }

    
CloseHandle(hPorts);
}

public 
void 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 >= iPoints)
        {
            
KickClient(client"This server is for beginners.");
        }
    }

Just add or change all of that in your plugin and make a "ports.cfg" in your addons/sourcemod/configs folder that looks like:

Code:
"Setups"
{
	"Server1"
	{
		"port"				"111"
		"points"			"1000"
	}
	
	"Server2"
	{
		"port"				"222"
		"points"			"1500"
	}
}
You can add more lines into that for as many servers as you have. Just follow the hierarchy and keep the "Server#" different each time.
__________________
Accepting PM's for private requests!
Jackol1234 is offline
cristianronaldo
Member
Join Date: Sep 2015
Old 06-01-2016 , 20:45   Re: Level rank plugin Help
Reply With Quote #25

Quote:
Originally Posted by Jackol1234 View Post
Alright this took a while for me to get and it's my first try with Key Values, but here you go:

PHP Code:
int iPoints;

char g_sPortPath[PLATFORM_MAX_PATH];

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

    
BuildPath(Path_SMg_sPortPathsizeof(g_sPortPath), "configs/ports.cfg");

    
FindPort();
}

public 
void FindPort()
{
    
int iPort GetConVarInt(FindConVar("hostport"));
    
Handle hPorts CreateKeyValues("Ports");
    
    if(!
FileExists(g_sPortPath))
    {
        
SetFailState("Configuration file %s not found!"g_sPortPath);
        return;
    }

    if(!
FileToKeyValues(hSettingsg_sPortPath))
    {
        
SetFailState("Improper structure for configuration file %s!"g_sPortPath);
        return;
    }

    if(
KvGotoFirstSubKey(hSettings))
    {
        do
        {
            
char Port[7];
            
KvGetString(hPorts"port"Port7);
            
kv_iPort StringToInt(Port);
            if (
iPort == kv_iPort)
            {
                
char Points[32];
                
KvGetString(hPorts"points"Points32);
                
iPoints StringToInt(Points);
                break;
            }
            
        } while(
KvGotoNextKey(hSettingsfalse));
    }

    else
    {
        
SetFailState("Can't find first subkey in configuration file %s!"g_sPortPath);
        return;
    }

    
CloseHandle(hPorts);
}

public 
void 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 >= iPoints)
        {
            
KickClient(client"This server is for beginners.");
        }
    }

Just add or change all of that in your plugin and make a "ports.cfg" in your addons/sourcemod/configs folder that looks like:

Code:
"Setups"
{
    "Server1"
    {
        "port"                "111"
        "points"            "1000"
    }
    
    "Server2"
    {
        "port"                "222"
        "points"            "1500"
    }
}
You can add more lines into that for as many servers as you have. Just follow the hierarchy and keep the "Server#" different each time.
Man really,YOU ARE THE BEST!!!!!I am very grateful for the help you have given me, I would pay you, but in my country is not possible to pay for internet.i will try this and tell you the results.Really thanks!!!!!!
cristianronaldo is offline
cristianronaldo
Member
Join Date: Sep 2015
Old 06-01-2016 , 21:09   Re: Level rank plugin Help
Reply With Quote #26

Quote:
Originally Posted by Jackol1234 View Post
Alright this took a while for me to get and it's my first try with Key Values, but here you go:

PHP Code:
int iPoints;

char g_sPortPath[PLATFORM_MAX_PATH];

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

    
BuildPath(Path_SMg_sPortPathsizeof(g_sPortPath), "configs/ports.cfg");

    
FindPort();
}

public 
void FindPort()
{
    
int iPort GetConVarInt(FindConVar("hostport"));
    
Handle hPorts CreateKeyValues("Ports");
    
    if(!
FileExists(g_sPortPath))
    {
        
SetFailState("Configuration file %s not found!"g_sPortPath);
        return;
    }

    if(!
FileToKeyValues(hSettingsg_sPortPath))
    {
        
SetFailState("Improper structure for configuration file %s!"g_sPortPath);
        return;
    }

    if(
KvGotoFirstSubKey(hSettings))
    {
        do
        {
            
char Port[7];
            
KvGetString(hPorts"port"Port7);
            
kv_iPort StringToInt(Port);
            if (
iPort == kv_iPort)
            {
                
char Points[32];
                
KvGetString(hPorts"points"Points32);
                
iPoints StringToInt(Points);
                break;
            }
            
        } while(
KvGotoNextKey(hSettingsfalse));
    }

    else
    {
        
SetFailState("Can't find first subkey in configuration file %s!"g_sPortPath);
        return;
    }

    
CloseHandle(hPorts);
}

public 
void 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 >= iPoints)
        {
            
KickClient(client"This server is for beginners.");
        }
    }

Just add or change all of that in your plugin and make a "ports.cfg" in your addons/sourcemod/configs folder that looks like:

Code:
"Setups"
{
    "Server1"
    {
        "port"                "111"
        "points"            "1000"
    }
    
    "Server2"
    {
        "port"                "222"
        "points"            "1500"
    }
}
You can add more lines into that for as many servers as you have. Just follow the hierarchy and keep the "Server#" different each time.
oopsssss
Attached Thumbnails
Click image for larger version

Name:	oopsss.png
Views:	67
Size:	7.8 KB
ID:	155157  
cristianronaldo is offline
Jackol1234
Senior Member
Join Date: Apr 2015
Old 06-01-2016 , 21:13   Re: Level rank plugin Help
Reply With Quote #27

Add me on steam and I'll help you more. Here is my Steam: steamcommunity.com/id/jackol1234
__________________
Accepting PM's for private requests!
Jackol1234 is offline
cristianronaldo
Member
Join Date: Sep 2015
Old 06-01-2016 , 22:17   Re: Level rank plugin Help
Reply With Quote #28

Quote:
Originally Posted by Jackol1234 View Post
Add me on steam and I'll help you more. Here is my Steam: steamcommunity.com/id/jackol1234
Sorry but the account does not allow me to add friends.Check it for yourself
Mi account is CRISTIANSORI2
Please help me with the plugin,pleaseeee
cristianronaldo is offline
Jackol1234
Senior Member
Join Date: Apr 2015
Old 06-01-2016 , 22:48   Re: Level rank plugin Help
Reply With Quote #29

It'll probably be easier on here then. Send me all the code you have and I'll fix it up with my key values.
__________________
Accepting PM's for private requests!

Last edited by Jackol1234; 06-01-2016 at 22:48.
Jackol1234 is offline
cristianronaldo
Member
Join Date: Sep 2015
Old 06-01-2016 , 23:19   Re: Level rank plugin Help
Reply With Quote #30

Quote:
Originally Posted by Jackol1234 View Post
It'll probably be easier on here then. Send me all the code you have and I'll fix it up with my key values.
Code:
 int iPoints;

char g_sPortPath[PLATFORM_MAX_PATH];

public void OnPluginStart()
{
    SQL_TConnect(SQLCallback_Connect, "CS");

    BuildPath(Path_SM, g_sPortPath, sizeof(g_sPortPath), "configs/ports.cfg");

    FindPort();
}

public void FindPort()
{
    int iPort = GetConVarInt(FindConVar("hostport"));
    Handle hPorts = CreateKeyValues("Ports");
    
    if(!FileExists(g_sPortPath))
    {
        SetFailState("Configuration file %s not found!", g_sPortPath);
        return;
    }

    if(!FileToKeyValues(hSettings, g_sPortPath))
    {
        SetFailState("Improper structure for configuration file %s!", g_sPortPath);
        return;
    }

    if(KvGotoFirstSubKey(hSettings))
    {
        do
        {
            char Port[7];
            KvGetString(hPorts, "port", Port, 7);
            kv_iPort = StringToInt(Port);
            if (iPort == kv_iPort)
            {
                char Points[32];
                KvGetString(hPorts, "points", Points, 32);
                iPoints = StringToInt(Points);
                break;
            }
            
        } while(KvGotoNextKey(hSettings, false));
    }

    else
    {
        SetFailState("Can't find first subkey in configuration file %s!", g_sPortPath);
        return;
    }

    CloseHandle(hPorts);
}

public void SQLCallback_LoadPlayerPoints(Handle owner, Handle hndl, const char[] error, any 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(hndl, 0);
        if (playerpoints >= iPoints)
        {
            KickClient(client, "This server is for beginners.");
        }
    }
}
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 07:51.


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