Raised This Month: $ Target: $400
 0% 

Server IP


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 04-24-2013 , 19:51   Server IP
Reply With Quote #1

hi
How i can read server ip?
I want set the Server IP in a Hud, but i dont want use hardcode because i have more then one server, and is better if i can use same plugin for all servers
__________________
Jhob94 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-24-2013 , 21:27   Re: Server IP
Reply With Quote #2

get_user_ip(0, ...

or

get the "ip" cvar (I think it's a cvar)
__________________

Last edited by fysiks; 04-24-2013 at 21:27.
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-25-2013 , 00:58   Re: Server IP
Reply With Quote #3

"ip" cvar can be false.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-25-2013 , 12:36   Re: Server IP
Reply With Quote #4

net_address..

EDIT:

PHP Code:
#include <amxmodx>

new p_Server;
new 
g_szServer[32];

public 
plugin_init()
{
    
register_plugin("Server IP in Hud Text",AMXX_VERSION_STR,"SmileY");
    
    
p_Server get_cvar_pointer("net_address");
}

public 
plugin_cfg()
{
    
get_pcvar_string(p_Server,g_szServer,charsmax(g_szServer));
    
    
ServerIP();
}

public 
ServerIP()
{
    
set_hudmessage(random_num(50,255),random_num(50,255),random_num(50,255),0.02,0.9,1,6.0,30.0, .channel=4);
    
show_hudmessage(0,"Server Address: %s",g_szServer);
    
    
set_task(20.0,"ServerIP",1337);

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 04-25-2013 at 12:45. Reason: :P
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-25-2013 , 23:19   Re: Server IP
Reply With Quote #5

Quote:
Originally Posted by ^SmileY View Post
PHP Code:
#include <amxmodx>

new p_Server;
new 
g_szServer[32];

public 
plugin_init()
{
    
register_plugin("Server IP in Hud Text",AMXX_VERSION_STR,"SmileY");
    
    
p_Server get_cvar_pointer("net_address");
}

public 
plugin_cfg()
{
    
get_pcvar_string(p_Server,g_szServer,charsmax(g_szServer));
    
    
ServerIP();
}

public 
ServerIP()
{
    
set_hudmessage(random_num(50,255),random_num(50,255),random_num(50,255),0.02,0.9,1,6.0,30.0, .channel=4);
    
show_hudmessage(0,"Server Address: %s",g_szServer);
    
    
set_task(20.0,"ServerIP",1337);

i'll use this method from now on.... as you say its a better solution.
__________________
Blizzard_87 is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 04-25-2013 , 18:05   Re: Server IP
Reply With Quote #6

Thanks all.
But fysiks are you sure get_user_ip(0,...) will show server ip?
__________________
Jhob94 is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-25-2013 , 20:52   Re: Server IP
Reply With Quote #7

Quote:
Originally Posted by Jhob94 View Post
Thanks all.
But fysiks are you sure get_user_ip(0,...) will show server ip?
yep its how I check that my plugin is loaded on my server and noone elses.

Code:
public Check_Legal() {     new szIp[22];     get_user_ip(0, szIp, charsmax(szIp));     if(!equal(szIp, SERVERIP))     {         Plugin_Protection()         return PLUGIN_HANDLED;     }     console_print(0, "* Registered Server Detected *");     console_print(0, "* Registered Server Detected *");     console_print(0, "* Registered Server Detected *");         return PLUGIN_HANDLED; }
__________________
Blizzard_87 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-25-2013 , 22:48   Re: Server IP
Reply With Quote #8

get the fuc*ing net_address! its always shows a real IP..

the ip cvar its only works if used in command line of HLDS like: ./hlds_run -game cstrike +ip xxx.xxx.xxx.xxx

Ps.
For get a: xxx.xxx.xxx.xxx:27015 for example, you need to get 2 cvars: ip cvar and port cvar

And later use in a string or in a format() funcions... net_address its only use one cvar

>>
Quote:
Originally Posted by Blizzard_87 View Post
yep its how I check that my plugin is loaded on my server and noone elses.

Code:
public Check_Legal() {     new szIp[22];     get_user_ip(0, szIp, charsmax(szIp));     if(!equal(szIp, SERVERIP))     {         Plugin_Protection()         return PLUGIN_HANDLED;     }     console_print(0, "* Registered Server Detected *");     console_print(0, "* Registered Server Detected *");     console_print(0, "* Registered Server Detected *");         return PLUGIN_HANDLED; }

Send-me any plugin with using this and i will be breaking whole file using a fake cvars..
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 04-25-2013 at 22:51.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Old 04-25-2013, 23:14
Blizzard_87
This message has been deleted by Blizzard_87.
Reply


Thread Tools
Display Modes

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 10:54.


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