Looping through lines using y_ini
#1

How could you loop through lines in a .ini file,to check if there is a match for something?

For example;let's say you're making a ban ip command,and you save the player's IP into a .ini file when he is banned.
So when he tries to come back in,a function loops through the file checking if there is his IP in there......
Reply
#2

You can't, from what I know.
Reply
#3

As I know, you're not able to do that, one way is to Load those lines into string variables, and loop through vars :S
Reply
#4

Sure you can. y_ini loves name value pairing, so if you have information saved like this in a ban file

Quote:
Originally Posted by ban.ini
192.168.0.10 = John_Green
ini_load ban file, get player ip, ini_string player ip, isnull check if empty (if not, ban!).

If you save ips like this

Quote:
Originally Posted by ban.ini
192.168.0.10
192.168.0.14
you'll need to open the file, loop through each line, and compare each ip if it matches the player ip.
Reply
#5

Ada,i'm asking HOW to loop through the lines.
Reply
#6

https://sampwiki.blast.hk/wiki/File_Functions

Look for "File Functions: Reading Files"
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)