Skip to content

Commit

Permalink
Public version
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderFoo committed Jan 3, 2023
1 parent e5ec811 commit 208f2f4
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Data/Scripts/Loadouts_Server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local ROOT = script:GetCustomProperty("Root"):WaitForObject()

local LOADOUTS = require(ROOT:GetCustomProperty("Loadouts"))
local SAVE_LOADOUT = ROOT:GetCustomProperty("SaveLoadout")
local FORCE_ON = ROOT:GetCustomProperty("ForceOn")

local players = {}

Expand Down Expand Up @@ -31,6 +32,10 @@ local function equip_item(player, item_index)
})

players[player].active:Equip(player)

if(FORCE_ON) then
players[player].active.visibility = Visibility.FORCE_ON
end
end

local function save_data(player)
Expand All @@ -40,7 +45,7 @@ local function save_data(player)

if(players[player] ~= nil and players[player].loadout_index ~= nil) then
local data = {}

pcall(function()
data = Storage.GetPlayerData(player)
end)
Expand Down Expand Up @@ -77,7 +82,7 @@ end

local function on_player_joined(player)
local data = {}

players[player] = {}

if(SAVE_LOADOUT) then
Expand Down Expand Up @@ -123,4 +128,4 @@ Events.ConnectForPlayer("Hotbar.Ready", ready)
Events.ConnectForPlayer("Hotbar.Select", select_item)

Game.playerJoinedEvent:Connect(on_player_joined)
Game.playerLeftEvent:Connect(on_player_left)
Game.playerLeftEvent:Connect(on_player_left)
16 changes: 16 additions & 0 deletions Data/Templates/Loadouts.pbt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ Assets {
Name: "cs:SaveLoadout"
Bool: true
}
Overrides {
Name: "cs:ForceOn"
Bool: true
}
Overrides {
Name: "cs:EnableHotbar"
Bool: true
Expand Down Expand Up @@ -171,6 +175,18 @@ Assets {
Name: "cs:SlotNormalColor:tooltip"
String: "The normal color of a slot in the hotbar."
}
Overrides {
Name: "cs:ForceOn:tooltip"
String: "In some cases with other components such as costume equippers, the requipment will need to be forced on."
}
Overrides {
Name: "cs:ForceOn:category"
String: "Custom"
}
Overrides {
Name: "cs:ForceOn:subcategory"
String: "Loadout"
}
}
Collidable_v2 {
Value: "mc:ecollisionsetting:inheritfromparent"
Expand Down
43 changes: 43 additions & 0 deletions Data/Templates/Loadouts_1.pbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Assets {
Id: 13121485076787381653
Name: "Loadouts"
PlatformAssetType: 5
TemplateAsset {
ObjectBlock {
RootId: 1650044587395406390
Objects {
Id: 1650044587395406390
Name: "TemplateBundleDummy"
Transform {
Location {
}
Rotation {
}
Scale {
X: 1
Y: 1
Z: 1
}
}
Folder {
BundleDummy {
ReferencedAssets {
Id: 7967915417835585167
}
}
}
}
}
PrimaryAssetId {
AssetType: "None"
AssetId: "None"
}
}
Marketplace {
Id: "387e57c444bd48d2969cc4cfb9bdd792"
OwnerAccountId: "bd602d5201b04b3fbf7be10f59c8f974"
OwnerName: "CoreAcademy"
Description: "This component is part of the Core Academy Essentials. A collection of useful components to help get started in Core.\r\n\r\nThe Loadouts component will give players the ability to switch their loadout in game. It comes with a simple loadout menu for players to select which loadout they want. It also contains a hotbar to allow for quick switching of their weapon/equipment.\r\n\r\nTo learn more on how to use this component, checkout the README included or the article linked below.\r\n\r\nhttps://learn.coregames.com/loadouts/\r\n\r\nFor any issues or bugs, please report them on GitHub.\r\n\r\nhttps://github.com/ManticoreGamesInc/CC-Loadouts/issues\r\n\r\nSee more Core Academy Essential components here.\r\n\r\nhttps://learn.coregames.com/core-academy-essentials\r\n"
}
SerializationVersion: 123
}

0 comments on commit 208f2f4

Please sign in to comment.