This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

strbreak? in parse ip from file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
avril-lavigne
Banned
Join Date: Apr 2009
Old 05-10-2015 , 07:43   strbreak? in parse ip from file
Reply With Quote #1

Im new to parsing files. I want to randomly choose Ip from list

PHP Code:
 new readdata[128]
        new 
parsedip[33]
        
        while(
fgets(filepointer,readdata,127))
    {
             
parse(readdata,parsedip32)  
             
server_print("%s"parsedip
     } 
All just fine , it gets 3 ip from my list
but how to select elements in string

I want something like parsedips[random_num(0,2)]

random selected ips
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 05-10-2015 , 08:01   Re: strbreak? in parse ip from file
Reply With Quote #2

PHP Code:
new parsedip[3][33]
new 
readdata[128]

while(
fgets(filepointer,readdata,charsmax(readdata))) 

     
parse(readdataparsedip[0], charsmax(pasedip[]), parsedip[1], charsmax(pasedip[]), parsedip[2], charsmax(pasedip[]))   
     
server_print("%s"parsedip[random_num(02)])  

Well, it should look like:
IP1 IP2 IP3

If it looks like:
IP1
IP2
IP3
You could do something like this:
PHP Code:
#define MAX_IPS 3

new parsedip[MAX_IPS][33]
new 
iCount
new readdata[128]

while(
fgets(filepointer,readdata,charsmax(readdata))) 

     
parse(readdataparsedip[iCount], charsmax(pasedip[]))   
         
     if(
iCount MAX_IPS 1)
         
iCount++
}

server_print("%s"parsedip[random_num(0iCount-1)]) 
__________________

Last edited by Jhob94; 05-10-2015 at 08:13. Reason: forgot to register readdata >.>
Jhob94 is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 05-10-2015 , 10:53   Re: strbreak? in parse ip from file
Reply With Quote #3

thanks, it works
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-10-2015 , 12:24   Re: strbreak? in parse ip from file
Reply With Quote #4

The condition of the while loop should be "!feof(filepointer) && iCount < sizeof(parsedip)"
__________________
fysiks is online now
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 21:41.


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