Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Issue 76 #78

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 27 additions & 28 deletions src/script.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- CARSA'S COMMANDS
---@version 2.0.0
---@version 2.0.1

---@alias peerID number
---@alias steamID string
Expand All @@ -15,8 +15,8 @@ local OWNER_STEAM_ID = "0"

local DEBUG = false

local ScriptVersion = "2.0.0"
local SaveDataVersion = "2.0.0"
local ScriptVersion = "2.0.1"
local SaveDataVersion = "2.0.1"

--[ LIBRARIES ]--
--#region
Expand Down Expand Up @@ -2936,6 +2936,30 @@ end
--[ CALLBACK FUNCTIONS ]--
--#region

g_savedata.version = SaveDataVersion
g_savedata.autosave = g_savedata.autosave or 1
g_savedata.is_dedicated_server = g_savedata.is_dedicated_server or false
-- define if undefined
g_savedata.vehicles = g_savedata.vehicles or {}
g_savedata.objects = g_savedata.objects or {}
g_savedata.players = g_savedata.players or {}
g_savedata.roles = g_savedata.roles or deepCopyTable(DEFAULT_ROLES)
g_savedata.unique_players = g_savedata.unique_players or 0
g_savedata.preferences = g_savedata.preferences or deepCopyTable(PREFERENCE_DEFAULTS)
g_savedata.rules = g_savedata.rules or {}
g_savedata.aliases = g_savedata.aliases or deepCopyTable(DEFAULT_ALIASES)
g_savedata.companionTokens = g_savedata.companionTokens or {}

-- create references to shorten code
G_vehicles = G_vehicles or new(VehicleContainer) ---@type VehicleContainer
G_objects = g_savedata.objects -- Not in use yet
G_players = new(PlayerContainer) ---@type PlayerContainer
G_roles = new(RoleContainer) ---@type RoleContainer
G_rules = new(Rules) ---@type Rules
G_preferences = g_savedata.preferences
G_aliases = g_savedata.aliases
G_companionTokens = g_savedata.companionTokens

function onCreate(is_new)
deny_tp_ui_id = server.getMapID()

Expand All @@ -2955,31 +2979,6 @@ function onCreate(is_new)

if invalid_version then return end


g_savedata.version = SaveDataVersion
g_savedata.autosave = g_savedata.autosave or 1
g_savedata.is_dedicated_server = g_savedata.is_dedicated_server or false
-- define if undefined
g_savedata.vehicles = g_savedata.vehicles or {}
g_savedata.objects = g_savedata.objects or {}
g_savedata.players = g_savedata.players or {}
g_savedata.roles = g_savedata.roles or deepCopyTable(DEFAULT_ROLES)
g_savedata.unique_players = g_savedata.unique_players or 0
g_savedata.preferences = g_savedata.preferences or deepCopyTable(PREFERENCE_DEFAULTS)
g_savedata.rules = g_savedata.rules or {}
g_savedata.aliases = g_savedata.aliases or deepCopyTable(DEFAULT_ALIASES)
g_savedata.companionTokens = g_savedata.companionTokens or {}

-- create references to shorten code
G_vehicles = G_vehicles or new(VehicleContainer) ---@type VehicleContainer
G_objects = g_savedata.objects -- Not in use yet
G_players = new(PlayerContainer) ---@type PlayerContainer
G_roles = new(RoleContainer) ---@type RoleContainer
G_rules = new(Rules) ---@type Rules
G_preferences = g_savedata.preferences
G_aliases = g_savedata.aliases
G_companionTokens = g_savedata.companionTokens

is_dedicated_server = g_savedata.is_dedicated_server

-- deserialize data
Expand Down