Scripting/Squirrel/Functions/ReadIniNumber: Difference between revisions
Jump to navigation
Jump to search
This wiki is using an old backup from 2020
Some information may be old/missing
(Created page with "__NOTOC__ This function reads a float value from an .ini file. == Syntax == <code>float ReadIniNumber( string filename, string section, string var )</code> == Arguments ==...") |
No edit summary |
||
Line 15: | Line 15: | ||
This example will teleport the player to a previously saved location when they type '/c gotoloc LocationName'. | This example will teleport the player to a previously saved location when they type '/c gotoloc LocationName'. | ||
<code | <code> | ||
function onPlayerCommand( player, command, text ) | function onPlayerCommand( player, command, text ) | ||
{ | { |
Revision as of 05:16, 22 June 2016
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.