-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ce8765
commit 609f36d
Showing
15 changed files
with
839 additions
and
836 deletions.
There are no files selected for viewing
420 changes: 210 additions & 210 deletions
420
server-data/resources/[esx_addons]/esx_boat/client/main.lua
Large diffs are not rendered by default.
Oops, something went wrong.
344 changes: 170 additions & 174 deletions
344
server-data/resources/[esx_addons]/esx_boat/client/marker.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,199 +1,195 @@ | ||
local HasAlreadyEnteredMarker = false | ||
local LastZone = nil | ||
local LastZone = nil | ||
|
||
CurrentAction = nil | ||
CurrentActionMsg = '' | ||
CurrentAction = nil | ||
CurrentActionMsg = "" | ||
CurrentActionData = {} | ||
|
||
-- Key controls | ||
CreateThread(function() | ||
while true do | ||
Wait(0) | ||
|
||
if CurrentAction then | ||
if IsControlJustReleased(0, 38) then | ||
if CurrentAction == 'boat_shop' then | ||
if not Config.LicenseEnable then | ||
OpenBoatShop(Config.Zones.BoatShops[CurrentActionData.zoneNum]) | ||
else -- check for license | ||
|
||
ESX.TriggerServerCallback('esx_license:checkLicense', function(hasBoatLicense) | ||
if hasBoatLicense then | ||
OpenBoatShop(Config.Zones.BoatShops[CurrentActionData.zoneNum]) | ||
else | ||
OpenLicenceMenu(Config.Zones.BoatShops[CurrentActionData.zoneNum]) | ||
end | ||
end, GetPlayerServerId(PlayerId()), 'boat') | ||
end | ||
elseif CurrentAction == 'garage_out' then | ||
OpenBoatGarage(Config.Zones.Garages[CurrentActionData.zoneNum]) | ||
elseif CurrentAction == 'garage_in' then | ||
StoreBoatInGarage(CurrentActionData.vehicle, Config.Zones.Garages[CurrentActionData.zoneNum].StoreTP) | ||
end | ||
|
||
CurrentAction = nil | ||
ESX.HideUI() | ||
end | ||
else | ||
Wait(500) | ||
end | ||
end | ||
while true do | ||
Wait(0) | ||
|
||
if CurrentAction then | ||
if IsControlJustReleased(0, 38) then | ||
if CurrentAction == "boat_shop" then | ||
if not Config.LicenseEnable then | ||
OpenBoatShop(Config.Zones.BoatShops[CurrentActionData.zoneNum]) | ||
else -- check for license | ||
ESX.TriggerServerCallback("esx_license:checkLicense", function(hasBoatLicense) | ||
if hasBoatLicense then | ||
OpenBoatShop(Config.Zones.BoatShops[CurrentActionData.zoneNum]) | ||
else | ||
OpenLicenceMenu(Config.Zones.BoatShops[CurrentActionData.zoneNum]) | ||
end | ||
end, GetPlayerServerId(PlayerId()), "boat") | ||
end | ||
elseif CurrentAction == "garage_out" then | ||
OpenBoatGarage(Config.Zones.Garages[CurrentActionData.zoneNum]) | ||
elseif CurrentAction == "garage_in" then | ||
StoreBoatInGarage(CurrentActionData.vehicle, Config.Zones.Garages[CurrentActionData.zoneNum].StoreTP) | ||
end | ||
|
||
CurrentAction = nil | ||
ESX.HideUI() | ||
end | ||
else | ||
Wait(500) | ||
end | ||
end | ||
end) | ||
|
||
AddEventHandler('esx_boat:hasEnteredMarker', function(zone, zoneNum) | ||
if zone == 'boat_shop' then | ||
CurrentAction = 'boat_shop' | ||
CurrentActionMsg = _U('boat_shop_open') | ||
CurrentActionData = { zoneNum = zoneNum } | ||
elseif zone == 'garage_out' then | ||
CurrentAction = 'garage_out' | ||
CurrentActionMsg = _U('garage_open') | ||
CurrentActionData = { zoneNum = zoneNum } | ||
elseif zone == 'garage_in' then | ||
local playerPed = PlayerPedId() | ||
local _ = GetEntityCoords(playerPed) | ||
|
||
if IsPedInAnyVehicle(playerPed, false) then | ||
local vehicle = GetVehiclePedIsIn(playerPed, false) | ||
|
||
if DoesEntityExist(vehicle) and GetPedInVehicleSeat(vehicle, -1) == playerPed then | ||
CurrentAction = 'garage_in' | ||
CurrentActionMsg = _U('garage_store') | ||
CurrentActionData = { vehicle = vehicle, zoneNum = zoneNum } | ||
end | ||
end | ||
end | ||
ESX.TextUI(CurrentActionMsg) | ||
AddEventHandler("esx_boat:hasEnteredMarker", function(zone, zoneNum) | ||
if zone == "boat_shop" then | ||
CurrentAction = "boat_shop" | ||
CurrentActionMsg = _U("boat_shop_open") | ||
CurrentActionData = { zoneNum = zoneNum } | ||
elseif zone == "garage_out" then | ||
CurrentAction = "garage_out" | ||
CurrentActionMsg = _U("garage_open") | ||
CurrentActionData = { zoneNum = zoneNum } | ||
elseif zone == "garage_in" then | ||
local playerPed = PlayerPedId() | ||
local _ = GetEntityCoords(playerPed) | ||
|
||
if IsPedInAnyVehicle(playerPed, false) then | ||
local vehicle = GetVehiclePedIsIn(playerPed, false) | ||
|
||
if DoesEntityExist(vehicle) and GetPedInVehicleSeat(vehicle, -1) == playerPed then | ||
CurrentAction = "garage_in" | ||
CurrentActionMsg = _U("garage_store") | ||
CurrentActionData = { vehicle = vehicle, zoneNum = zoneNum } | ||
end | ||
end | ||
end | ||
ESX.TextUI(CurrentActionMsg) | ||
end) | ||
|
||
AddEventHandler('esx_boat:hasExitedMarker', function() | ||
if not isInShopMenu then | ||
ESX.CloseContext() | ||
end | ||
AddEventHandler("esx_boat:hasExitedMarker", function() | ||
if not isInShopMenu then | ||
ESX.CloseContext() | ||
end | ||
|
||
CurrentAction = nil | ||
ESX.HideUI() | ||
CurrentAction = nil | ||
ESX.HideUI() | ||
end) | ||
|
||
-- Enter / Exit marker events | ||
CreateThread(function() | ||
while true do | ||
Wait(0) | ||
|
||
local playerPed = PlayerPedId() | ||
local coords = GetEntityCoords(playerPed) | ||
local isInMarker, hasExited, letSleep = false, false, true | ||
local currentZone, currentZoneNum | ||
|
||
for i=1, #Config.Zones.BoatShops, 1 do | ||
local distance = #(coords - Config.Zones.BoatShops[i].Outside) | ||
|
||
if distance < Config.DrawDistance then | ||
DrawMarker(Config.MarkerType, Config.Zones.BoatShops[i].Outside, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Marker.x, Config.Marker.y, Config.Marker.z, Config.Marker.r, Config.Marker.g, Config.Marker.b, 100, false, true, 2, false, nil, nil, false) | ||
letSleep = false | ||
end | ||
|
||
if distance < Config.Marker.x then | ||
isInMarker = true | ||
currentZone = 'boat_shop' | ||
currentZoneNum = i | ||
end | ||
end | ||
|
||
for i=1, #Config.Zones.Garages, 1 do | ||
local distance = #(coords - Config.Zones.Garages[i].GaragePos) | ||
|
||
if distance < Config.DrawDistance then | ||
DrawMarker(Config.MarkerType, Config.Zones.Garages[i].GaragePos, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Marker.x, Config.Marker.y, Config.Marker.z, Config.Marker.r, Config.Marker.g, Config.Marker.b, 100, false, true, 2, false, nil, nil, false) | ||
letSleep = false | ||
end | ||
|
||
if distance < Config.Marker.x then | ||
isInMarker = true | ||
currentZone = 'garage_out' | ||
currentZoneNum = i | ||
end | ||
|
||
distance = #(coords - Config.Zones.Garages[i].StorePos) | ||
|
||
if distance < Config.DrawDistance then | ||
DrawMarker(Config.MarkerType, Config.Zones.Garages[i].StorePos, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.StoreMarker.x, Config.StoreMarker.y, Config.StoreMarker.z, Config.StoreMarker.r, Config.StoreMarker.g, Config.StoreMarker.b, 100, false, true, 2, false, nil, nil, false) | ||
letSleep = false | ||
end | ||
|
||
if distance < Config.StoreMarker.x then | ||
isInMarker = true | ||
currentZone = 'garage_in' | ||
currentZoneNum = i | ||
end | ||
end | ||
|
||
if isInMarker and not HasAlreadyEnteredMarker or (isInMarker and (LastZone ~= currentZone or LastZoneNum ~= currentZoneNum)) then | ||
if | ||
(LastZone ~= nil and LastZoneNum ~= nil) and | ||
(LastZone ~= currentZone or LastZoneNum ~= currentZoneNum) | ||
then | ||
TriggerEvent('esx_boat:hasExitedMarker', LastZone) | ||
hasExited = true | ||
end | ||
|
||
HasAlreadyEnteredMarker = true | ||
LastZone = currentZone | ||
LastZoneNum = currentZoneNum | ||
|
||
TriggerEvent('esx_boat:hasEnteredMarker', currentZone, currentZoneNum) | ||
end | ||
|
||
if not hasExited and not isInMarker and HasAlreadyEnteredMarker then | ||
HasAlreadyEnteredMarker = false | ||
TriggerEvent('esx_boat:hasExitedMarker') | ||
end | ||
|
||
if letSleep then | ||
Wait(500) | ||
end | ||
end | ||
while true do | ||
Wait(0) | ||
|
||
local playerPed = PlayerPedId() | ||
local coords = GetEntityCoords(playerPed) | ||
local isInMarker, hasExited, letSleep = false, false, true | ||
local currentZone, currentZoneNum | ||
|
||
for i = 1, #Config.Zones.BoatShops, 1 do | ||
local distance = #(coords - Config.Zones.BoatShops[i].Outside) | ||
|
||
if distance < Config.DrawDistance then | ||
DrawMarker(Config.MarkerType, Config.Zones.BoatShops[i].Outside, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Marker.x, Config.Marker.y, Config.Marker.z, Config.Marker.r, Config.Marker.g, Config.Marker.b, 100, false, true, 2, false, nil, nil, false) | ||
letSleep = false | ||
end | ||
|
||
if distance < Config.Marker.x then | ||
isInMarker = true | ||
currentZone = "boat_shop" | ||
currentZoneNum = i | ||
end | ||
end | ||
|
||
for i = 1, #Config.Zones.Garages, 1 do | ||
local distance = #(coords - Config.Zones.Garages[i].GaragePos) | ||
|
||
if distance < Config.DrawDistance then | ||
DrawMarker(Config.MarkerType, Config.Zones.Garages[i].GaragePos, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Marker.x, Config.Marker.y, Config.Marker.z, Config.Marker.r, Config.Marker.g, Config.Marker.b, 100, false, true, 2, false, nil, nil, false) | ||
letSleep = false | ||
end | ||
|
||
if distance < Config.Marker.x then | ||
isInMarker = true | ||
currentZone = "garage_out" | ||
currentZoneNum = i | ||
end | ||
|
||
distance = #(coords - Config.Zones.Garages[i].StorePos) | ||
|
||
if distance < Config.DrawDistance then | ||
DrawMarker(Config.MarkerType, Config.Zones.Garages[i].StorePos, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.StoreMarker.x, Config.StoreMarker.y, Config.StoreMarker.z, Config.StoreMarker.r, Config.StoreMarker.g, Config.StoreMarker.b, 100, false, true, 2, false, nil, nil, false) | ||
letSleep = false | ||
end | ||
|
||
if distance < Config.StoreMarker.x then | ||
isInMarker = true | ||
currentZone = "garage_in" | ||
currentZoneNum = i | ||
end | ||
end | ||
|
||
if isInMarker and not HasAlreadyEnteredMarker or (isInMarker and (LastZone ~= currentZone or LastZoneNum ~= currentZoneNum)) then | ||
if (LastZone ~= nil and LastZoneNum ~= nil) and (LastZone ~= currentZone or LastZoneNum ~= currentZoneNum) then | ||
TriggerEvent("esx_boat:hasExitedMarker", LastZone) | ||
hasExited = true | ||
end | ||
|
||
HasAlreadyEnteredMarker = true | ||
LastZone = currentZone | ||
LastZoneNum = currentZoneNum | ||
|
||
TriggerEvent("esx_boat:hasEnteredMarker", currentZone, currentZoneNum) | ||
end | ||
|
||
if not hasExited and not isInMarker and HasAlreadyEnteredMarker then | ||
HasAlreadyEnteredMarker = false | ||
TriggerEvent("esx_boat:hasExitedMarker") | ||
end | ||
|
||
if letSleep then | ||
Wait(500) | ||
end | ||
end | ||
end) | ||
|
||
-- Blips | ||
CreateThread(function() | ||
local blipList = {} | ||
|
||
for i=1, #Config.Zones.Garages, 1 do | ||
table.insert(blipList, { | ||
coords = Config.Zones.Garages[i].GaragePos, | ||
text = _U('blip_garage'), | ||
sprite = 356, | ||
color = 3, | ||
scale = 1.0 | ||
}) | ||
end | ||
|
||
for i=1, #Config.Zones.BoatShops, 1 do | ||
table.insert(blipList, { | ||
coords = Config.Zones.BoatShops[i].Outside, | ||
text = _U('blip_shop'), | ||
sprite = 427, | ||
color = 3, | ||
scale = 1.0 | ||
}) | ||
end | ||
|
||
for i=1, #blipList, 1 do | ||
CreateBlip(blipList[i].coords, blipList[i].text, blipList[i].sprite, blipList[i].color, blipList[i].scale) | ||
end | ||
local blipList = {} | ||
|
||
for i = 1, #Config.Zones.Garages, 1 do | ||
table.insert(blipList, { | ||
coords = Config.Zones.Garages[i].GaragePos, | ||
text = _U("blip_garage"), | ||
sprite = 356, | ||
color = 3, | ||
scale = 1.0, | ||
}) | ||
end | ||
|
||
for i = 1, #Config.Zones.BoatShops, 1 do | ||
table.insert(blipList, { | ||
coords = Config.Zones.BoatShops[i].Outside, | ||
text = _U("blip_shop"), | ||
sprite = 427, | ||
color = 3, | ||
scale = 1.0, | ||
}) | ||
end | ||
|
||
for i = 1, #blipList, 1 do | ||
CreateBlip(blipList[i].coords, blipList[i].text, blipList[i].sprite, blipList[i].color, blipList[i].scale) | ||
end | ||
end) | ||
|
||
function CreateBlip(coords, text, sprite, color, scale) | ||
local blip = AddBlipForCoord(coords.x, coords.y) | ||
local blip = AddBlipForCoord(coords.x, coords.y) | ||
|
||
SetBlipSprite(blip, sprite) | ||
SetBlipScale(blip, scale) | ||
SetBlipColour(blip, color) | ||
SetBlipSprite(blip, sprite) | ||
SetBlipScale(blip, scale) | ||
SetBlipColour(blip, color) | ||
|
||
SetBlipAsShortRange(blip, true) | ||
SetBlipAsShortRange(blip, true) | ||
|
||
BeginTextCommandSetBlipName('STRING') | ||
AddTextComponentSubstringPlayerName(text) | ||
EndTextCommandSetBlipName(blip) | ||
end | ||
BeginTextCommandSetBlipName("STRING") | ||
AddTextComponentSubstringPlayerName(text) | ||
EndTextCommandSetBlipName(blip) | ||
end |
Oops, something went wrong.