Reading line X from a file
#4

i've made that quickly, but should work properly.

PHP Code:
stock GetLine(file[] , line dest[] , size sizeof dest// in both errors, the passed string will be null;
{
    new 
File:f_file fopen(file,io_read);
    if( ( !
f_file || line ) && fclose(f_file) ) return 0// When a file fails to open, it's closed.
    
for(new i_lines fread(f_file,dest,size) ; i_lines++)
    {
        if(
line == i_lines)
        {
            
fclose(f_file);
            return 
1;
        }
    }
    
fclose(f_file);
    return -
1;
}
// here it's an example of its usage.
switch(GetLine(file[],line,dest))
{
     case -
1:
     {
          print(
"line doesn't exist");
     }
     case 
0:
     {
          print(
"couldn't handle the file or the line is invalid");
     }
     case 
1:
     {
          print(
dest);
     }

For solving your second issue, about the player spawn. You should save in the players files, in which city they was in their last logins.
Reply


Messages In This Thread
Reading line X from a file - by MP2 - 03.04.2013, 16:53
Re: Reading line X from a file - by OrMisicL - 03.04.2013, 17:16
Re: Reading line X from a file - by MP2 - 03.04.2013, 17:30
Re: Reading line X from a file - by leonardo1434 - 03.04.2013, 18:11
Re: Reading line X from a file - by AndreT - 03.04.2013, 18:19
Re: Reading line X from a file - by OrMisicL - 03.04.2013, 18:25
Re: Reading line X from a file - by leonardo1434 - 03.04.2013, 18:32

Forum Jump:


Users browsing this thread: 1 Guest(s)