Skip to content

Commit

Permalink
fix: style and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mafewtm committed Nov 4, 2024
1 parent f00b039 commit 64bbf67
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
44 changes: 24 additions & 20 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
local config = require 'config.client'
local previewCam, scaleform, buttonsScaleform
local currentButtonID, previousButtonID = 1, 1
local arrowStart = {
vec2(-3150.25, -1427.83),
vec2(4173.08, 1338.72),
vec2(-2390.23, 6262.24)
}

local spawns
local previewCam
local scaleform
local buttonsScaleform
local currentButtonId = 1
local previousButtonId = 1

local function setupCamera()
previewCam = CreateCamWithParams('DEFAULT_SCRIPTED_CAMERA', -24.77, -590.35, 90.8, -2.0, 0.0, 160.0, 45.0, false, 2)
Expand Down Expand Up @@ -106,6 +103,12 @@ end

local function scaleformDetails(index)
local spawn = spawns[index]
local arrowStart = {
vec2(-3150.25, -1427.83),
vec2(4173.08, 1338.72),
vec2(-2390.23, 6262.24)
}

BeginScaleformMovieMethod(scaleform, 'ADD_HIGHLIGHT')
ScaleformMovieMethodAddParamInt(index)
ScaleformMovieMethodAddParamFloat(spawn.coords.x)
Expand Down Expand Up @@ -158,7 +161,7 @@ local function scaleformDetails(index)
end

local function updateScaleform()
if previousButtonID == currentButtonID then return end
if previousButtonId == currentButtonId then return end

for i = 1, #spawns, 1 do
BeginScaleformMovieMethod(scaleform, 'REMOVE_HIGHLIGHT')
Expand All @@ -182,26 +185,26 @@ local function updateScaleform()
EndScaleformMovieMethod()
end

scaleformDetails(currentButtonID)
scaleformDetails(currentButtonId)
end

local function inputHandler()
while DoesCamExist(previewCam) do
if IsControlJustReleased(0, 188) then
previousButtonID = currentButtonID
currentButtonID -= 1
previousButtonId = currentButtonId
currentButtonId -= 1

if currentButtonID < 1 then
currentButtonID = #spawns
if currentButtonId < 1 then
currentButtonId = #spawns
end

updateScaleform()
elseif IsControlJustReleased(0, 187) then
previousButtonID = currentButtonID
currentButtonID += 1
previousButtonId = currentButtonId
currentButtonId += 1

if currentButtonID > #spawns then
currentButtonID = 1
if currentButtonId > #spawns then
currentButtonId = 1
end

updateScaleform()
Expand All @@ -217,7 +220,8 @@ local function inputHandler()
FreezeEntityPosition(cache.ped, false)
DisplayRadar(true)

local spawnData = spawns[currentButtonID]
local spawnData = spawns[currentButtonId]

if spawnData.propertyId then
TriggerServerEvent('qbx_properties:server:enterProperty', { id = spawnData.propertyId, isSpawn = true })
else
Expand Down Expand Up @@ -263,6 +267,6 @@ AddEventHandler('qb-spawn:client:setupSpawns', function()

Wait(400)

scaleformDetails(currentButtonID)
scaleformDetails(currentButtonId)
inputHandler()
end)
14 changes: 10 additions & 4 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ lib.versionCheck('Qbox-project/qbx_spawn')

lib.callback.register('qbx_spawn:server:getLastLocation', function(source)
local player = exports.qbx_core:GetPlayer(source)
return json.decode(MySQL.single.await('SELECT position FROM players WHERE citizenid = ?', {player.PlayerData.citizenid}).position), player.PlayerData.metadata.currentPropertyId
end)
local queryResult = MySQL.single.await('SELECT position FROM players WHERE citizenid = ?', { player.PlayerData.citizenid })
local position = json.decode(queryResult.position)
local currentPropertyId = player.PlayerData.metadata.currentPropertyId

return position, currentPropertyId
end)

lib.callback.register('qbx_spawn:server:getProperties', function(source)
if not GetResourceState('qbx_properties'):find('start') then
Expand All @@ -12,9 +16,11 @@ lib.callback.register('qbx_spawn:server:getProperties', function(source)

local player = exports.qbx_core:GetPlayer(source)
local houseData = {}
local properties = MySQL.query.await('SELECT id, property_name, coords FROM properties WHERE owner = ?', {player.PlayerData.citizenid})
local properties = MySQL.query.await('SELECT id, property_name, coords FROM properties WHERE owner = ?', { player.PlayerData.citizenid })

for i = 1, #properties do
local property = properties[i]

houseData[#houseData + 1] = {
label = property.property_name,
coords = json.decode(property.coords),
Expand All @@ -23,4 +29,4 @@ lib.callback.register('qbx_spawn:server:getProperties', function(source)
end

return houseData
end)
end)

0 comments on commit 64bbf67

Please sign in to comment.