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
Author Message
doze
Senior Member
Join Date: Mar 2012
Old 04-04-2016 , 17:40   Make a plugin run only if server IP = 1.1.1.1
#1

Hello,

Some help will be very appreciated with this.

Do you guys know how i can make a sourcemod plugin run only if the server IP = 1.1.1.1

If the server IP is another one than the listed one, i would like the plugin to not run any of its code and instead print a public chat message.

Thank you.
doze is offline
Naydef
Senior Member
Join Date: Dec 2015
Location: Doom Town, Nevada
Old 04-04-2016 , 17:43   Re: Make a plugin run only if server IP = 1.1.1.1
#2

Easy, but the question is WHY?
__________________
My plugins:
*None for now*


Steam:
naydef
Naydef is offline
doze
Senior Member
Join Date: Mar 2012
Old 04-04-2016 , 17:49   Re: Make a plugin run only if server IP = 1.1.1.1
#3

Quote:
Originally Posted by Naydef View Post
Easy, but the question is WHY?
So i can share the plugin only with servers i want to.

How can i do it ?

Last edited by doze; 04-04-2016 at 17:50.
doze is offline
BAILANDO
Senior Member
Join Date: Feb 2015
Location: Slovakia
Old 04-04-2016 , 18:11   Re: Make a plugin run only if server IP = 1.1.1.1
#4

Code:
#pragma semicolon 1 #define DEBUG #define PLUGIN_AUTHOR "BailaRazor" #define PLUGIN_VERSION "1.00" //#include <sourcemod> //#include <sdktools> //#include <cstrike> //#include <sdkhooks> static char ip[30]; 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");     GetConVarString(conip, ip, 30); } public void SomeAction() {     //Run only when IP is 1.1.1.1     if (StrEqual(ip, "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");         ServerCommand("sm plugins unload PluginName");     } }
Attached Files
File Type: sp Get Plugin or Get Source (onlyonspecificip.sp - 285 views - 867 Bytes)
BAILANDO is offline
doze
Senior Member
Join Date: Mar 2012
Old 04-04-2016 , 18:21   Re: Make a plugin run only if server IP = 1.1.1.1
#5

Quote:
Originally Posted by BAILANDO View Post
Code:
#pragma semicolon 1 #define DEBUG #define PLUGIN_AUTHOR "BailaRazor" #define PLUGIN_VERSION "1.00" //#include <sourcemod> //#include <sdktools> //#include <cstrike> //#include <sdkhooks> static char ip[30]; 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");     GetConVarString(conip, ip, 30); } public void SomeAction() {     //Run only when IP is 1.1.1.1     if (StrEqual(ip, "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");         ServerCommand("sm plugins unload PluginName");     } }
Thanks for the reply.

But ServerCommand("sm plugins unload PluginName"); will only work as long as the plugin name is kept ? I'd like it to unload it regardless of the name the plugin has.

Also, where will i put my existing code for the plugin that i want to modify, i am guessing i will copy paste the entire plugin over PrintToChatAll("Server IP is 1.1.1.1 and plugin is loaded"); , correct ?
doze is offline
psychonic

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

Quote:
Originally Posted by doze View Post
So i can share the plugin only with servers i want to.
But you can only share the plugin binary if you are also sharing the source code, so unless their keyboards are missing the "Delete" key, the check is trivially removed.
psychonic is offline
doze
Senior Member
Join Date: Mar 2012
Old 04-04-2016 , 18:58   Re: Make a plugin run only if server IP = 1.1.1.1
#7

Quote:
Originally Posted by psychonic View Post
But you can only share the plugin binary if you are also sharing the source code, so unless their keyboards are missing the "Delete" key, the check is trivially removed.
Yes, i will only share the binary.

Last edited by doze; 04-04-2016 at 18:58.
doze is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 04-04-2016 , 19:07   Re: Make a plugin run only if server IP = 1.1.1.1
#8

Quote:
Originally Posted by doze View Post
Yes, i will only share the binary.
This is an illegal violation of the license that you agreed to when you used AlliedModders software to create your plugin. If you are giving out the binary, you MUST also provide the source. Failure to do so can result in your plugin being blacklisted from running on all SourceMod servers.
__________________

Last edited by ddhoward; 04-04-2016 at 19:07.
ddhoward is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-04-2016 , 19:12   Re: Make a plugin run only if server IP = 1.1.1.1
#9

I feel the ban hammer coming down.
__________________
Neuro Toxin is offline
doze
Senior Member
Join Date: Mar 2012
Old 04-04-2016 , 19:16   Re: Make a plugin run only if server IP = 1.1.1.1
#10

Quote:
Originally Posted by ddhoward View Post
This is an illegal violation of the license that you agreed to when you used AlliedModders software to create your plugin. If you are giving out the binary, you MUST also provide the source. Failure to do so can result in your plugin being blacklisted from running on all SourceMod servers.
Oh dear God, i hope you won't report me to the police.

http://i3.kym-cdn.com/photos/images/...80/696/abe.jpg

Last edited by doze; 04-04-2016 at 19:24.
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 08:42.


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