Squirrel/Server/Functions/Ini/ReadIniFloat

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: __NOTOC__ This function reads a float value from an .ini file. == Syntax == <code>float ReadIniFloat( string filename, string section, string var )</code> == Arguments == * '''filename...)
 
m (Forgot a ,)
Line 19: Line 19:
 
{
 
{
 
     local x = ReadIniFloat( "Locations.ini", text, "x" ),
 
     local x = ReadIniFloat( "Locations.ini", text, "x" ),
           y = ReadIniFloat( "Locations.ini", text, "y" )
+
           y = ReadIniFloat( "Locations.ini", text, "y" ),
 
           z = ReadIniFloat( "Locations.ini", text, "z" );
 
           z = ReadIniFloat( "Locations.ini", text, "z" );
  

Revision as of 01:09, 4 March 2009

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