Here is what i wrote , but i crashed the server for some reason.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sockets>
new const g_szURLHost[ 128 ] = "playstar.se";
new g_hSocket;
new bool:g_bFoundHeader;
new g_iIndex;
new g_iFailCounter;
new Float:g_fStartTime;
new bool:g_bSetFinish;
public plugin_init( )
{
register_plugin( "Playstar steamidTools", "1.0", "ecca" );
}
public client_authorized(id)
{
new iError;
g_hSocket = socket_open( g_szURLHost, 80, SOCKET_TCP, iError );
if( iError )
{
new szError[ 128 ];
formatex( szError, charsmax( szError ), "Socket error: %i", iError );
set_fail_state( szError );
return;
}
g_bFoundHeader = false;
g_fStartTime = get_gametime();
g_iFailCounter = 0;
g_bSetFinish = false;
new szDataPacket[512];
new steamid[24];
get_user_authid(id, steamid, charsmax(steamid));
new iLen = formatex(szDataPacket, charsmax(szDataPacket), "GET /%s%s HTTP/1.1^r^nHost: %s^r^n^r^n", "someurl", steamid, "www.playstar.se");
socket_send( g_hSocket, szDataPacket, iLen );
set_task( 0.1, "TaskReadData", 123, _, _, "b" );
}
public TaskReadData( )
{
if( socket_change( g_hSocket ) )
{
static szBuffer[ 1024 ];
new iLen = socket_recv( g_hSocket, szBuffer, charsmax( szBuffer ) );
new iStart;
if( !g_bFoundHeader )
{
new iPos = contain( szBuffer, "^r^n^r^n" );
if( iPos != -1 )
{
iStart = iPos + 4;
}
g_bFoundHeader = true;
}
new szOutput[64][128];
ExplodeString( szOutput, 64, 127, szBuffer, '&' );
server_print("%s", szOutput[0]);
if( !g_bSetFinish )
{
g_bSetFinish = true;
set_task( 5.0, "TaskCheckData" );
}
}
}
public TaskCheckData( )
{
remove_task( 123 );
socket_close( g_hSocket );
}
stock ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
{
new nIdx = 0, l = strlen(p_szInput)
new nLen = (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput, p_szDelimiter ))
while( (nLen < l) && (++nIdx < p_nMax) )
nLen += (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput[nLen], p_szDelimiter ))
return
}
__________________