Looping through lines using y_ini - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Looping through lines using y_ini (
/showthread.php?tid=473364)
Looping through lines using y_ini -
Tagathron - 02.11.2013
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......
Re: Looping through lines using y_ini -
gtakillerIV - 02.11.2013
You can't, from what I know.
Re: Looping through lines using y_ini -
erminpr0 - 02.11.2013
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
Re: Looping through lines using y_ini -
Ada32 - 02.11.2013
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.
Re: Looping through lines using y_ini -
Tagathron - 02.11.2013
Ada,i'm asking HOW to loop through the lines.
Re: Looping through lines using y_ini -
Ada32 - 02.11.2013
https://sampwiki.blast.hk/wiki/File_Functions
Look for "File Functions: Reading Files"