Scripting/Squirrel/Functions/WriteIniNumber: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
(Created page with "__NOTOC__ This function writes an integer value to an .ini file. If the file does not exist, the function will create it. == Syntax == <code>bool WriteIniInteger( string fil...")
 
Line 14: Line 14:


== Example ==
== Example ==
This example will save player's cash to a file 'PlayerCash.ini' when they leave the game.
create a Pos.ini file on your server


<code lang="squirrel">
<code lang="squirrel">
function onPlayerPart( player, reason )
function onPlayerPart( player, reason )
{
{
    WriteIniInteger( "PlayerCash.ini", "Cash", player.Name, player.Cash );
WriteIniNumber( "Pos.ini", "X", player.Name, player.Pos.X );
WriteIniNumber( "Pos.ini", "Y", player.Name, player.Pos.Y );
WriteIniNumber( "Pos.ini", "Z", player.Name, player.Pos.Z );
}
}
</code>
</code>
=== Notes ===
The functions [[Scripting/Squirrel/Functions/Player.Name|player.Name]], [[Scripting/Squirrel/Functions/Player.Cash|player.Cash]] and call [[OnPlayerPart]] were also used in in this example. More info about them in the corresponding pages.


== Related Functions ==
== Related Functions ==


{{Scripting/Squirrel/Functions/INI Functions}}
{{Scripting/Squirrel/Functions/INI Functions}}

Revision as of 07:18, 2 August 2016

This function writes an integer value to an .ini file. If the file does not exist, the function will create it.

Syntax

bool WriteIniInteger( string filename, string section, string var, int 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 integer value for the variable

Example

create a Pos.ini file on your server

function onPlayerPart( player, reason ) { WriteIniNumber( "Pos.ini", "X", player.Name, player.Pos.X ); WriteIniNumber( "Pos.ini", "Y", player.Name, player.Pos.Y ); WriteIniNumber( "Pos.ini", "Z", player.Name, player.Pos.Z ); }

Related Functions