Scripting/Squirrel/Functions/ReadIniNumber

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing

This function reads a float value from an .ini file.

Syntax

float ReadIniNumber( string filename, string section, string var )

Arguments

  • filename This is the name of the file
  • section The section that contains the value you want to read
  • var The name of the variable

Example

This example will teleport the player to a previously saved location when they type '/c gotoloc LocationName'.

function onPlayerCommand( player, command, text ) {

    local x = ReadIniNumber( "Locations.ini", text, "x" ),
          y = ReadIniNumber( "Locations.ini", text, "y" ),
          z = ReadIniNumber( "Locations.ini", text, "z" );
    if ( x )
    {
         local pos = Vector( x, y, z );
         player.Pos = pos;
         MessagePlayer( "Teleporting to " + text + "...", player );
    }
    else MessagePlayer( "Location " + text + " not found.", player );

}

Notes

The functions player.Pos, MessagePlayer and call OnPlayerCommand were also used in in this example. More info about them in corresponding pages.

Related Functions