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)

doze 04-04-2016 17:40

Make a plugin run only if server IP = 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.:bacon!:

Naydef 04-04-2016 17:43

Re: Make a plugin run only if server IP = 1.1.1.1
 
Easy, but the question is WHY?

doze 04-04-2016 17:49

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

Originally Posted by Naydef (Post 2408180)
Easy, but the question is WHY?

So i can share the plugin only with servers i want to.

How can i do it ?

BAILANDO 04-04-2016 18:11

Re: Make a plugin run only if server IP = 1.1.1.1
 
1 Attachment(s)
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");     } }

doze 04-04-2016 18:21

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

Originally Posted by BAILANDO (Post 2408189)
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 ?

psychonic 04-04-2016 18:53

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

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

doze 04-04-2016 18:58

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

Originally Posted by psychonic (Post 2408195)
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.

ddhoward 04-04-2016 19:07

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

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

Neuro Toxin 04-04-2016 19:12

Re: Make a plugin run only if server IP = 1.1.1.1
 
I feel the ban hammer coming down.

doze 04-04-2016 19:16

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

Originally Posted by ddhoward (Post 2408197)
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


All times are GMT -4. The time now is 20:29.

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