AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Req] Socket steamid validation (https://forums.alliedmods.net/showthread.php?t=215660)

ecca 05-10-2013 19:43

[Req] Socket steamid validation
 
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.

fysiks 05-10-2013 19:56

Re: [Req] Socket steamid validation
 
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.

ecca 05-10-2013 19:58

Re: [Req] Socket steamid validation
 
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




All times are GMT -4. The time now is 16:21.

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