1
+ --
2
+ -- CLIENTSIDE RESOURCE START PROCEDURE
3
+ --
4
+ local function resourceStart ()
5
+ -- Load the clientside configuration file, or create a new one if it does not exist.
6
+ local rootNode = xmlLoadFile (client_config_file ) or xmlCreateFile (client_config_file , " config" )
7
+
8
+ -- Ensure all important setting nodes exist.
9
+ for settingKey , defaultValue in pairs (setting ) do
10
+ if not xmlFindChild (rootNode , settingKey , 0 ) then
11
+ local newNode = xmlCreateChild (rootNode , settingKey )
12
+ xmlNodeSetValue (newNode , tostring (defaultValue ))
13
+ end
14
+ end
15
+
16
+ -- Remove deprecated/unused setting nodes.
17
+ for _ , subNode in ipairs (xmlNodeGetChildren (rootNode )) do
18
+ local nodeName = xmlNodeGetName (subNode )
19
+ if not setting [nodeName ] then
20
+ xmlDestroyNode (subNode )
21
+ end
22
+ end
23
+
24
+ xmlSaveFile (rootNode )
25
+ xmlUnloadFile (rootNode )
26
+
27
+ -- Cache the client-side handling saves.
28
+ cacheClientSaves ()
29
+
30
+ -- Query the server for admin rights.
31
+ triggerServerEvent (" requestRights" , root )
32
+
33
+ -- Build the GUI.
34
+ startBuilding ()
35
+ end
36
+ addEventHandler (" onClientResourceStart" , resourceRoot , resourceStart )
37
+
38
+ --
39
+ -- CLIENTSIDE RESOURCE STOP PROCEDURE
40
+ --
41
+ local function resourceStop ()
42
+ -- Unload the clientside configuration file.
43
+ xmlUnloadFile (client_handling_file )
44
+ end
45
+ addEventHandler (" onClientResourceStop" , resourceRoot , resourceStop )
0 commit comments