Raised This Month: $51 Target: $400
 12% 

[REQ.] Switch Server or (Fake server)


Post New Thread Reply   
 
Thread Tools Display Modes
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-03-2010 , 13:11   Re: [REQ.] Switch Server or (Fake server)
Reply With Quote #11

Sylwester, I was making this myself for him, but I have no anger towards you that you released yours.
I'm just curious how you would read the floated time value from that byte code because I finally found the pattern but I could not read the float.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-03-2010 , 15:54   Re: [REQ.] Switch Server or (Fake server)
Reply With Quote #12

I skipped reading player time since it was impossible to change played time of a fakeclient.
Anyway, converting those bits to float is not so hard. Here is a fragment of a receive_data() function from my DuplicateServerInfo plugin with reading time included:
PHP Code:
public receive_data(){
    static 
cache[2048], len
    len 
socket_recv(g_socketcache2047)
    if(
len 5)
        return
    if(!
equalcache, { -1, -1, -1, -}, ) )
        return
    if(
cache[4] == 'D'){ //(players details) A2S_PLAYER reply if sent challange number is correct
        
g_s_players cache[5]

        new 
j=6
        
for(new i=0i<g_s_playersi++){
            
j++
            
+= copyc(g_s_player_name[i], 31cache[j], 0)+1
            
if(cache[j+3] < 0){ //negative number
                
g_s_player_kills[i] = -((((255-ret_ac(cache[j+3]))*256+255-ret_ac(cache[j+2]))*256+255-ret_ac(cache[j+1]))*256+255-ret_ac(cache[j])+1)
            }else{
//positive number
                
g_s_player_kills[i] = (((ret_ac(cache[j+3])*256)+ret_ac(cache[j+2]))*256+ret_ac(cache[j+1]))*256+ret_ac(cache[j])
            }

            
/* reading player time - start */
            
new time_bits
            
for(new k=7k>=4k--){
                
time_bits<<=8
                time_bits
+=ret_ac(cache[j+k])
            }
            new 
Float:time Float:time_bits
            
/* reading player time - end */

            
j+=8
        
}
        
update_players()
    }

//..... 
__________________
Impossible is Nothing
Sylwester is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 10-03-2010 , 16:30   Re: [REQ.] Switch Server or (Fake server)
Reply With Quote #13

hey , sylwester , can you make a simple plugin to look the map is remaiding X server ?

Ex : [AMXX] The ip xxx.xxx.xxx.xxx:27015 is now in map 'de_dust2' with 0/16 Players!
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-03-2010 , 17:49   Re: [REQ.] Switch Server or (Fake server)
Reply With Quote #14

I'm not sure if this is what you wanted:
PHP Code:
#include <amxmodx>
#include <sockets>

new g_socket 0
new g_host[32]
new 
g_port

public plugin_init(){
    
register_plugin("Server Info""1.0""Sylwester")
    
register_concmd("amx_server_info""cmd_server_info")
}

public 
cmd_server_info(id){
    new 
tmp[64], tmp2[32], error
    read_args
(tmp63)
    
remove_quotes(tmp)
    
strtok(tmpg_host63tmp231':')
    
g_port str_to_num(tmp2)
    if(
g_socket != 0){
        
socket_close(g_socket)
        
g_socket 0
    
}
    
g_socket socket_open(g_hostg_portSOCKET_UDPerror)
    if(
g_socket <= || error){
        new 
error_msg[64]
        switch(
error){
            case 
0error_msg "unknown"
            
case 1error_msg "error while creating socket"
            
case 2error_msg "could not resolve hostname"
            
case 3format(error_msg63"could not connect to %s:%d"g_hostg_port)
        }
        
client_print(idprint_console"Socket error: %s"error_msg)
        return
    }
    new 
cache[32]
    
format(cache25"%c%c%c%c%c%s%c"25525525525584"Source Engine Query")
    
socket_send2(g_socketcache25)
    
set_task(0.1"check_socket")
}

public 
check_socket(){
    static 
cnt
    cnt
++
    if(
g_socket <= 0){
        
cnt 0
        
return
    }
    if(
socket_change(g_socket1)){
        
receive_data()
    }
    if(
cnt!=20)
        
set_task(0.1"check_socket")
    else
        
cnt=0
}

public 
receive_data(){
    static 
cache[2048], lenhostname[64], map[64], playersmaxplayersdir[64], game_desc[64]
    
len socket_recv(g_socketcache2047)
    if(
len 5)
        return
    if(!
equalcache, { -1, -1, -1, -}, ) )
        return
    if(
cache[4] == 'I'){ //(server details) A2S_INFO reply
        
new 6
        i 
+= copyc(hostname127cache[i], 0)+1
        i 
+= copyc(map63cache[i], 0)+1
        i 
+= copyc(dir63cache[i], 0)+1
        i 
+= copyc(game_desc63cache[i], 0)+1
        players 
cache[i+2]
        
maxplayers cache[i+3]
        
client_print(0print_chat"Server @ ^"%s:%d^": %s ## Map: %s ## Players: %d/%d"g_hostg_porthostnamemapplayersmaxplayers)
        if(
g_socket != 0){
            
socket_close(g_socket)
            
g_socket 0
        
}
    }

write: amx_server_info "ip:port"
in console.
__________________
Impossible is Nothing
Sylwester is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 10-03-2010 , 18:04   Re: [REQ.] Switch Server or (Fake server)
Reply With Quote #15

Thanks Awesome! i go to test

EDIT : Works very good , thnx.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.

Last edited by lucas_7_94; 10-03-2010 at 18:11.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
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 07:15.


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