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

[Req] Socket steamid validation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ecca
Sexy Santa
Join Date: Jan 2011
Old 05-10-2013 , 19:43   [Req] Socket steamid validation
Reply With Quote #1

Good evening.

Since it was a pretty long time i wrote a amxx plugin and i've gone to SourceMod i need your help with a simple plugin.

Simply what it need todo is send a socket request to specific server with steamid and validate incoming data. I need to split the string where the character & is and later check if the value is equal to a 0 or 1. If it's equal to 0 it should kick them out.

Thanks in advance.
__________________
ecca is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-10-2013 , 19:56   Re: [Req] Socket steamid validation
Reply With Quote #2

Look at examples, tutorials, or plugins that use sockets to learn about sockets. Try to write it then if you have specific issues with specific parts after you have written and tested it then you can post here asking about those specific issues.
__________________
fysiks is offline
ecca
Sexy Santa
Join Date: Jan 2011
Old 05-10-2013 , 19:58   Re: [Req] Socket steamid validation
Reply With Quote #3

Here is what i wrote , but i crashed the server for some reason.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sockets>

new const g_szURLHost128 ] = "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_openg_szURLHost80SOCKET_TCPiError );
    
    if( 
iError )
    {
        new 
szError128 ];
        
formatexszErrorcharsmaxszError ), "Socket error: %i"iError );
        
set_fail_stateszError );
        return;
    }
    
    
g_bFoundHeader false;
    
    
g_fStartTime get_gametime();
    
g_iFailCounter 0;
    
g_bSetFinish false;
    
    new 
szDataPacket[512];
    new 
steamid[24];
    
get_user_authid(idsteamidcharsmax(steamid));
    new 
iLen formatex(szDataPacketcharsmax(szDataPacket), "GET /%s%s HTTP/1.1^r^nHost: %s^r^n^r^n""someurl"steamid"www.playstar.se");
    
    
socket_sendg_hSocketszDataPacketiLen );
    
    
set_task0.1"TaskReadData"123__"b" );
}

public 
TaskReadData( )
{
    if( 
socket_changeg_hSocket ) )
    {
        static 
szBuffer1024 ];
        new 
iLen socket_recvg_hSocketszBuffercharsmaxszBuffer ) );
        
        new 
iStart;
        
        if( !
g_bFoundHeader )
        {
            new 
iPos containszBuffer"^r^n^r^n" );
            
            if( 
iPos != -)
            {
                
iStart iPos 4;
            }
            
            
g_bFoundHeader true;
        }
        
        new 
szOutput[64][128];
        
        
ExplodeStringszOutput64127szBuffer'&' );
        
        
server_print("%s"szOutput[0]);
        
        if( !
g_bSetFinish )
        {
            
g_bSetFinish true;
            
set_task5.0"TaskCheckData" );
        }
    }
}

public 
TaskCheckData( )
{
    
remove_task123 );
    
    
socket_closeg_hSocket );
}

stock ExplodeStringp_szOutput[][], p_nMaxp_nSizep_szInput[], p_szDelimiter )
{
    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

__________________

Last edited by ecca; 05-11-2013 at 05:27.
ecca 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:24.


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