AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Make a plugin run only if server IP = 1.1.1.1 (https://forums.alliedmods.net/showthread.php?t=281190)

Maxximou5 04-04-2016 23:31

Re: Make a plugin run only if server IP = 1.1.1.1
 
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);



Mitchell 04-05-2016 00:13

Re: Make a plugin run only if server IP = 1.1.1.1
 
Quote:

Originally Posted by doze (Post 2408252)
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.

ReFlexPoison 04-05-2016 00:42

Re: Make a plugin run only if server IP = 1.1.1.1
 
This thread went on longer than it should.

BAILANDO 04-05-2016 02:17

Re: Make a plugin run only if server IP = 1.1.1.1
 
1 Attachment(s)
As Neuro Toxin say, better is SetFailState,

Spoiler

mottzi 04-05-2016 05:01

Re: Make a plugin run only if server IP = 1.1.1.1
 
Quote:

Originally Posted by doze (Post 2408231)
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.

psychonic 04-05-2016 08:55

Re: Make a plugin run only if server IP = 1.1.1.1
 
Quote:

Originally Posted by Mitchell (Post 2408263)
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.

Chdata 04-05-2016 09:41

Re: Make a plugin run only if server IP = 1.1.1.1
 
Instead of trying to block it through IP, you could make sure that you only distribute it to people you trust.

doze 04-05-2016 10:36

Re: Make a plugin run only if server IP = 1.1.1.1
 
Quote:

Originally Posted by BAILANDO (Post 2408279)
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 :bacon!::bacon!:

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.

Naydef 04-05-2016 10:59

Re: Make a plugin run only if server IP = 1.1.1.1
 
Quote:

Originally Posted by doze (Post 2408363)
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 :bacon!::bacon!:

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" 


doze 04-05-2016 11:22

Re: Make a plugin run only if server IP = 1.1.1.1
 
Quote:

Originally Posted by Naydef (Post 2408368)
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.


All times are GMT -4. The time now is 15:39.

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