Load from scriptfile
#6

You can do a while loop with the function fread, like so
pawn Код:
new
    string[ 128 ]; //I'm only making 128 cells to be sure you can fit an entire line of the txtfile
while( fread( hFile, string )) //This will read line-by-line and store the line being read at the moment into the variable 'string'
{
}
Now. The content of the while loop is where you extract the information from the line. The way it's formatted, the delimiter for each information is ", ". To get each and every data by know the delimiter, you can either use a custom function called "split" (search for it) or you can use sscanf by ******:

pawn Код:
for(new i = 0; i < MAX_PROPS; i++) //replace MAX_PROPS with the number of props you've got
{
    sscanf( string, "e<p<, >s[24]fffiiis[24]>", PropInfo[i] ); //this will store all the info into propinfo
    //do your stuff
}
EDIT

Do not under ANY circumstances use my code as 1. It won't probably work. 2. It's full of flaws.
Just use my code as an "inspiration" and try searching for similar codes. I recommend searching for the keywords "sscanf fread delimiter enum"
Reply


Messages In This Thread
Load from scriptfile - by Fernado Samuel - 11.12.2012, 22:45
Re: Load from scriptfile - by LarzI - 11.12.2012, 23:43
Re: Load from scriptfile - by Fernado Samuel - 11.12.2012, 23:59
Re: Load from scriptfile - by Jefff - 12.12.2012, 00:27
Re: Load from scriptfile - by Lordzy - 12.12.2012, 00:33
Re: Load from scriptfile - by LarzI - 12.12.2012, 00:40
Re: Load from scriptfile - by Fernado Samuel - 12.12.2012, 06:25
Re: Load from scriptfile - by LarzI - 12.12.2012, 14:10

Forum Jump:


Users browsing this thread: 1 Guest(s)