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

Make a plugin run only if server IP = 1.1.1.1


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 04-04-2016 , 23:31   Re: Make a plugin run only if server IP = 1.1.1.1
#21

PHP Code:
new Handle:plugin GetMyHandle(), String:nameOfPlugin[256];
GetPluginFilename(pluginnameOfPluginsizeof(nameOfPlugin));
ServerCommand("sm plugins unload %s"nameOfPlugin);

PrintToServer("%s was disabled!"nameOfPlugin); 
Or

PHP Code:
stock UnloadPlugin(Handle:plugin=INVALID_HANDLE)
{
    
decl String:filename[64];
    
GetPluginFilename(pluginfilenamesizeof(filename));
    
ServerCommand("sm plugins unload %s"filename);
}

stock DisablePlugin(Handle:plugin=INVALID_HANDLE)
{
    
decl String:filename[64String:path_disabled[PLATFORM_MAX_PATH], String:path_plugin[PLATFORM_MAX_PATH];
    
    
GetPluginFilename(pluginfilenamesizeof(filename));
    
BuildPath(Path_SMpath_disabledsizeof(path_disabled), "plugins/disabled/%s"filename);
    
BuildPath(Path_SMpath_pluginsizeof(path_plugin), "plugins/%s"filename);
    
    if (
FileExists(path_disabled))
    {
        
DeleteFile(path_disabled);
    }
    
    if (!
RenameFile(path_disabledpath_plugin))
    {
        
DeleteFile(path_plugin);
    }
    
    
ServerCommand("sm plugins unload %s"filename);

Maxximou5 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-05-2016 , 00:13   Re: Make a plugin run only if server IP = 1.1.1.1
#22

Quote:
Originally Posted by doze View Post
If i knew how to code, i'd do it myself, wouldnt be requesting simple plugins like this, i don't know what to do with those things, they arent of any use to me.
Maybe you should learn to code, or atleast understand it enough to actually copy and paste it.



psychonic, couldn't some one just use a hex editor and change the ip? Never tried though.
Mitchell is offline
ReFlexPoison
☠☠☠
Join Date: Jul 2011
Location: ☠☠☠
Old 04-05-2016 , 00:42   Re: Make a plugin run only if server IP = 1.1.1.1
#23

This thread went on longer than it should.
ReFlexPoison is offline
BAILANDO
Senior Member
Join Date: Feb 2015
Location: Slovakia
Old 04-05-2016 , 02:17   Re: Make a plugin run only if server IP = 1.1.1.1
#24

As Neuro Toxin say, better is SetFailState,

Spoiler
Attached Files
File Type: sp Get Plugin or Get Source (onlyonspecificip.sp - 131 views - 1.0 KB)
BAILANDO is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 04-05-2016 , 05:01   Re: Make a plugin run only if server IP = 1.1.1.1
#25

Quote:
Originally Posted by doze View Post
I've changed my mind and i want to use it for a different purpose now since this code can have a variety of uses, using it for what i've initially intended is useless now since i've learned the plugin can be decompiled, i have no more use for it for that purpose.

I want to make sure i don't upload the plugin to another one of my servers by mistake, i need it to stop the plugin from executing so it doesn't interfere with other plugins on the server and print an alert in the chat informing me of my mistake so i can rectify it ASAP.
Yeah as if, nice try though. Who do you think you're fooling? I dont think I've heard this excuse before.

I suggest you go to the requests forum and stop spamming this section. If you want to distribute your plugins in a manner that violate the Sourcemod licence, dont seek for help here.
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
psychonic

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

Quote:
Originally Posted by Mitchell View Post
psychonic, couldn't some one just use a hex editor and change the ip? Never tried though.
I'm not very familiar with the SMX format, but I believe that the code section is compressed. It might be possible to extract, decompress, edit, recompress but not a small task. There may or may not also be a checksum value that would then be off.

Last edited by psychonic; 04-05-2016 at 08:55.
psychonic is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 04-05-2016 , 09:41   Re: Make a plugin run only if server IP = 1.1.1.1
#27

Instead of trying to block it through IP, you could make sure that you only distribute it to people you trust.
__________________
Chdata is offline
doze
Senior Member
Join Date: Mar 2012
Old 04-05-2016 , 10:36   Re: Make a plugin run only if server IP = 1.1.1.1
#28

Quote:
Originally Posted by BAILANDO View Post
As Neuro Toxin say, better is SetFailState,

Spoiler
Many thanks man, you're a good guy that actually understands what i am talking about and doesn't fill up the thread with nothingness, some bacon for you my good sir

There seems to be a problem however with Source that makes the plugin not work.

When writing hostip in console (server or client) the server IP will not be displayed.

I've tested writing hostip in multiple games now to see what will happen, none of them will print out the hostip.

DOD says: "hostip" = "-1062731419"
TF2 says: "hostip" = "-1062731566"
HL2DM says: "hostip" = "-1135168212"

So the plugin is still not working unfortunately, but we're getting close ! lol.

Last edited by doze; 04-05-2016 at 10:56.
doze is offline
Naydef
Senior Member
Join Date: Dec 2015
Location: Doom Town, Nevada
Old 04-05-2016 , 10:59   Re: Make a plugin run only if server IP = 1.1.1.1
#29

Quote:
Originally Posted by doze View Post
Many thanks man, you're a good guy that actually understands what i am talking about and doesn't fill up the thread with nothingness, some bacon for you my good sir

There seems to be a problem however with Source that makes the plugin not work.

When writing hostip in console (server or client) the server IP will not be displayed.

I've tested writing hostip in multiple games now to see what will happen, none of them will print out the hostip.

DOD says: "hostip" = "-1062731419"
TF2 says: "hostip" = "-1062731566"
HL2DM says: "hostip" = "-1135168212"

So the plugin is still not working unfortunately, but we're getting close ! lol.
PHP Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "BailaRazor"
#define PLUGIN_VERSION "1.00"

//#include <sourcemod>
//#include <sdktools>
//#include <cstrike>
//#include <sdkhooks>

public Plugin myinfo 
{
    
name "Run plugin only on specific IP"
    
author PLUGIN_AUTHOR
    
description "Run plugin only on specific IP"
    
version PLUGIN_VERSION
    
url ""
};

public 
void OnPluginStart()
{
    static 
Handle conip INVALID_HANDLE;
    
conip FindConVar("hostip");
    
SomeAction();
}

public 
void SomeAction()
{
    new 
pieces[4];
    new 
longip GetConVarInt(conip);
    
    
pieces[0] = (longip >> 24) & 0x000000FF;
    
pieces[1] = (longip >> 16) & 0x000000FF;
    
pieces[2] = (longip >> 8) & 0x000000FF;
    
pieces[3] = longip 0x000000FF;

    
Format(buffersize"%d.%d.%d.%d"pieces[0], pieces[1], pieces[2], pieces[3]);
    if(
StrEqual(buffer"1.1.1.1"))
    {
        
PrintToChatAll("Server IP is 1.1.1.1 and plugin is loaded");
    }
    else
    {
        
PrintToChatAll("Server IP isn't 1.1.1.1 and plugins is unloaded");
        
SetFailState("Server isn't running on allowed IP address");
    }
}

//Here you can put your own code, plugin can access this code only when server running on 1.1.1.1, else it will be on fail state "unloaded" 
__________________
My plugins:
*None for now*


Steam:
naydef

Last edited by Naydef; 04-05-2016 at 11:06.
Naydef is offline
doze
Senior Member
Join Date: Mar 2012
Old 04-05-2016 , 11:22   Re: Make a plugin run only if server IP = 1.1.1.1
#30

Quote:
Originally Posted by Naydef View Post
PHP Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "BailaRazor"
#define PLUGIN_VERSION "1.00"

//#include <sourcemod>
//#include <sdktools>
//#include <cstrike>
//#include <sdkhooks>

public Plugin myinfo 
{
    
name "Run plugin only on specific IP"
    
author PLUGIN_AUTHOR
    
description "Run plugin only on specific IP"
    
version PLUGIN_VERSION
    
url ""
};

public 
void OnPluginStart()
{
    static 
Handle conip INVALID_HANDLE;
    
conip FindConVar("hostip");
    
SomeAction();
}

public 
void SomeAction()
{
    new 
pieces[4];
    new 
longip GetConVarInt(conip);
    
    
pieces[0] = (longip >> 24) & 0x000000FF;
    
pieces[1] = (longip >> 16) & 0x000000FF;
    
pieces[2] = (longip >> 8) & 0x000000FF;
    
pieces[3] = longip 0x000000FF;

    
Format(buffersize"%d.%d.%d.%d"pieces[0], pieces[1], pieces[2], pieces[3]);
    if(
StrEqual(buffer"1.1.1.1"))
    {
        
PrintToChatAll("Server IP is 1.1.1.1 and plugin is loaded");
    }
    else
    {
        
PrintToChatAll("Server IP isn't 1.1.1.1 and plugins is unloaded");
        
SetFailState("Server isn't running on allowed IP address");
    }
}

//Here you can put your own code, plugin can access this code only when server running on 1.1.1.1, else it will be on fail state "unloaded" 
Fails to compile.

error 017: undefined symbol "conip"
error 017: undefined symbol "buffer"
error 017: undefined symbol "buffer"

3 Errors.
doze 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 03:33.


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