Raised This Month: $ Target: $400
 0% 

Make a plugin run only if server IP = 1.1.1.1


Post New Thread Closed Thread   
 
Thread Tools Display Modes
e54385991
AlliedModders Donor
Join Date: Aug 2013
Old 04-05-2016 , 11:58   Re: Make a plugin run only if server IP = 1.1.1.1
#31

simple use steamworks extensions


REQUIRE SteamWorks


PHP Code:
#pragma semicolon 1
#include <sourcemod>
//#undef REQUIRE_EXTENSIONS
#include <SteamWorks>
//#define REQUIRE_EXTENSIONS

int ipaddr[4];
char port[8],ipport[64];

bool IP false;

public 
Plugin myinfo 
{
    
name "New Plugin",
    
author "bbs.93x.net",
    
description "<- Description ->",
    
version "1.0",
    
url "<- URL ->"
}

//#if defined REQUIRE_EXTENSIONS
public int SteamWorks_SteamServersConnected()
{
    if(!
IP)
    {
        if ((
GetFeatureStatus(FeatureType_Native"SteamWorks_GetPublicIP") == FeatureStatus_Available))
            
PrintToServer("SteamWorks is Available!");
        if(
SteamWorks_GetPublicIP(ipaddr))
        {
            
IP true;
            
GetConVarString(FindConVar("hostport"), portsizeof(port));
            
Format(ipport,sizeof(ipport),"%i.%i.%i.%i:%s" ,ipaddr[0],ipaddr[1],ipaddr[2],ipaddr[3],port);
            
            if(
StrContains(ipport,"1.1.1.1:27015") == -1)
            {
                
SetFailState("The plugin isn't running on allowed IP address");
            }
        }
        else
        {
            
PrintToServer("Get Server Public IP Faild!");
            
SetFailState("Get Server Public IP Faild!");
        }
    }
}
//#endif 
__________________

Last edited by e54385991; 04-05-2016 at 12:18.
e54385991 is offline
Send a message via ICQ to e54385991
doze
Senior Member
Join Date: Mar 2012
Old 04-05-2016 , 13:00   Re: Make a plugin run only if server IP = 1.1.1.1
#32

Quote:
Originally Posted by e54385991 View Post
simple use steamworks extensions


REQUIRE SteamWorks


PHP Code:
#pragma semicolon 1
#include <sourcemod>
//#undef REQUIRE_EXTENSIONS
#include <SteamWorks>
//#define REQUIRE_EXTENSIONS

int ipaddr[4];
char port[8],ipport[64];

bool IP false;

public 
Plugin myinfo 
{
    
name "New Plugin",
    
author "bbs.93x.net",
    
description "<- Description ->",
    
version "1.0",
    
url "<- URL ->"
}

//#if defined REQUIRE_EXTENSIONS
public int SteamWorks_SteamServersConnected()
{
    if(!
IP)
    {
        if ((
GetFeatureStatus(FeatureType_Native"SteamWorks_GetPublicIP") == FeatureStatus_Available))
            
PrintToServer("SteamWorks is Available!");
        if(
SteamWorks_GetPublicIP(ipaddr))
        {
            
IP true;
            
GetConVarString(FindConVar("hostport"), portsizeof(port));
            
Format(ipport,sizeof(ipport),"%i.%i.%i.%i:%s" ,ipaddr[0],ipaddr[1],ipaddr[2],ipaddr[3],port);
            
            if(
StrContains(ipport,"1.1.1.1:27015") == -1)
            {
                
SetFailState("The plugin isn't running on allowed IP address");
            }
        }
        else
        {
            
PrintToServer("Get Server Public IP Faild!");
            
SetFailState("Get Server Public IP Faild!");
        }
    }
}
//#endif 
The plugin seems to load only if the server IP is the right one, that is good.

However, i've added my existing plugin code after //#endif , it didn't work, nothing happened.
doze is offline
psychonic

BAFFLED
Join Date: May 2008
Old 04-05-2016 , 13:18   Re: Make a plugin run only if server IP = 1.1.1.1
#33

I think that you've gotten more than enough help for this.
psychonic is offline
Closed Thread



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 21:29.


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