Skip to content

Commit

Permalink
New features (#2)
Browse files Browse the repository at this point in the history
* Add files via upload

* Add files via upload
  • Loading branch information
jakeyboi1 authored May 4, 2023
1 parent 711ab05 commit 306bd65
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 5 deletions.
35 changes: 33 additions & 2 deletions client/CampSetup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local storagechest
local fasttravelpost
local broll
local blip
local outoftown

------- Event To Register Inv After Char Selection ------
RegisterNetEvent('vorp:SelectedCharacter')
Expand Down Expand Up @@ -198,6 +199,36 @@ end


-- Command Setup
RegisterCommand(Config.CommandName, function()
MainTentmenu()
Citizen.CreateThread(function()
if Config.CampCommand then
RegisterCommand(Config.CommandName, function()
TriggerEvent('bcc-camp:NearTownCheck')
end)
end
end)

----------------------- Distance Check for player to town coordinates --------------------------------
RegisterNetEvent('bcc-camp:NearTownCheck')
AddEventHandler('bcc-camp:NearTownCheck', function()
if not Config.SetCampInTowns then
outoftown = true
if Config.CampItem.enabled then
TriggerServerEvent('bcc-camp:RemoveCampItem')
end
else
local pl2 = PlayerPedId()
for k, e in pairs(Config.Towns) do
local pl = GetEntityCoords(pl2)
local dist = #(vec2(pl.x, pl.y) - vec2(e.coordinates.x, e.coordinates.y))
if dist > e.range then
outoftown = true
elseif dist < e.range then
VORPcore.NotifyRightTip(Config.Language.Tooclosetotown, 4000)
outoftown = false break
end
end
end
if outoftown then
MainTentmenu()
end
end)
3 changes: 3 additions & 0 deletions client/MenuSetup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ function MainTentmenu() --when triggered will open the main menu
end
if data.current.value == 'settent' then --if option clicked is this then
MenuData.CloseAll()
if Config.CampItem.enabled then
TriggerServerEvent('bcc-camp:RemoveCampItem')
end
spawnTent()
end
end)
Expand Down
43 changes: 41 additions & 2 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ Config.CampBlips = {
}

Config.CampRadius = 30 --radius you will be able to place props inside
Config.CampCommand = true --If true you will set your tent via command (do not have this and camp item enabled at the same time use one or the other)
Config.CampItem = { enabled = false, CampItem = 'water', RemoveItem = true } --if enabled is true then you will need to use the CampItem to set tent make sure the item exists in your database if removeitem is true it will remove 1 of the item from the players inventory when they set camp
Config.CommandName = 'SetTent' --name of the command to set the tent
Config.SetCampInTowns = true --If false players will be able to set camp inside of towns

Config.InventoryLimit = 200 --the camps storage limit

Expand Down Expand Up @@ -71,11 +74,47 @@ Config.Language = {

--Camp Setup Translations
CantBuild = 'You can not build here!',
InventoryName = 'Camp Storage '
InventoryName = 'Camp Storage ',
Tooclosetotown = 'You are to close to a town'
}



--------------------------------- Town Locations ------------------------------------------------------------------------------------
------------Ignore This for the most part. Unless you want to change the range of a town, or add more towns -------------------------
Config.Towns = { --creates a sub table in town table
{
coordinates = {x = -297.48, y = 791.1, z = 118.33}, --Valentine (the towns coords)
range = 150, --The distance away you have to be to be considered outside of town
},
{
coordinates = {x = 2930.95, y = 1348.91, z = 44.1}, --annesburg
range = 250,
},
{
coordinates = {x = 2632.52, y = -1312.31, z = 51.42}, --Saint denis
range = 600,
},
{
coordinates = {x = 1346.14, y = -1312.5, z = 76.53}, --Rhodes
range = 200,
},
{
coordinates = {x = -1801.09, y = -374.86, z = 161.15}, --strawberry
range = 150,
},
{
coordinates = {x = -801.77, y = -1336.43, z = 43.54}, --blackwater
range = 350
},
{
coordinates = {x = -3659.38, y = -2608.91, z = -14.08}, --armadillo
range = 150,
},
{
coordinates = {x = -5498.97, y = -2950.61, z = -1.62}, --Tumbleweed
range = 100,
}, --You can add more towns by copy and pasting one of the tables above and changing the coords and range to your liking
}



Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ client_scripts {
}


version '1.0.1'
version '1.0.2'

dependencies {
'vorp_core',
Expand Down
16 changes: 16 additions & 0 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,31 @@ TriggerEvent('bcc:getUtils', function(bccutils)
BccUtils = bccutils
end)

--Inv creation for camp
RegisterServerEvent('bcc-camp:CampInvCreation', function(charid)
VORPInv.registerInventory('Player_' .. charid .. '_bcc-campinv', Config.Language.InventoryName, Config.InventoryLimit)
end)

-- camp inv open
RegisterServerEvent('bcc-camp:OpenInv', function()
local _source = source
local Character = VORPcore.getUser(_source).getUsedCharacter
VORPInv.OpenInv(_source, 'Player_' .. Character.charIdentifier.. '_bcc-campinv')
end)

---- Registering Camp Item -----
Citizen.CreateThread(function()
if Config.CampItem.enabled then
VORPInv.RegisterUsableItem(Config.CampItem.CampItem, function(data)
TriggerClientEvent('bcc-camp:NearTownCheck', data.source)
end)
end
end)

----Removing camp item ---
RegisterServerEvent('bcc-camp:RemoveCampItem', function()
local _source = source
VORPInv.subItem(_source, Config.CampItem.CampItem, 1)
end)
--This handles the version check
BccUtils.Versioner.checkRelease(GetCurrentResourceName(), 'https://github.com/BryceCanyonCounty/bcc-camp')

0 comments on commit 306bd65

Please sign in to comment.