Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Doors #62

Merged
merged 11 commits into from
Jul 30, 2023
Merged
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ This will open a furniture store complete with all of the props. Select an item

> Note: The place on ground button sometimes does not work properly depending on where the native detects the ground to be.

## Dynamic Doors

Dynamic Doors will turn placed doors into actual working doors, Instead of them being static. (See videos below)

### Preview

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe just add a note in here on what is meant by dynamic doors (ie: place doros and that they work like a door, rather than a static asset that cant be open/closed)

Side note for future, it might even be cool to see if we can make some of these interior doors lockable (i wonder if it would work with the existing doorlock systems when you place a door down??)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be something to look into for the near future I think, That wouuld be pretty sick!

https://github.com/complexza/ps-housing/assets/74205343/fef28197-8e95-4b5f-aba8-b3e5409456d8

https://github.com/complexza/ps-housing/assets/74205343/196bb25e-75b9-42f6-b1c3-fe86ad477544

### Setup
- You will need to set the `Config.DynamicDoors = true`
- You will have to add this convar into your server.cfg `setr game_enableDynamicDoorCreation "true"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, why is this convar needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually not sure, I just knows it makes the doors dynamic, as far as I know the convar just converts the doors into the dynamic mode

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added game_enableDynamicDoorCreation network check bypass, allowing the creation of doors dynamically in a network environment (thanks to @Nikez, @z3t4s, and okqut).

I found this when it was added https://forum.cfx.re/t/cfx-re-community-pulse-june-2023-edition/5109543

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh sick! Thanks, I struggled to find docs on it!


> Note: The convar has to be in your server.cfg in order for the doors to be dynamic!

# Important

* Players need to place their [stash](https://github.com/Project-Sloth/ps-housing/blob/7efd2009050b9a20969877cf69b284352a9309bf/shared/config.lua#LL426C96-L426C96) and [wardrobe](https://github.com/Project-Sloth/ps-housing/blob/7efd2009050b9a20969877cf69b284352a9309bf/shared/config.lua#L427) or else they wont have one. Check [Config](https://github.com/Project-Sloth/ps-housing/blob/7efd2009050b9a20969877cf69b284352a9309bf/shared/config.lua#L422) for more information.
Expand Down
9 changes: 6 additions & 3 deletions client/cl_property.lua
Original file line number Diff line number Diff line change
Expand Up @@ -430,16 +430,19 @@ function Property:OpenDoorbellMenu()
end

function Property:LoadFurniture(furniture)
local coords = GetOffsetFromEntityInWorldCoords(self.shellObj, furniture.position.x, furniture.position.y,
furniture.position.z)
local coords = GetOffsetFromEntityInWorldCoords(self.shellObj, furniture.position.x, furniture.position.y, furniture.position.z)
local hash = furniture.object

lib.requestModel(hash)
local entity = CreateObjectNoOffset(hash, coords.x, coords.y, coords.z, false, true, false)
SetModelAsNoLongerNeeded(hash)
SetEntityRotation(entity, furniture.rotation.x, furniture.rotation.y, furniture.rotation.z, 2, true)
FreezeEntityPosition(entity, true)

if furniture.type == 'door' and Config.DynamicDoors then
Debug("Object: "..furniture.label.." wont be frozen")
else
FreezeEntityPosition(entity, true)
end

if furniture.type and Config.FurnitureTypes[furniture.type] then
Config.FurnitureTypes[furniture.type](entity, self.property_id, self.propertyData.shell)
Expand Down
306 changes: 153 additions & 153 deletions html/index.js

Large diffs are not rendered by default.

41 changes: 40 additions & 1 deletion shared/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ Config.AccessCanEditFurniture = true
-- Draw the poly for the property
Config.DebugMode = true


function Debug(...)
if Config.DebugMode then
print(...)
end
end

-- Enables Dynamic Doors
Config.DynamicDoors = false

Config.PoliceJobNames = { -- add multiple police jobs that are allowed to raid properties!
"police",
-- "police2",
Expand Down Expand Up @@ -1220,6 +1222,43 @@ Config.Furnitures = {
}
},

{
category = "Doors", -- All from Base Game.
items = {
{ ["object"] = "v_ilev_fa_frontdoor", ["price"] = 300, ["type"] = "door", ["label"] = "White Door" },
{ ["object"] = "v_ilev_247_offdorr", ["price"] = 300, ["type"] = "door", ["label"] = "24/7 Wooden Door" },
{ ["object"] = "v_ilev_arm_secdoor", ["price"] = 300, ["type"] = "door", ["label"] = "Security Door" },
{ ["object"] = "v_ilev_bank4door01", ["price"] = 300, ["type"] = "door", ["label"] = "Bank Glass Door" },
{ ["object"] = "v_ilev_bk_gate", ["price"] = 300, ["type"] = "door", ["label"] = "Fancy Metal Gate" },
{ ["object"] = "v_ilev_cbankcountdoor01", ["price"] = 300, ["type"] = "door", ["label"] = "Bank Office Door" },
{ ["object"] = "v_ilev_cd_door", ["price"] = 300, ["type"] = "door", ["label"] = "Wooden Door with Glass" },
{ ["object"] = "v_ilev_cm_door1", ["price"] = 300, ["type"] = "door", ["label"] = "Light Blue Door" },
{ ["object"] = "v_ilev_dev_door", ["price"] = 300, ["type"] = "door", ["label"] = "Black House Door" },
{ ["object"] = "v_ilev_door_orangesolid", ["price"] = 300, ["type"] = "door", ["label"] = "Orange Solid Door" },
{ ["object"] = "v_ilev_fa_backdoor", ["price"] = 300, ["type"] = "door", ["label"] = "Dirty Glass Door" },
{ ["object"] = "v_ilev_gangsafedoor", ["price"] = 300, ["type"] = "door", ["label"] = "Gang Safe Door" },
{ ["object"] = "v_ilev_gc_door02", ["price"] = 300, ["type"] = "door", ["label"] = "Office Door" },
{ ["object"] = "v_ilev_janitor_frontdoor", ["price"] = 300, ["type"] = "door", ["label"] = "White Mesh Door" },
{ ["object"] = "v_ilev_rc_door1", ["price"] = 300, ["type"] = "door", ["label"] = "Yellow Fire Door" },
{ ["object"] = "v_ilev_roc_door2", ["price"] = 300, ["type"] = "door", ["label"] = "Solid Red Door" },
{ ["object"] = "v_ilev_sol_off_door01", ["price"] = 300, ["type"] = "door", ["label"] = "Solid Wooden Door" },
{ ["object"] = "v_ilev_stad_fdoor", ["price"] = 300, ["type"] = "door", ["label"] = "Glass Door with Rails" },
{ ["object"] = "v_ilev_tort_door", ["price"] = 300, ["type"] = "door", ["label"] = "Door with Danger Sign" },
{ ["object"] = "v_ilev_trevtraildr", ["price"] = 300, ["type"] = "door", ["label"] = "Trailer Door" },
{ ["object"] = "prop_cs_fridge_door", ["price"] = 300, ["type"] = "door", ["label"] = "Fridge Door" },
{ ["object"] = "prop_artgallery_dl", ["price"] = 300, ["type"] = "door", ["label"] = "White Art Gallery Door" },
{ ["object"] = "prop_bh1_09_mp_l", ["price"] = 300, ["type"] = "door", ["label"] = "Weazel Plaza Door" },
{ ["object"] = "prop_bh1_48_backdoor_l", ["price"] = 300, ["type"] = "door", ["label"] = "Black Glass Door" },
{ ["object"] = "prop_casino_door_01r", ["price"] = 300, ["type"] = "door", ["label"] = "Casino Glass Door" },
{ ["object"] = "prop_cs4_11_door", ["price"] = 300, ["type"] = "door", ["label"] = "White Door with Small Window" },
{ ["object"] = "prop_cs6_03_door_r", ["price"] = 300, ["type"] = "door", ["label"] = "Antique Wooden Door" },
{ ["object"] = "prop_grumandoor_r", ["price"] = 300, ["type"] = "door", ["label"] = "Golden Snake Door" },
{ ["object"] = "prop_motel_door_09", ["price"] = 300, ["type"] = "door", ["label"] = "Motel Door" },
{ ["object"] = "v_61_hlw_mesh_doorbroken", ["price"] = 300, ["type"] = "door", ["label"] = "Broken White Door" },
{ ["object"] = "prop_fnclink_03gate5", ["price"] = 300, ["type"] = "door", ["label"] = "Chainlink Fence" },
}
},

{
category = "Misc",
items = {
Expand Down
18 changes: 8 additions & 10 deletions ui/src/components/OwnedItems.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@
<div class="flex flex-col gap-2 w-full">
<h1 class="text-[2rem]">{item.label}</h1>
</div>
{#if !item.type}
<button
class="bg-[color:var(--color-tertiary)] text-[2rem] py-4 h-full text-center aspect-square"
on:click={() => {
SendNUI('removeOwnedItem', item)
}}
>
<i class="fa-solid fa-xmark" />
</button>
{/if}
<button
class="bg-[color:var(--color-tertiary)] text-[2rem] py-4 h-full text-center aspect-square"
on:click={() => {
SendNUI('removeOwnedItem', item)
}}
>
<i class="fa-solid fa-xmark" />
</button>
</div>
{/each}
</div>
Expand Down