Squirrel/Server/Functions/Ini/ReadIniFloat
From Liberty Unleashed Wiki
(Difference between revisions)
(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
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'.
function OnPlayerCommand( player, command, text ) { local x = ReadIniFloat( "Locations.ini", text, "x" ), y = ReadIniFloat( "Locations.ini", text, "y" ), z = ReadIniFloat( "Locations.ini", text, "z" ); if ( x ) { local pos = Vector( x, y, z ); SetPlayerPos( player, pos ); MessagePlayer( "Teleporting to " +text+ "...", player ); } else MessagePlayer( "Location " +text+ " not found.", player ); }
Notes
The functions SetPlayerPos, MessagePlayer and call OnPlayerCommand were also used in in this example. More info about them in corresponding pages.