View Single Post
Xablau
Member
Join Date: Dec 2014
Old 01-05-2015 , 06:15   Re: [ socket_recv + json/data ]
Reply With Quote #9

PHP Code:
public client_putinserver(id)
{
    
get_data(id)
}
public 
get_data(id
{
    new 
ip[16], server[16], nick[32],steamid[32], errorsendbuffer[512]
    
get_user_ip(0,ip,63,0)
    
get_user_name(id,nick31)
    
get_user_authid(id,steamid,31)
    
    
g_Socket socket_open("site.com"80SOCKET_TCPerror
    
    
format(sendbuffer511"GET %s HTTP/1.1^nHost:site.com^r^n^r^n""/player.php?steamid=%s&ip=%s&nick=%s"steamidipnick)
    
socket_send(g_Socketsendbuffer511)
    
    const 
SIZE 63
    
new line_variable[SIZE 1], line_value[SIZE 1]
    
    if (
socket_change(g_Socket))
    {
        new 
lines[30][100], count 0
        socket_recv
(g_Socketg_Data511)
        
count ExplodeString(lines50119g_Data13)
        for(new 
i=0;i<count;i++)
        {
            
parse(lines[i], line_variableSIZEline_valueSIZE)
            if (
equal(line_variable"max_hp"))
                
set_user_health(idline_value)
            if (
equal(line_variable"max_armor"))
                
set_user_armor(idline_value)
        }   
    }
    
socket_close(g_Socket
}
stock ExplodeStringp_szOutput[][], p_nMaxp_nSizep_szInput[], p_szDelimiter ) { // Function by xeroblood
    
new nIdx 0strlen(p_szInput)
    new 
nLen = (copycp_szOutput[nIdx], p_nSizep_szInputp_szDelimiter ))
    while( (
nLen l) && (++nIdx p_nMax) )
        
nLen += (copycp_szOutput[nIdx], p_nSizep_szInput[nLen], p_szDelimiter ))
    return 
nIdx

Work on player.php, example:

"max_hp" "110"
"max_armor" "120"
"value" "data"
...

I need error:

Error: Argument type mismatch (argument 2) on line 45
Line 45:
PHP Code:
set_user_health(idline_value
How to fix?

Last edited by Xablau; 01-05-2015 at 06:22.
Xablau is offline