Raised This Month: $ Target: $400
 0% 

Breaking socket data on lines?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AoD90
Senior Member
Join Date: Jul 2008
Location: Ugljevik/RS/BIH
Old 04-26-2011 , 09:11   Breaking socket data on lines?
Reply With Quote #1

How can I break received socket data into lines so I can read line by line?
AoD90 is offline
Send a message via MSN to AoD90
AoD90
Senior Member
Join Date: Jul 2008
Location: Ugljevik/RS/BIH
Old 04-26-2011 , 10:19   Re: Breaking socket data on lines?
Reply With Quote #2

nvm

I just used:

Code:
new ExplodedStrings[10][16]
        
        new Count = ExplodeString( ExplodedStrings, 10, 16, g_Data, '^n' )
        
        for(new i=0; i<=Count; i++)
        {
            log_amx("%s", ExplodedStrings[i])
        }
with
Code:
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 nIdx
}
AoD90 is offline
Send a message via MSN to AoD90
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-26-2011 , 20:00   Re: Breaking socket data on lines?
Reply With Quote #3

ehm , lets say
that your variable that the socket stores the new data is

data[900]

you can simple do it with

server_print("%s\n\r",data)
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-26-2011 , 20:04   Re: Breaking socket data on lines?
Reply With Quote #4

Quote:
Originally Posted by ProIcons View Post
ehm , lets say
that your variable that the socket stores the new data is

data[900]

you can simple do it with

server_print("%s\n\r",data)
He wanted to find separate lines within the variable.

Example:
Code:
new data[128]; copy(data, charsmax(data), "oh, line #1^r^nline #2^r^nand look like #3!^r^n^r^na blank line betwen!");

To find those you would use the ExplodeString() like he did or this:

Code:
new line[32]; while(data[0]) {     strtok(data, line, charsmax(line), data, charsmax(data), '^n');         // line variable is one of those lines. }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


Thread Tools
Display Modes

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 04:18.


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