Raised This Month: $ Target: $400
 0% 

wan and lan download urls


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 01-02-2013 , 10:48   wan and lan download urls
Reply With Quote #1

#include <amxmodx>

new wl_downloadurl, ip_adrr[16]

public plugin_init()
{
register_plugin("wanorlan", "0.1beta", "mockBa")
wl_downloadurl = get_cvar_pointer("sv_downloadurl")
}

public client_connect(id)
{
get_user_ip(id, ip_adrr, 15, 1)

if(!equali(ip_adrr, "10.", 3))
{
set_pcvar_string(wl_downloadurl, "http://10.91.140.125/cstrike/")
}
else
{
set_pcvar_string(wl_downloadurl, "http://mydomain/cstrike/")
}
}

I have sv_downloadurl "http://mydomain/cstrike/", but LAN users, without Internet, can't download files. Can you help me with script for switching urls for LAN and WAN users? LAN users from 10.0.0.0/8

The script works, I want to hear your advice about using it.

Last edited by ZASTRELIS; 01-02-2013 at 10:56.
ZASTRELIS is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 01-02-2013 , 15:21   Re: wan and lan download urls
Reply With Quote #2

Try:
PHP Code:
#include <amxmodx>

new wl_downloadurlip_adrr[24];

public 
plugin_init(){
    
register_plugin("wanorlan""0.1beta""mockBa");
    
wl_downloadurl get_cvar_pointer("sv_downloadurl");
}

public 
client_connect(id){
    
get_user_ip(idip_adrr231);

    if(
contain(ip_adrr"10.") != -1)
        
set_pcvar_string(wl_downloadurl"http://10.91.140.125/cstrike/");
    else
        
set_pcvar_string(wl_downloadurl"http://mydomain/cstrike/");

__________________
simanovich is offline
AngeIII
Senior Member
Join Date: Sep 2007
Location: Latvia
Old 01-02-2013 , 16:15   Re: wan and lan download urls
Reply With Quote #3

simanovich it is totally same.. you just use more memory for ip_adrr array and check with contain function, but really is better to check with equal only first three symbols. (first code).

as for setting sv_downloadurl a lot of times.. some times when players join to server (two or more players at one time, e.g. at map change).
sv_downloadurl can sometimes for LAN players http://mydomain/cstrike/. cause plugin can with this sequence:

LAN JOIN:
http://10.91.140.125/cstrike/
WAN JOIN:
http://mydomain/cstrike/

LAN+WAN JOIN(BOTH):
http://10.91.140.125/cstrike/
WAN+LAN JOIN(BOTH): http://mydomain/cstrike/

what is better to use.. mhm maybe your own website lan..(localhost)
__________________
skype: pavle_ivanof
-=ThQ=-
PRIVATE SUPPORT = PAID SUPPORT
AngeIII is offline
Send a message via Skype™ to AngeIII
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-02-2013 , 20:17   Re: wan and lan download urls
Reply With Quote #4

You are lucky that your code works.

An observation: If your server is on the internet and it's also on LAN then all computers on that LAN have access to the internet .
__________________
fysiks is offline
Reply



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 13:45.


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