View Single Post
HelpMe
Senior Member
Join Date: Jun 2013
Location: Home
Old 08-24-2013 , 10:45   Re: Cvar plus a timer problem
Reply With Quote #3

Quote:
Originally Posted by thetwistedpanda View Post
PHP Code:
#include <sourcemod>
#include <morecolors>
#include <steamtools>

new Handle:h_Enabled INVALID_HANDLE;
new 
Handle:h_Timer INVALID_HANDLE;
new 
Handle:h_Repeat INVALID_HANDLE;

public 
Plugin:myinfo 
{
    
name "ServerIP",
    
author "Benjamin",
    
description "Prints server ip to chat when typing sm_ip",
    
version "1.5",
    
url "http://steamcommunity.com/id/BenjaminHT/"
}

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_ip"ServerIP);
    
h_Enabled CreateConVar("sm_timerenable""1""Enable chat messages with server ip. 1 = enabled."FCVAR_PLUGINtrue0.0true1.0);
    
h_Timer CreateConVar("sm_timer""30""The time before trigger."FCVAR_PLUGINtrue30.0true600.0);
    
AutoExecConfig(true"ServerIP.cfg");
}

public 
OnMapStart()
{
    if(
GetConVarInt(h_Enabled))
        
h_Repeat CreateTimer(GetConVarFloat(h_Timer), TimerCallBack_TIMER_REPEAT);
}

public 
OnMapEnd()
{
        if(
h_Repeat != INVALID_HANDLE && CloseHandle(h_Repeat))
            
h_Repeat INVALID_HANDLE;
}

public 
Action:TimerCallBack(Handle:timerany:client)
{
    new 
soos GetConVarInt(FindConVar("hostport"));
    new 
octets[4];
    
Steam_GetPublicIP(octets);
    
CPrintToChat(client"{green}=========================");
    
CPrintToChat(client"{default}Server IP is: {green}%d.%d.%d.%d:%d"octets[0], octets[1], octets[2], octets[3], soos);
    
CPrintToChat(client"{green}=========================");
}

public 
Action:ServerIP(clientargs)
{
    new 
IsEnabled GetConVarInt(h_Enabled);
    if(
IsEnabled == 1)
    {
        new 
soos GetConVarInt(FindConVar("hostport"));
        new 
octets[4];
        
Steam_GetPublicIP(octets);
        
CPrintToChat(client"{green}=========================");
        
CPrintToChat(client"{default}Server IP is: {green}%d.%d.%d.%d:%d"octets[0], octets[1], octets[2], octets[3], soos);
        
CPrintToChat(client"{green}=========================");
    }
        return 
Plugin_Handled;

Thanks man
HelpMe is offline