Squirrel/Server/Functions/Ini/WriteIniFloat
From Liberty Unleashed Wiki
(Difference between revisions)
(New page: __NOTOC__ This function writes a float value to an .ini file. If the file does not exist, the function will create it. == Syntax == <code>bool WriteIniFloat( string filename, string sect...) |
m (Squirrel/Functions/Ini/WriteIniFloat moved to Squirrel/Server/Functions/Ini/WriteIniFloat: Server-side function only) |
Revision as of 00:59, 27 November 2009
This function writes a float value to an .ini file. If the file does not exist, the function will create it.
Syntax
bool WriteIniFloat( string filename, string section, string var, float value )
Arguments
- filename This is the name of the file
- section The section that contains the value you want to create/edit
- var The name of the variable
- value The float value for the variable
Example
This example will save a location to a file 'Locations.ini' when a player types '/saveloc LocationName'.
function OnPlayerCommand( player, command, text ) { if ( command = "saveloc" ) { local pos = GetPlayerPos( player ); WriteIniFloat( "Locations.ini", text, "x", pos.x ); WriteIniFloat( "Locations.ini", text, "y", pos.y ); WriteIniFloat( "Locations.ini", text, "z", pos.z ); MessagePlayer( "Saved location " +text+ ".", player ); } }
Notes
The functions GetPlayerPos, MessagePlayer and call OnPlayerCommand were also used in in this example. More info about them in the corresponding pages.