AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   want to check server ip, to load plugin (https://forums.alliedmods.net/showthread.php?t=188131)

lobopack23 06-22-2012 16:59

want to check server ip, to load plugin
 
So from what I am aware of is that i need to use this

get_user_ip(0, SERVER_IP, 31)

I wanted to make a check where, if the server ip does not match the #define SERVER_IP, then the plugin will not run, and if it does plugin will run.

Any help?

mottzi 06-22-2012 17:17

Re: want to check server ip, to load plugin
 
search. Asked and answered many times.

claudiuhks 06-22-2012 17:45

Re: want to check server ip, to load plugin
 
Use this check in plugin_precache

PHP Code:

#define DEFINED_ADDRESS "1.1.1.1:27015"
new cName64 ]; get_cvar_string"net_address"cName63 );
if( 
equalcNameDEFINED_ADDRESS ) ) { /* Match */ } else { /* Does not match */ 


YamiKaitou 06-22-2012 17:50

Re: want to check server ip, to load plugin
 
Quote:

Originally Posted by claudiuhks (Post 1734076)
Use this check in plugin_precache

PHP Code:

#define DEFINED_ADDRESS "1.1.1.1:27015"
new cName64 ]; get_cvar_string"net_address"cName63 );
if( 
equalcNameDEFINED_ADDRESS ) ) { /* Match */ } else { /* Does not match */ 


get_user_ip(0 is actually faster than get_cvar_string since it must search through the entire list of cvars until if finds the one you want (hence the reason why the use of pcvars is required in new plugin releases)

lobopack23 06-23-2012 04:39

Re: want to check server ip, to load plugin
 
Ok but how would I actually check.. Like the condition?

Like this?

#define IPCHECK 1.1.1.1:27015
new serverip = get_user_ip(0, 0)

if( IPCHECK = serverip)
plugin_continue

Else
plugin_handled

YamiKaitou 06-23-2012 04:49

Re: want to check server ip, to load plugin
 
Code:
new ip[22]; get_user_ip(0, ip, charsmax(ip), 0); if (!equal(ip, "1.1.1.1:27015"))     set_fail_state("Sorry, but your IP doesn't match my hardcoded IP"); else     server_print("Yay, your IP matches my hardcoded IP, enjoy");

lobopack23 06-23-2012 05:04

Re: want to check server ip, to load plugin
 
Thx alot yami +rep


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

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