Squirrel/Server/Functions/Ini/ReadIniFloat

From Liberty Unleashed Wiki
Revision as of 01:04, 27 November 2009 by Juppi (Talk | contribs)

Jump to: navigation, search

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

Syntax

  1. float ReadIniFloat( 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 '/gotoloc LocationName'.

  1.  
  2. function OnPlayerCommand( player, command, text )
  3. {
  4. local x = ReadIniFloat( "Locations.ini", text, "x" ),
  5. y = ReadIniFloat( "Locations.ini", text, "y" ),
  6. z = ReadIniFloat( "Locations.ini", text, "z" );
  7.  
  8. if ( x )
  9. {
  10. local pos = Vector( x, y, z );
  11. SetPlayerPos( player, pos );
  12.  
  13. MessagePlayer( "Teleporting to " +text+ "...", player );
  14. }
  15.  
  16. else MessagePlayer( "Location " +text+ " not found.", player );
  17. }
  18.  

Notes

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

Related Functions

Template:Squirrel/Functions/Ini

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox