Scripting/Squirrel/Functions/Ini/CountIniSection

From VC-MP Wiki

Jump to: navigation, search

This function says, how many values/lines are in a selected section in an ini file.

Syntax

CountIniSection( string FileName, string Section )

Arguments

  • FileName - This is the file name
  • Section - The section name. Use without "[" and "]"

Example

To see how this works, let's create (oh yeah, again) a sample ini file 'hola.ini'. You can copy and paste this:

[Players]
1 = TheTammer
2 = TheSpaner
3 = TheHaxor
4 = TheCheatzor
[Nothing]
Nothing = true

We want to know how many values/lines are in the '[Players]' section. As you can see, there are 4 values in the section. But we want, that the script will tell us this.

function onServerStart()
{
     print( "There are " + CountIniSection( "hola.ini", "Players" ) + " players saved." );
}

Notes

The call onServerStart was used in in this example. More info about this in the corresponding page.

Related Functions

Personal tools
squirrel scripting