AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   wan and lan download urls (https://forums.alliedmods.net/showthread.php?t=204683)

ZASTRELIS 01-02-2013 10:48

wan and lan download urls
 
#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.

simanovich 01-02-2013 15:21

Re: wan and lan download urls
 
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/");



AngeIII 01-02-2013 16:15

Re: wan and lan download urls
 
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)

fysiks 01-02-2013 20:17

Re: wan and lan download urls
 
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 :).


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

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