7erra – User

From Bohemia Interactive Community
Jump to navigation Jump to search
(functions links)
m (Text replacement - "\[ *((ftp|http)s?:\/\/[^ ]+)([^{])=([^}])([^ ]+)" to "[$1$3{{=}}$4$5")
 
(34 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= BIKI Related =
My contributions:
* [[Special:Contributions/7erra]]
My sandboxes:
* [[User:7erra/Sandbox]]
* [[User:7erra/Sandbox1]]
* [[User:7erra/Sandbox2]]
* [[User:7erra/Sandbox3]]
* [[User:7erra/Sandbox4]]
* [[User:7erra/Sandbox5]]
= About Me =
{| style="float: right;"
{| style="float: right;"
|-
|-
|{{User de}}
|{{UserLanguage|de}}
|-
|-
|{{User en-3}}
|{{UserLanguage|en|3}}
|}
|}
ArmA player since ArmA2. Scripting since A3. Fluent in German, English and sqf.
ArmA player since Arma 2. Scripting since Arma 3. Fluent in German, English and sqf.


Connect with me!
Connect with me!
Line 13: Line 26:
*Discord: Terra#3653
*Discord: Terra#3653


= My Content =
My <s>abominations</s> creations:
My <s>abominations</s> creations:
*[https://forums.bohemia.net/forums/topic/217263-7erras-editing-extensions/| 7erra's Editing Extensions (mod)]
*[https://forums.bohemia.net/forums/topic/217263-7erras-editing-extensions/| 7erra's Editing Extensions (mod)]
*[https://steamcommunity.com/sharedfiles/filedetails/?id=1420348567| Disable 3den Mission Preview Shortcut (mod)]
*[https://steamcommunity.com/sharedfiles/filedetails/?id{{=}}1420348567| Disable 3den Mission Preview Shortcut (mod)]
*[https://forums.bohemia.net/forums/topic/219677-release-virtual-arsenal-shop-system/| VASS: Virtual Arsenal Shop System (script)]
*[https://forums.bohemia.net/forums/topic/219677-release-virtual-arsenal-shop-system/| VASS: Virtual Arsenal Shop System (script)]
*Older ones:
*Older ones:
Line 21: Line 35:
**[https://forums.bohemia.net/forums/topic/207752-pop-up-target-gui/| Pop-Up Target GUI (script)]
**[https://forums.bohemia.net/forums/topic/207752-pop-up-target-gui/| Pop-Up Target GUI (script)]


= Useful Links =
Links which I abuse a lot:
Links which I abuse a lot:
*https://community.bistudio.com/wiki/User:7erra/Sandbox
*https://community.bistudio.com/wiki/User_Interface_Event_Handlers
*https://community.bistudio.com/wiki/User_Interface_Event_Handlers
*https://community.bistudio.com/wiki/Arma_3:_Event_Handlers
*https://community.bistudio.com/wiki/Arma_3:_Event_Handlers
Line 31: Line 47:
*https://community.bistudio.com/wiki/Cheatsheet
*https://community.bistudio.com/wiki/Cheatsheet


= (づ。◕‿‿◕。)づ =
(づ。◕‿‿◕。)づ
(づ。◕‿‿◕。)づ
<br><br>
{{wip}}
==What is a Scripted Database?==
A Scripted Database is a simple way to manage information with ingame functions from Bohemia Interactive. Instead of using file operations it is a semi persistent sqf database. This means that the database is only avialable during the mission and can be modified with ingame commands. The downside is that it will be wiped when the mission ends or the game/server crashes. To make the database persistent you can save it periodically to the profileNamespace.
==The Functions==
A list of all functions which are used to operate the database can be found here: [[:Category:Function Group: Database|Database functions]].
The functions in which you should be interested in are:
*[[BIS_fnc_dbValueSet]]
*[[BIS_fnc_dbValueReturn]]
And to a certain extent:
*[[BIS_fnc_dbClassList]]
*[[BIS_fnc_dbClassRemove]]
*[[BIS_fnc_dbClassReturn]]
*[[BIS_fnc_dbClassSet]]
*[[BIS_fnc_dbImportXML]]
*[[BIS_fnc_dbValueList]]
==Creating A Database==
There are theoretically three options:
===Declaring An Empty Array===
The most straightforward option. Simply add {{Inline code|TAG_database {{=}} [];}} to any script where you want to declare the database, eg initServer.sqf.
===Importing From An .xml File===
[[BIS_fnc_dbImportXML]] can convert the content of an xml file into an array which has the format of a Scripted Database. An xml file can be way easier to read than a nested array. Just keep in mind that you can't modify the xml file from within the game, meaning that once the mission restarts the default database from that file will be loaded and not the database which exsisted at the end of a mission.
===Importing From A Config===
A config can either be the description.ext (misssion config) or a config.bin(/.cpp) (global config). The [[BIS_fnc_dbImportConfig]] function can import the config classes from the config but not the values. This makes this function  a bit useless as the same can be achieved with the other options but even better. Writing to the config is also only possible from outside the game and not with commands.
==Operating A Database==
===Classes And Values===
The Scripted Database consists of classes and values. Classes can be indentified by the class symbol "#" while the symbol for values is "&". The sole puropse of [[BIS_fnc_dbSymbolClass]] and [[BIS_fnc_dbSymbolValue]] is to return this sign. While the class is followed by an array which contains values, the value is only followed by its content which can be any data type. After the values content might follow another value or the array for that class ends. Here is an example of what the database looks like:
["#PLAYERS",["#1234",["&NAME","Bob","&KILLS",20,"&RANK","Seargent"],["#5678",["&NAME","Davis","&KILLS",0,"&RANK","Private"]]]
Let's format that a bit differently:
[
"#PLAYERS", {{codecomment|// The uppermost class containing information about the players}}
[
"#1234", {{codecomment|// An imaginary user id to indentify a player wihtout doubt}}
[
{{codecomment|// Following here are some stats that the player has}}
"&NAME", "Bob",
"&KILLS", 20,
"&RANK", "Seargent"
],
"#5678",
[
"&NAME", "Davis",
"&KILLS", 0,
"&RANK", "Private"
],
]
]
===Accessing Values===
To get the content of a value you can use the [[BIS_fnc_dbValueReturn]] function. The first parameter is the database from which the value should be returned. The second one is the path where the value is located. The following code displays the rank the player currently has:
_puid = getPlayerUID player;
_rank = [TAG_database, ["players", _puid, "rank"]] call BIS_fnc_dbValueReturn;
hint _rank;
If you ever worked with configs then you might notice the similiarity between the path array and the path to a config. This is how you access a config value:
getText (missionConfigfile>> "Players" >> getPlayerUID player >> "rank");
So while the config is not editable the database is which leads us to...
===Editing Values===
Values can be edited with the function [[BIS_fnc_dbValueSet]]. Continuing with the example from above the player was just promoted and a new rank has to be set in the database (array TAG_database):
_newRank = [[rank]] player;
_puid = [[getPlayerUID]] player;
[TAG_database, ["players", _puid, "rank"], _newRank] call [[BIS_fnc_dbValueSet]];
The previous database array will be overwritten by the function, see the {{Inline code|[[set]]}} command.

Latest revision as of 17:20, 28 April 2023