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

Add Coral prop/outline and fix Delete Object #88

Closed
Closed
Show file tree
Hide file tree
Changes from 2 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
65 changes: 56 additions & 9 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ local currentArea = 0
local inSellerZone = false
local iswearingsuit = false
local oxgenlevell = 0
local Coral = {}
local CoralProp = `prop_coral_pillar_01`
local peds = {}

local currentDivingLocation = {
area = 0,
Expand All @@ -21,6 +24,15 @@ local currentGear = {
}

-- Functions

function loadCoral()
RequestModel(CoralProp)
while not HasModelLoaded(CoralProp) do
RequestModel(CoralProp)
Wait(0)
end
end

local function callCops()
local call = math.random(1, 3)
local chance = math.random(1, 3)
Expand All @@ -33,12 +45,12 @@ end
local function deleteGear()
if currentGear.mask ~= 0 then
DetachEntity(currentGear.mask, 0, 1)
DeleteEntity(currentGear.mask)
DeleteObject(currentGear.mask)
currentGear.mask = 0
end
if currentGear.tank ~= 0 then
DetachEntity(currentGear.tank, 0, 1)
DeleteEntity(currentGear.tank)
DeleteObject(currentGear.tank)
currentGear.tank = 0
end

Expand Down Expand Up @@ -69,6 +81,8 @@ local function takeCoral(coral)
Config.CoralLocations[currentDivingLocation.area].coords.Coral[coral].PickedUp = true
TriggerServerEvent('qb-diving:server:TakeCoral', currentDivingLocation.area, coral, true)
ClearPedTasks(ped)
SetEntityDrawOutline(Coral[coral], false)
DeleteObject(Coral[coral])
FreezeEntityPosition(ped, false)
end, function() -- Cancel
ClearPedTasks(ped)
Expand All @@ -77,6 +91,7 @@ local function takeCoral(coral)
end
local function setDivingLocation(divingLocation)
if currentDivingLocation.area ~= 0 then
exports['qb-target']:RemoveZone('coral_zone')
for k in pairs(Config.CoralLocations[currentDivingLocation.area].coords.Coral) do
if Config.UseTarget then
exports['qb-target']:RemoveZone(k)
Expand All @@ -102,6 +117,10 @@ local function setDivingLocation(divingLocation)
EndTextCommandSetBlipName(labelBlip)
currentDivingLocation.blip.label = labelBlip
for k, v in pairs(Config.CoralLocations[currentDivingLocation.area].coords.Coral) do
loadCoral()
Coral[k] = CreateObject(CoralProp, v.coords.x, v.coords.y, v.coords.z+0.5, false, false, false)
PlaceObjectOnGroundProperly(Coral[k])
FreezeEntityPosition(Coral[k], true)
if Config.UseTarget then
exports['qb-target']:AddBoxZone('diving_coral_zone_'..k, v.coords, v.length, v.width, {
name = 'diving_coral_zone_'..k,
Expand Down Expand Up @@ -140,6 +159,34 @@ local function setDivingLocation(divingLocation)
end)
end
end
local CircleZone = CircleZone:Create(Config.CoralLocations[currentDivingLocation.area].coords.Area, 100.0, {
name="coral_zone",
debugPoly=false,
useZ = true,
})
local combo_coral = ComboZone:Create({CircleZone}, {name="combo_coral", debugPoly=false})
combo_coral:onPlayerInOut(function(isPointInside)
if isPointInside then
while isPointInside do
local coords = GetEntityCoords(PlayerPedId())
for _,v in pairs(Coral) do
local loc = GetEntityCoords(v)
if #(loc - coords) < 25 then
SetEntityDrawOutline(v, true)
SetEntityDrawOutlineColor(50, 50, 200, 150)
SetEntityDrawOutlineShader(1)
else
SetEntityDrawOutline(v, false)
end
end
Wait(1000)
end
else
for _,v in pairs(Coral) do
SetEntityDrawOutline(v, false)
end
end
end)
end

local function sellCoral()
Expand All @@ -166,12 +213,12 @@ local function createSeller()
Wait(0)
end
local currentCoords = vector4(current.coords.x, current.coords.y, current.coords.z - 1, current.coords.w)
local ped = CreatePed(0, current.model, currentCoords, false, false)
FreezeEntityPosition(ped, true)
SetEntityInvincible(ped, true)
SetBlockingOfNonTemporaryEvents(ped, true)
peds[i] = CreatePed(0, current.model, currentCoords, false, false)
FreezeEntityPosition(peds[i], true)
SetEntityInvincible(peds[i], true)
SetBlockingOfNonTemporaryEvents(peds[i], true)
if Config.UseTarget then
exports['qb-target']:AddTargetEntity(ped, {
exports['qb-target']:AddTargetEntity(peds[i], {
options = {
{
label = Lang:t("info.sell_coral"),
Expand Down Expand Up @@ -414,8 +461,8 @@ CreateThread(function()
Wait(0)
if currentGear.enabled == true and iswearingsuit == true then
if IsPedSwimmingUnderWater(PlayerPedId()) then
DrawText2(oxgenlevell..'')
DrawText2(oxgenlevell..'?')
end
end
end
end)
end)
4 changes: 3 additions & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fx_version 'cerulean'
game 'gta5'

description 'QB-Diving'
version '1.2.0'
version '1.2.1'

shared_script {
'@qb-core/shared/locale.lua',
Expand All @@ -16,6 +16,8 @@ server_script 'server/main.lua'
client_scripts {
'@PolyZone/client.lua',
'@PolyZone/BoxZone.lua',
'@PolyZone/CircleZone.lua',
'@PolyZone/ComboZone.lua',
'client/main.lua'
}

Expand Down