Hdpath?
#1

Here is the code I got when I followed this tutorial:
https://sampwiki.blast.hk/wiki/How_to_read_from_INI_files

But it doesn't work, it says hdpath is an undefined symbol.

Код:
public getINIString( filename[], section[], item[], result[] ) {
 new File:inifile;
 new line[512];
 new sectionstr[64], itemstr[64];
 new sectionfound = 0;

 inifile = fopen( filename, io_read );
 if( !inifile ) {
  printf( "FATAL: Couldn't open \"%s\"!", hdpath );
  return 0;
 }

 format( sectionstr, 64, "[%s]", section );
 format( itemstr, 64, "%s=", item );

 while( fread( inifile, line )) {
  line[strlen( line )-2] = 0; /* Remove \r\n */

  if( line[0] == 0 ) {
   continue;
  }

  /* If !sectionfound is true, we're looking for the proper section. */
  if( !sectionfound ) {
   /* Check if wanted section is being opened. */
   if( !strcmp( line, sectionstr, true, strlen( sectionstr ))) {
    sectionfound = 1;
   }
  }
  else { /* Itemmode from here. */
   /* We're leaving the wanted section and didn't find the value yet.
    * So we'll never reach it. */
   if( line[0] == '[' ) {
    return 0;
    }

   /* Have we reached our wanted INI item? */
   if( !strcmp( line, itemstr, true, strlen( itemstr ))) {
    format( result, sizeof( line ), "%s", line[strlen( itemstr )] );
    return 1;
   }
  }
 }

 fclose( inifile );
 return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)