Skip to content

Commit

Permalink
Update (#4)
Browse files Browse the repository at this point in the history
* Add files via upload

* Add files via upload

* Update fxmanifest.lua
  • Loading branch information
jakeyboi1 authored May 7, 2023
1 parent 4266754 commit c05fad5
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 104 deletions.
119 changes: 53 additions & 66 deletions client/CampSetup.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
--------------------- Variables Used ----------------------------------
local tentcreated = false
local benchcreated = false
local campfirecreated = false
local storagechestcreated = false
local hitchpostcreated = false
local fasttravelpostcreated = false
local hitchpost
local tent
local bench
local campfire
local storagechest
local fasttravelpost
local broll
local blip
local outoftown
local tentcreated, benchcreated, campfirecreated, storagechestcreated, hitchpostcreated, fasttravelpostcreated = false, false, false, false, false, false
local hitchpost, tent, bench, campfire, storagechest, fasttravelpost, broll, blip, outoftown

------- Event To Register Inv After Char Selection ------
RegisterNetEvent('vorp:SelectedCharacter')
Expand Down Expand Up @@ -47,47 +34,58 @@ function spawnTent()
while DoesEntityExist(tent) do
Citizen.Wait(5)
local x2,y2,z2 = table.unpack(GetEntityCoords(PlayerPedId()))
if GetDistanceBetweenCoords(x, y, z, x2, y2, z2, true) < 2 then --if dist less than 2 then
DrawText3D(x, y, z, Config.Language.OpenCampMenu)
local dist = GetDistanceBetweenCoords(x, y, z, x2, y2, z2, true)
if dist < 2 then
BccUtils.Misc.DrawText3D(x, y, z, Config.Language.OpenCampMenu)
if IsControlJustReleased(0, 0x760A9C6F) then
MainCampmenu() --opens the menu
end
elseif dist > 200 then
Citizen.Wait(2000)
end
end
end
end

function spawnLogBench()
function spawnItem(furntype, model)
local infrontofplayer = IsThereAnyPropInFrontOfPed(PlayerPedId())
local notneartent = notneartentdistcheck(tent)
if infrontofplayer or benchcreated or notneartent then
local x,y,z = table.unpack(GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 1.0, 0))
if infrontofplayer or notneartent then
VORPcore.NotifyRightTip(Config.Language.CantBuild, 4000)
else
local model = 'p_bench_log03x'
progressbarfunc(Config.SetupTime.BenchSetupTime, Config.Language.SettingBucnhPbar)
modelload(model)
local x,y,z = table.unpack(GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 1.0, 0))
bench = CreateObject(model, x, y, z, true, true, false)
PropCorrection(bench)
benchcreated = true
if furntype == 'bench' then
if benchcreated then
VORPcore.NotifyRightTip(Config.Language.CantBuild, 4000)
else
progressbarfunc(Config.SetupTime.BenchSetupTime, Config.Language.SettingBucnhPbar)
bench = CreateObject(model, x, y, z, true, true, false)
benchcreated = true
PropCorrection(bench)
end
elseif furntype == 'campfire' then
if campfirecreated then
VORPcore.NotifyRightTip(Config.Language.CantBuild, 4000)
else
progressbarfunc(Config.SetupTime.FireSetupTime, Config.Language.FireSetup)
campfire = CreateObject(model, x, y, z, true, true, false)
PropCorrection(campfire)
campfirecreated = true
end
elseif furntype == 'hitchingpost' then
if hitchpostcreated then
VORPcore.NotifyRightTip(Config.Language.CantBuild, 4000)
else
progressbarfunc(Config.SetupTime.HitchingPostTime, Config.Language.HitchingPostSetup)
hitchpost = CreateObject(model, x, y, z, true, true, false)
PropCorrection(hitchpost)
hitchpostcreated = true
end
end
end
end

function spawnCampFire()
local infrontofplayer = IsThereAnyPropInFrontOfPed(PlayerPedId())
local notneartent = notneartentdistcheck(tent)
if infrontofplayer or campfirecreated or notneartent then
VORPcore.NotifyRightTip(Config.Language.CantBuild, 4000)
else
progressbarfunc(Config.SetupTime.FireSetupTime, Config.Language.FireSetup)
local model = 'p_campfire01x'
modelload(model)
local x,y,z = table.unpack(GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 1.0, 0))
campfire = CreateObject(model, x, y, z, true, true, false)
PropCorrection(campfire)
campfirecreated = true
end
end

function spawnStorageChest()
local infrontofplayer = IsThereAnyPropInFrontOfPed(PlayerPedId())
Expand All @@ -105,32 +103,19 @@ function spawnStorageChest()
while DoesEntityExist(storagechest) do
Citizen.Wait(10)
local x2,y2,z2 = table.unpack(GetEntityCoords(PlayerPedId()))
if GetDistanceBetweenCoords(x, y, z, x2, y2, z2, true) < 2 then --if dist less than 2 then
DrawText3D(x, y, z - 1, Config.Language.OpenCampStorage)
local dist = GetDistanceBetweenCoords(x, y, z, x2, y2, z2, true)
if dist < 2 then
BccUtils.Misc.DrawText3D(x, y, z - 1, Config.Language.OpenCampStorage)
if IsControlJustReleased(0, 0x760A9C6F) then
TriggerServerEvent('bcc-camp:OpenInv')
end
elseif dist > 200 then
Citizen.Wait(2000)
end
end
end
end

function spawnHitchingPost()
local infrontofplayer = IsThereAnyPropInFrontOfPed(PlayerPedId())
local notneartent = notneartentdistcheck(tent)
if infrontofplayer or hitchpostcreated or notneartent then
VORPcore.NotifyRightTip(Config.Language.CantBuild, 4000)
else
progressbarfunc(Config.SetupTime.HitchingPostTime, Config.Language.HitchingPostSetup)
local model = 'p_hitchingpost01x'
modelload(model)
local x,y,z = table.unpack(GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 1.0, 0))
hitchpost = CreateObject(model, x, y, z, true, true, false)
PropCorrection(hitchpost)
hitchpostcreated = true
end
end

function spawnFastTravelPost()
local infrontofplayer = IsThereAnyPropInFrontOfPed(PlayerPedId())
local notneartent = notneartentdistcheck(tent)
Expand All @@ -145,13 +130,16 @@ function spawnFastTravelPost()
PropCorrection(fasttravelpost)
fasttravelpostcreated = true
while DoesEntityExist(fasttravelpost) do
Citizen.Wait(10)
Citizen.Wait(5)
local x2,y2,z2 = table.unpack(GetEntityCoords(PlayerPedId()))
if GetDistanceBetweenCoords(x, y, z, x2, y2, z2, true) < 2 then
DrawText3D(x, y, z, Config.Language.OpenFastTravel)
local dist = GetDistanceBetweenCoords(x, y, z, x2, y2, z2, true)
if dist < 2 then
BccUtils.Misc.DrawText3D(x, y, z, Config.Language.OpenFastTravel)
if IsControlJustReleased(0, 0x760A9C6F) then
Tpmenu()
end
elseif dist > 200 then
Citizen.Wait(2000)
end
end
end
Expand Down Expand Up @@ -188,7 +176,7 @@ function delcamp()
DeleteObject(storagechest)
end
if hitchpostcreated then
hitchpostcreated =false
hitchpostcreated = false
DeleteObject(hitchpost)
end
if fasttravelpostcreated then
Expand All @@ -212,17 +200,16 @@ RegisterNetEvent('bcc-camp:NearTownCheck')
AddEventHandler('bcc-camp:NearTownCheck', function()
if not Config.SetCampInTowns then
outoftown = true
if Config.CampItem.enabled then
if Config.CampItem.enabled and Config.CampItem.RemoveItem 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
if GetDistanceBetweenCoords(pl.x, pl.y, pl.z, e.coordinates.x, e.coordinates.y, e.coordinates.z, false) > e.range then
outoftown = true
elseif dist < e.range then
else
VORPcore.NotifyRightTip(Config.Language.Tooclosetotown, 4000)
outoftown = false break
end
Expand Down
32 changes: 21 additions & 11 deletions client/MenuSetup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ end)
------------ Events for cleanup ---------------

--this is used to close the menu while you are on the main menu and hit backspace button
local inmenu = false --var used to see if you are in the main menu or not
RegisterNetEvent('bcc-camp:MenuClose')
local inmenu = false
AddEventHandler('bcc-camp:MenuClose', function()
while true do --loops will run permantely
Citizen.Wait(10) --waits 10ms prevents crashing
Expand All @@ -23,7 +22,7 @@ end)


---------------------- Main Camp Menu Setup -----------------------------------

local cdown = false
function MainTentmenu() --when triggered will open the main menu
inmenu = true --changes var to true allowing the press of backspace to close the menu
TriggerEvent('bcc-camp:MenuClose') --triggers the event
Expand All @@ -43,10 +42,22 @@ 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')
if Config.Cooldown then
if not cdown then
if Config.CampItem.enabled then
TriggerServerEvent('bcc-camp:RemoveCampItem')
end
cdown = true
spawnTent()
else
VORPcore.NotifyRightTip(Config.Language.Cdown, 4000)
end
else
if Config.CampItem.enabled then
TriggerServerEvent('bcc-camp:RemoveCampItem')
end
spawnTent()
end
spawnTent()
end
end)
end
Expand Down Expand Up @@ -78,16 +89,16 @@ function MainCampmenu() --when triggered will open the main menu
delcamp()
elseif data.current.value == 'setcfire' then --if option clicked is this then
MenuData.CloseAll()
spawnCampFire()
spawnItem('campfire', 'p_campfire01x')
elseif data.current.value == 'setcbench' then
MenuData.CloseAll()
spawnLogBench()
spawnItem('bench', 'p_bench_log03x')
elseif data.current.value == 'setcstoragechest' then
MenuData.CloseAll()
spawnStorageChest()
elseif data.current.value == 'setchitchingpost' then
MenuData.CloseAll()
spawnHitchingPost()
spawnItem('hitchingpost', 'p_hitchingpost01x')
elseif data.current.value == 'setcftravelpost' then
MenuData.CloseAll()
if Config.FastTravel.enabled then
Expand All @@ -103,8 +114,7 @@ function Tpmenu() --when triggered will open the main menu
inmenu = true --changes var to true allowing the press of backspace to close the menu
TriggerEvent('bcc-camp:MenuClose') --triggers the event
MenuData.CloseAll() --closes all menus
local elements = {} --sets the var to a table
local elementindex = 1 --sets the var too 1
local elements, elementindex = {}, 1
Citizen.Wait(100) --waits 100ms
for k, v in pairs(Config.FastTravel.Locations) do --opens a for loop
elements[elementindex] = { --sets the elemnents to this table
Expand Down
20 changes: 2 additions & 18 deletions client/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ VORPutils = {}
TriggerEvent("getUtils", function(utils)
VORPutils = utils
end)
progressbar = exports.vorp_progressbar:initiate() --Allows use of progressbar in code
progressbar = exports.vorp_progressbar:initiate()
BccUtils = exports['bcc-utils'].initiate()

---------------------------- Functions ------------------------------------------------

Expand Down Expand Up @@ -47,23 +48,6 @@ function notneartentdistcheck(tentobj) --returns true if your too far from tent
if GetDistanceBetweenCoords(x, y, z, x2, y2, z2, true) > Config.CampRadius then return true else return false end
end

--Creates the ability to use DrawText3D
function DrawText3D(x, y, z, text)
local onScreen,_x,_y=GetScreenCoordFromWorldCoord(x, y, z)
local px,py,pz=table.unpack(GetGameplayCamCoord())
local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
local str = CreateVarString(10, "LITERAL_STRING", text, Citizen.ResultAsLong())
if onScreen then
SetTextScale(0.30, 0.30)
SetTextFontForCurrentCommand(1)
SetTextColor(255, 255, 255, 215)
SetTextCentre(1)
DisplayText(str,_x,_y)
local factor = (string.len(text)) / 225
DrawSprite("feeds", "hud_menu_4a", _x, _y+0.0125,0.015+ factor, 0.03, 0.1, 35, 35, 35, 190, 0)
end
end

--Progressbar
function progressbarfunc(time, text)
FreezeEntityPosition(PlayerPedId(), true)
Expand Down
5 changes: 4 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Config.CampCommand = true --If true you will set your tent via command (do not h
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.Cooldown = true --if enabled the cooldown will be active
Config.CooldownTime = 1800000 --time in ms before the player can set a camp again

Config.InventoryLimit = 200 --the camps storage limit

Expand Down Expand Up @@ -75,7 +77,8 @@ Config.Language = {
--Camp Setup Translations
CantBuild = 'You can not build here!',
InventoryName = 'Camp Storage ',
Tooclosetotown = 'You are to close to a town'
Tooclosetotown = 'You are to close to a town',
Cdown = 'On Cooldown'
}


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.2'
version '1.0.3'

dependencies {
'vorp_core',
Expand Down
9 changes: 2 additions & 7 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ local VORPcore = {}
TriggerEvent("getCore", function(core)
VORPcore = core
end)
local BccUtils = {}
TriggerEvent('bcc:getUtils', function(bccutils)
BccUtils = bccutils
end)
local BccUtils = exports['bcc-utils'].initiate()

--Inv creation for camp
RegisterServerEvent('bcc-camp:CampInvCreation', function(charid)
Expand All @@ -34,9 +31,7 @@ end)
----Removing camp item ---
RegisterServerEvent('bcc-camp:RemoveCampItem', function()
local _source = source
if Config.CampItem.RemoveItem then
VORPInv.subItem(_source, Config.CampItem.CampItem, 1)
end
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 c05fad5

Please sign in to comment.