From acf425bb6091e2885d6ac3e40773d42a567e229c Mon Sep 17 00:00:00 2001 From: ghermans Date: Sun, 5 May 2019 14:57:57 +0200 Subject: [PATCH 01/15] Fixed base resource --- vf_base/__resource.lua | 6 ++- vf_base/client/spawn.lua | 19 ++++------ vf_base/server/database.lua | 3 +- vf_base/server/general.lua | 74 +++++++++++++++++++++++++++++++++++++ vf_base/utils/player.lua | 14 ++++++- 5 files changed, 102 insertions(+), 14 deletions(-) diff --git a/vf_base/__resource.lua b/vf_base/__resource.lua index 80e2a51..17972c2 100644 --- a/vf_base/__resource.lua +++ b/vf_base/__resource.lua @@ -1,6 +1,6 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' resource_type 'gametype' { name = 'venomous-freemode' } -resource_version '1.1.1' +resource_version '1.1.2' dependencies {'ghmattimysql'} @@ -14,6 +14,10 @@ client_scripts { 'client/spawn.lua' } +export 'GetInventory' +server_export 'AddInventoryItem' +server_export 'GetInventoryItems' + server_scripts { 'config/freemode.lua', 'server/database.lua', diff --git a/vf_base/client/spawn.lua b/vf_base/client/spawn.lua index 6925e06..626dabb 100644 --- a/vf_base/client/spawn.lua +++ b/vf_base/client/spawn.lua @@ -11,25 +11,22 @@ AddEventHandler('onClientGameTypeStart', function() exports.spawnmanager:forceRespawn() end) -AddEventHandler('playerSpawned', function(spawn) - while not NetworkIsGameInProgress() and IsPlayerPlaying(PlayerId()) do - Wait(200) - end - - while not IsScreenFadedIn() do - Wait(200) - end -end) - Citizen.CreateThread(function() if not firstTick then + while not NetworkIsGameInProgress() and IsPlayerPlaying(PlayerId()) do + Wait(800) + end + + print('Ready to start the intro') + if not IsPlayerSwitchInProgress() then SetEntityVisible(PlayerPedId(), false, 0) SwitchOutPlayer(PlayerPedId(), 32, 1) Wait(3000) showLoadingPromt("PCARD_JOIN_GAME", 8000) - Wait(1000) + Wait(1000) + TriggerServerEvent("vf_base:GetInventory") end GetRandomMultiPlayerModel("mp_m_freemode_01") diff --git a/vf_base/server/database.lua b/vf_base/server/database.lua index a7e738d..9a646ae 100644 --- a/vf_base/server/database.lua +++ b/vf_base/server/database.lua @@ -2,5 +2,6 @@ IsDatabaseVerified = false local setupTable = "CREATE TABLE IF NOT EXISTS venomous_players (license varchar(255) NOT NULL, identifier varchar(255) NOT NULL, cash int(11) NOT NULL, `bank` int(11) NOT NULL, `rank` int(11) NOT NULL, `xp` int(11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8" exports.ghmattimysql:execute(setupTable, {}, function() - IsDatabaseVerified = true + local invTable = "CREATE TABLE IF NOT EXISTS venomous_inventory (license varchar(255) NOT NULL, item varchar(255) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8" + exports.ghmattimysql:execute(invTable, {}, function() IsDatabaseVerified = true end) end) diff --git a/vf_base/server/general.lua b/vf_base/server/general.lua index 41babbd..658d78d 100644 --- a/vf_base/server/general.lua +++ b/vf_base/server/general.lua @@ -33,4 +33,78 @@ end, "GET", "", "") RegisterServerEvent("vf_base:KickRes") AddEventHandler("vf_base:KickRes", function(reason) DropPlayer(source, tostring(reason)) +end) + +function GetInventoryItems(license) + local params = {['license'] = license} + exports.ghmattimysql:scalar("SELECT license FROM venomous_inventory WHERE license = @license", params, function(result) + if result then + exports.ghmattimysql:execute("SELECT *, COUNT(*) AS total FROM venomous_inventory WHERE license = @license GROUP BY item", params, function(data) + return data + end) + end + end) +end + +function AddInventoryItem(src, item) + local data = {["license"] = license, ["item"] = tostring(item)} + + TriggerEvent('vf_base:FindPlayer', src, function(user) + local params = {['license'] = user.license, ["item"] = tostring(item)} + exports.ghmattimysql:execute("INSERT INTO venomous_inventory (`license`, `item`) VALUES (@license, @item)", params, function() + exports.ghmattimysql:execute("SELECT *, COUNT(*) AS total FROM venomous_inventory WHERE license = @license GROUP BY item", params, function(data) + TriggerClientEvent('vf_base:refresh_inventory', src, data) + end) + end) + end) +end + +RegisterServerEvent('vf_inventory:additem') +AddEventHandler('vf_inventory:additem', function(item) + local src = source + + TriggerEvent('vf_base:FindPlayer', src, function(user) + local params = {['license'] = user.license, ["item"] = tostring(item)} + exports.ghmattimysql:execute("INSERT INTO venomous_inventory (`license`, `item`) VALUES (@license, @item)", params, function() end) + end) +end) + +RegisterServerEvent('vf_base:GetInventory') +AddEventHandler('vf_base:GetInventory', function() + local src = source + + TriggerEvent('vf_base:FindPlayer', src, function(user) + local params = {['license'] = user.license} + exports.ghmattimysql:scalar("SELECT license FROM venomous_inventory WHERE license = @license", params, function(result) + if not result then + print('No inventory items are found for ' .. GetPlayerName(src)) + else + exports.ghmattimysql:execute("SELECT *, COUNT(*) AS total FROM venomous_inventory WHERE license = @license GROUP BY item", params, function(data) + TriggerClientEvent('vf_base:refresh_inventory', src, data) + end) + end + end) + end) +end) + +RegisterServerEvent('vf_base:UpdateInventory') +AddEventHandler('vf_base:UpdateInventory', function(item) + local src = source + local stockItem = item + + TriggerEvent('vf_base:FindPlayer', src, function(user) + local params = {['license'] = user.license, ['item'] = item} + + exports.ghmattimysql:scalar("SELECT license, item FROM venomous_inventory WHERE license = @license and item = @item", params, function(result) + if result then + exports.ghmattimysql:execute("DELETE FROM venomous_inventory WHERE license = @license and item = @item LIMIT 1", params, function(queryR) + if queryR then + exports.ghmattimysql:execute("SELECT *, COUNT(*) AS total FROM venomous_inventory WHERE license = @license GROUP BY item", params, function(data) + TriggerClientEvent('vf_base:refresh_inventory', src, data) + end) + end + end) + end + end) + end) end) \ No newline at end of file diff --git a/vf_base/utils/player.lua b/vf_base/utils/player.lua index a1ea2b0..40cfa65 100644 --- a/vf_base/utils/player.lua +++ b/vf_base/utils/player.lua @@ -1,3 +1,5 @@ +inventoryItems = {} + function generateSpawn() math.randomseed(GetGameTimer()) local keys = {} @@ -64,4 +66,14 @@ AddEventHandler("vf_base:DisplayBankValue", function(value) StatSetInt("BANK_BALANCE", value, true) ShowHudComponentThisFrame(3) CancelEvent() -end) \ No newline at end of file +end) + +RegisterNetEvent('vf_base:refresh_inventory') +AddEventHandler('vf_base:refresh_inventory', function(array) + inventoryItems = array + GetInventory() +end) + +function GetInventory() + return inventoryItems +end \ No newline at end of file From 16eed748c6d5b7011cc99b6ff2f3cc958f989727 Mon Sep 17 00:00:00 2001 From: Glenn Hermans Date: Thu, 30 May 2019 15:58:48 +0200 Subject: [PATCH 02/15] Drop old file --- vf_base/client/character.lua | 318 ----------------------------------- 1 file changed, 318 deletions(-) delete mode 100644 vf_base/client/character.lua diff --git a/vf_base/client/character.lua b/vf_base/client/character.lua deleted file mode 100644 index 1c23ae4..0000000 --- a/vf_base/client/character.lua +++ /dev/null @@ -1,318 +0,0 @@ -_charPool = nil - -RegisterNetEvent("vf_base:NoCharacter") -AddEventHandler("vf_base:NoCharacter", function() - warning = CreateWarningMessage(GetLabelText("HUD_CONNPROB"), GetLabelText("TRAN_NOCHAR")) - local IsTeleported = false - while HasScaleformMovieLoaded(warning) and not IsTeleported do - if IsControlJustPressed(0, 201) then - EnterCharacterCreator() - end - - Citizen.Wait(1) - end -end) - -RegisterNetEvent("vf_base:CreateCharacter") -AddEventHandler("vf_base:CreateCharacter", function() - EnterCharacterCreator() -end) - -function EnterCharacterCreator() - if IsPlayerSwitchInProgress() then - SetEntityCoordsNoOffset(PlayerPedId(), 403.006225894, -996.8715, -99.00) - SetEntityHeading(PlayerPedId(), 182.65637207031) - - interior = GetInteriorAtCoordsWithType(399.9, -998.7, -100.0, "v_mugshot") - LoadInterior(interior) - while not IsInteriorReady(interior) do - Wait(500) - end - - cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true) - while not DoesCamExist(cam) do - Citizen.Wait(500) - end - - if DoesCamExist(cam) then - SetCamCoord(cam, 402.7553, -1000.55, -98.48412) - SetCamRot(cam, -3.589798, 0.0, -0.276381, 2) - SetCamFov(cam, 37.95373) - - RenderScriptCams(true, false, 3000, 1, 0, 0) - FreezeEntityPosition(PlayerPedId(), true) - DoScreenFadeIn(200) - hidehud = true - end - - _charPool = NativeUI.CreatePool() - charMenu = NativeUI.CreateMenu(GetLabelText("FACE_TITLE"), "~b~" .. GetLabelText("FACE_MMT")) - _charPool:Add(charMenu) - - DisplayCharacterCreatorMenu(charMenu) - _charPool:RefreshIndex() - IsCharacterCreated = true - - N_0xd8295af639fd9cb8(PlayerPedId()) - end -end - -function AddGenderSelection(menu) - local genders = {GetLabelText("FACE_MALE"), GetLabelText("FACE_FEMALE")} - local newitem = NativeUI.CreateListItem(GetLabelText("FACE_SEX"), genders, 1, GetLabelText("FACE_MM_H2")) - - menu:AddItem(newitem) - menu.OnListChange = function(sender, item, index) - if item == newitem then - SelectedItem = newitem:IndexToItem(index) - if SelectedItem == GetLabelText("FACE_MALE") then - playerModel = 'mp_m_freemode_01' - else - playerModel = 'mp_f_freemode_01' - end - - GetRandomMultiPlayerModel(playerModel) - end - end -end - -function AddHeritageSelection(menu) - local submenu = _charPool:AddSubMenu(menu, GetLabelText("FACE_HERI"), GetLabelText("FACE_MM_H3")) - local genders = {GetLabelText("FACE_MALE"), GetLabelText("FACE_FEMALE")} - local playerPed = PlayerPedId() - - local Heritage = NativeUI.CreateHeritageWindow(10, 8) - submenu:AddWindow(Heritage) - - local females = {"Sophia 1", "Sophia 2", "Sophia3", "Sophia4", "Sophia5", "Sophia6", "Sophia7", "Sophia8", "Sophia9","Sophia"} - local males = { "Benjamin", "Daniel", "Joshua", "Noah", "Andrew", "Juan", "Alex", "Isaac", "Evan", "Ethan", "Vincent", "Angel", "Diego", "Adrian", "Gabriel", "Michael", "Santiago", "Kevin", "Louis", "Samuel", "Anthony"} - Mum = 10 - Dad = 9 - - momList = NativeUI.CreateListItem(GetLabelText("FACE_MUMS"), females, 1, GetLabelText("CHARC_H_30")) - submenu:AddItem(momList) - - dadList = NativeUI.CreateListItem(GetLabelText("FACE_DADS"), males, 1, GetLabelText("CHARC_H_31")) - submenu:AddItem(dadList) - - submenu.OnListChange = function(sender, item, index) - if item == momList then - Mum = index - elseif item == dadList then - Dad = index - end - - Heritage:Index(Mum, Dad) - SetPedHeadBlendData(PlayerPedId(), 0, math.random(12), 0,math.random(12), Mum, Dad,1.0,1.0,1.0,true) - - while not HasPedHeadBlendFinished(PlayerPedId()) do - Wait(500) - end - end - - local amount = {} - - for i = 1, 10 do - amount[i] = i - end - - local newitem = NativeUI.CreateSliderItem(GetLabelText("FACE_H_DOM"), amount, 1, GetLabelText("CHARC_H_9")) - submenu:AddItem(newitem) - - local newitem2 = NativeUI.CreateSliderItem(GetLabelText("FACE_H_STON"), amount, 1, GetLabelText("FACE_HER_ST_H")) - submenu:AddItem(newitem2) - - submenu.OnSliderChange = function(sender, item, index) - if item == newitem then - reseamblance = item:IndexToItem(index) - elseif item == newitem2 then - skinTone = item:IndexToItem(index) - end - end -end - -function AddAppearanceSelection(menu) - local submenu = _charPool:AddSubMenu(menu, GetLabelText("FACE_APP"), GetLabelText("FACE_MM_H6")) - if IsPedMale(PlayerPedId()) then - hairstyles = { GetLabelText("CC_M_HS_1"), GetLabelText("CC_M_HS_2"), GetLabelText("CC_M_HS_3"), GetLabelText("CC_M_HS_4"), - GetLabelText("CC_M_HS_5"), GetLabelText("CC_M_HS_6"), GetLabelText("CC_M_HS_7"), - GetLabelText("CC_M_HS_8"), GetLabelText("CC_M_HS_9"), GetLabelText("CC_M_HS_10"), - GetLabelText("CC_M_HS_11"), GetLabelText("CC_M_HS_12"), GetLabelText("CC_M_HS_13"), - GetLabelText("CC_M_HS_14"), GetLabelText("CC_M_HS_15"), GetLabelText("CC_M_HS_16"), - GetLabelText("CC_M_HS_17"), GetLabelText("CC_M_HS_18"), GetLabelText("CC_M_HS_19"), - GetLabelText("CC_M_HS_20"), GetLabelText("CC_M_HS_21"), GetLabelText("CC_M_HS_22") - } - else - hairstyles = { GetLabelText("CC_F_HS_1"), GetLabelText("CC_F_HS_2"), GetLabelText("CC_F_HS_3"), - GetLabelText("CC_F_HS_4"), GetLabelText("CC_F_HS_5"), GetLabelText("CC_F_HS_6"), - GetLabelText("CC_F_HS_7"), GetLabelText("CC_F_HS_8"), GetLabelText("CC_F_HS_9"), - GetLabelText("CC_F_HS_10"), GetLabelText("CC_F_HS_11"), GetLabelText("CC_F_HS_12"), - GetLabelText("CC_F_HS_13"), GetLabelText("CC_F_HS_14"), GetLabelText("CC_F_HS_15"), - GetLabelText("CC_F_HS_16"), GetLabelText("CC_F_HS_17"), GetLabelText("CC_F_HS_18"), - GetLabelText("CC_F_HS_19"), GetLabelText("CC_F_HS_20"), GetLabelText("CC_F_HS_21"), - GetLabelText("CC_F_HS_22"), GetLabelText("CC_F_HS_23") - } - end - - local HairItem = NativeUI.CreateListItem(GetLabelText("FACE_HAIR"), hairstyles, 1, GetLabelText("FACE_APP_H")) - submenu:AddItem(HairItem) - - local hairColors = { - {22, 19, 19}, - {30, 28, 25}, - {76, 56, 45}, - {69, 34, 24}, - {123, 59, 31}, - {149, 68, 35}, - {165, 87, 50}, - {175, 111, 72}, - {159, 105, 68}, - {198, 152, 108}, - } - - local hairColor = NativeUI.CreateColourPanel(GetLabelText("IB_COLOR"), hairColors) - HairItem:AddPanel(hairColor) - - submenu.OnListChange = function(sender, item, index) - if item == HairItem then - hairId = index - SetPedComponentVariation(PlayerPedId(), 2, hairId, 2, 0) - end - end -end - -function AddApparelSelection(menu) - local glasses = {} - local hats = { GetLabelText("CELL_831"), GetLabelText("HT_FMM_2_0")} - local submenu = _charPool:AddSubMenu(menu, GetLabelText("FACE_APPA"), GetLabelText("FACE_MM_H7")) - - local StyleItem = NativeUI.CreateListItem(GetLabelText("FACE_APP_STY"), genders , 1, GetLabelText("FACE_APP_H")) - submenu:AddItem(StyleItem) - - TotalGlasses = GetNumberOfPedPropDrawableVariations(PlayerPedId(), 1) - for i = 0, TotalGlasses do - table.insert(glasses, i) - end - - local Hatitem = NativeUI.CreateListItem(GetLabelText("FACE_HAT"), hats, 0, GetLabelText("FACE_APP_H")) - submenu:AddItem(Hatitem) - - local glassesItem = NativeUI.CreateListItem(GetLabelText("FACE_GLS"), glasses, 1, GetLabelText("FACE_APP_H")) - submenu:AddItem(glassesItem) - - submenu.OnListChange = function(sender, item, index) - if item == StyleItem then - - elseif item == Hatitem then - hatValue = item:IndexToItem(index) - print(hatValue) - if hatValue == GetLabelText("CELL_831") then - hatId = 8 - if IsPedPropValid(PlayerPedId(), 0, hatId, 0) then - SetPedPropIndex(PlayerPedId(), 0, hatId, 0, true) - end - elseif hatValue == GetLabelText("HT_FMM_2_0") then - hatId = 2 - if IsPedPropValid(PlayerPedId(), 0, hatId, 0) then - SetPedPropIndex(PlayerPedId(), 0, hatId, 0, true) - end - end - - elseif item == glassesItem then - glassValue = item:IndexToItem(index) - if IsPedPropValid(PlayerPedId(), 1, glassValue, 0) then - SetPedPropIndex(PlayerPedId(), 1, glassValue, 0, true) - end - end - end -end - -function AddStatsSelection(menu) - local submenu = _charPool:AddSubMenu(menu, GetLabelText("FACE_STATS"), "") - local newitem = NativeUI.CreateListItem(GetLabelText("PIM_MAGMSTL"), genders, 1, GetLabelText("FACE_APP_H")) - - submenu:AddItem(newitem) - submenu.OnListSelect = function(sender, item, index) - if item == newitem then - - end - end -end - -function AddSaveSelection(menu) - local submenu = _charPool:AddSubMenu(menu, GetLabelText("FACE_SAVE"), GetLabelText("FACE_MM_H8")) - local newitem = NativeUI.CreateItem(GetLabelText("FE_HLP29"), GetLabelText("FACE_W_2")) - - submenu:AddItem(newitem) - - local cancelConfirm = NativeUI.CreateItem(GetLabelText("FE_HLP27"), GetLabelText("FACE_W_2")) - submenu:AddItem(cancelConfirm) - - submenu.OnItemSelect = function(sender, item, index) - if item == newitem then - if DoesCamExist(cam) then - RenderScriptCams(false, false, 3000, 1, 0, 0) - FreezeEntityPosition(PlayerPedId(), false) - submenu:Visible(not submenu:Visible()) - DestroyCam(cam, true) - end - - local joinCoords = vector3(-1044.645, -2749.844, 21.36343-1.0) - - if not IsScreenFadedOut() then - DoScreenFadeOut(400) - while not IsScreenFadedOut() do - Wait(50) - end - end - - SetEntityCoords(PlayerPedId(), -1044.645, -2749.844, 21.36343-1.0) - SetEntityHeading(PlayerPedId(), 328.147) - while not HasCollisionLoadedAroundEntity(PlayerPedId()) do - Wait(1) - end - - _charPool:Remove() - - if IsScreenFadedOut() then - Wait(500) - DoScreenFadeIn(300) - Wait(400) - end - - SimulatePlayerInputGait(PlayerId(), 1.0, 8500, 1.0, 1, 0) - TriggerServerEvent('vf_ammunation:LoadPlayer') - - SetPlayerScores(1, 2000, 1, 1000, 1) - hidehud = false - end - end -end - -function DisplayCharacterCreatorMenu(menu) - AddGenderSelection(menu) - AddHeritageSelection(menu) - AddAppearanceSelection(menu) - AddApparelSelection(menu) - AddStatsSelection(menu) - AddSaveSelection(menu) -end - -Citizen.CreateThread(function() - while true do - Wait(0) - if NetworkIsGameInProgress() and IsPlayerPlaying(PlayerId()) then - if IsCharacterCreated then - if _charPool:IsAnyMenuOpen() then - _charPool:ProcessMenus() - end - - if DoesCamExist(cam) and not IsPlayerSwitchInProgress() then - if not _charPool:IsAnyMenuOpen() then - charMenu:Visible(not charMenu:Visible()) - end - end - end - end - end -end) \ No newline at end of file From 88d72eb95d5ff887eb391c0f11971036dee4a0fc Mon Sep 17 00:00:00 2001 From: Glenn Hermans Date: Thu, 30 May 2019 16:03:58 +0200 Subject: [PATCH 03/15] Drop old file --- vf_base/client/interaction.lua | 129 --------------------------------- 1 file changed, 129 deletions(-) delete mode 100644 vf_base/client/interaction.lua diff --git a/vf_base/client/interaction.lua b/vf_base/client/interaction.lua deleted file mode 100644 index 10bd343..0000000 --- a/vf_base/client/interaction.lua +++ /dev/null @@ -1,129 +0,0 @@ -local DoesInteractionMenuExist = false -personalVeh = nil - -function AddInterActionMenu(menu) - local newitem = UIMenuItem.New(GetLabelText("PM_SETTING_10"), '') - menu:AddItem(newitem) - newitem.Activated = function(ParentMenu, SelectedItem) - if SelectedItem == newitem then - menu:Visible(not menu:Visible()) - SetEntityHealth(PlayerPedId(), 0) - end - end -end - -function VehiclesInventoryMenu(menu) - local submenu = _menuPool:AddSubMenu(menu, GetLabelText("VEX_NMB")) - local personalVehicles = DefaultVehicles - - local personalAirVehs = { - "lazer", - } - - local engineStatus = { - GetLabelText("BIK_AGPOS_ON"), - GetLabelText("BIK_AGPOS_OFF") - } - - local doorStatus = { - GetLabelText("BM_UNLOCKED"), - GetLabelText("PM_UCON_LCK") - } - - vehItem = NativeUI.CreateListItem(GetLabelText("PIM_TRPV"), personalVehicles, 1, GetLabelText("MPCT_PERVEH1B")) - submenu:AddItem(vehItem) - - vehAirItem = NativeUI.CreateListItem(GetLabelText("PIM_TRPA"), personalAirVehs, 1, GetLabelText("MPCT_PERVEH1B")) - submenu:AddItem(vehAirItem) - - DestroyVeh = UIMenuItem.New(GetLabelText("PIM_TA16"), "") - submenu:AddItem(DestroyVeh) - DestroyVeh.Activated = function(ParentMenu, SelectedItem) - if SelectedItem == DestroyVeh then - DestroyPV(personalVeh) - end - end - - emptyVeh = UIMenuItem.New(GetLabelText("PIM_TEMV"), GetLabelText("PIM_HEMV0")) - submenu:AddItem(emptyVeh) - emptyVeh.Activated = function(ParentMenu, SelectedItem) - if SelectedItem == emptyVeh then - if IsPedInAnyVehicle(PlayerPedId(), false) then - currentVeh = GetVehiclePedIsUsing(PlayerPedId()) - TaskEveryoneLeaveVehicle(currentVeh) - else - DisplayNotification(GetLabelText("PIM_HEMV1")) - end - end - end - - vehDoorsItem = NativeUI.CreateListItem(GetLabelText("PIM_TDPV"), doorStatus, 1, "") - submenu:AddItem(vehDoorsItem) - - submenu.OnListSelect = function(sender, item, index) - if item == vehItem then - if not DoesEntityExist(personalVeh) then - quantity = item:IndexToItem(index) - personalVeh = RequestPV(quantity) - else - DisplayNotification(GetLabelText("PIM_HRPV9")) - end - elseif item == vehAirItem then - if not DoesEntityExist(personalVeh) then - quantity = item:IndexToItem(index) - personalVeh = RequestPV(quantity) - else - DisplayNotification(GetLabelText("PIM_HRPV9")) - end - elseif item == vehDoorsItem then - quantity = item:IndexToItem(index) - end - end - - local vehRepair = UIMenuItem.New(GetLabelText("BLIP_544"), "") - vehRepair:RightLabel('$ ' .. '50') - submenu:AddItem(vehRepair) - - vehRepair.Activated = function(ParentMenu, SelectedItem) - if SelectedItem == vehRepair then - if IsPedInAnyVehicle(PlayerPedId(), false) then - currentVeh = GetVehiclePedIsUsing(PlayerPedId()) - SetVehicleFixed(currentVeh) - else - DisplayNotification(GetLabelText("PIM_HEMV1")) - end - end - end -end - -Citizen.CreateThread(function() - while true do - Wait(1) - if NetworkIsGameInProgress() and IsPlayerPlaying(PlayerId()) then - playerID = PlayerId() - playerName = GetPlayerName(playerID) - playerPed = PlayerPedId() - - if not DoesInteractionMenuExist then - DecorRegister("vf_personalvehicle", 2) - - _menuPool = MenuPool.New() - mainMenu = UIMenu.New(playerName, "~b~" .. GetLabelText("INPUT_INTERACTION_MENU")) - _menuPool:Add(mainMenu) - - AddInterActionMenu(mainMenu) - VehiclesInventoryMenu(mainMenu) - - _menuPool:RefreshIndex() - _menuPool:MouseControlsEnabled(false) - DoesInteractionMenuExist = true - end - - _menuPool:ProcessMenus() - if IsControlJustPressed(1, 244) then - mainMenu:Visible(not mainMenu:Visible()) - end - end - - end -end) \ No newline at end of file From 5a02a34c34fbcdc1b32052c7506e46f0c3a85a47 Mon Sep 17 00:00:00 2001 From: Glenn Hermans Date: Wed, 12 Jun 2019 19:26:41 +0200 Subject: [PATCH 04/15] Fix #57 --- vf_interaction/__resource.lua | 22 +- vf_interaction/client.lua | 648 +++++++++++++++++++---------- vf_interaction/config/costs.lua | 6 +- vf_interaction/config/vehicles.lua | 76 ++-- vf_interaction/server.lua | 22 +- vf_interaction/vehicles.lua | 168 ++++---- 6 files changed, 569 insertions(+), 373 deletions(-) diff --git a/vf_interaction/__resource.lua b/vf_interaction/__resource.lua index 7324b75..8c85348 100644 --- a/vf_interaction/__resource.lua +++ b/vf_interaction/__resource.lua @@ -1,11 +1,13 @@ -resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' - -client_scripts { - '@NativeUI/NativeUI.lua', - 'config/costs.lua', - 'config/vehicles.lua', - 'vehicles.lua', - 'client.lua' -} - +resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' + +dependencies {'ghmattimysql', 'NativeUI', 'vf_base'} + +client_scripts { + '@NativeUI/NativeUI.lua', + 'config/costs.lua', + 'config/vehicles.lua', + 'vehicles.lua', + 'client.lua' +} + server_script 'server.lua' \ No newline at end of file diff --git a/vf_interaction/client.lua b/vf_interaction/client.lua index 5e7f562..23f0305 100644 --- a/vf_interaction/client.lua +++ b/vf_interaction/client.lua @@ -1,228 +1,422 @@ -DoesInteractionMenuExist = false -IsPlayerNearImpoundGate = false -personalVeh = nil -gateBlip = nil -gateHash = "prop_facgate_08" -playerPed = nil - -function DisplayWarning(text) - BeginTextCommandDisplayHelp(text) - EndTextCommandDisplayHelp(0, 0, 0, 8000) -end - -function DisplayNotification(text) - SetNotificationTextEntry("STRING") - SetNotificationBackgroundColor(140) - AddTextComponentString(text) - DrawNotification(false, false) -end - -function AddInterActionMenu(menu) - local newitem = UIMenuItem.New(GetLabelText("PM_SETTING_10"), '') - menu:AddItem(newitem) - newitem.Activated = function(ParentMenu, SelectedItem) - if SelectedItem == newitem then - menu:Visible(not menu:Visible()) - SetEntityHealth(PlayerPedId(), 0) - end - end - - local newitem = UIMenuItem.New(GetLabelText("GC_MENU26"), "") - newitem:RightLabel('$ ' .. Costs.clear_wanted_level) - menu:AddItem(newitem) - newitem.Activated = function(ParentMenu, SelectedItem) - if SelectedItem == newitem then - if IsPlayerWantedLevelGreater(PlayerId(), 0) then - local something, CashAmount = StatGetInt("MP0_WALLET_BALANCE",-1) - if tonumber(CashAmount) >= Costs.clear_wanted_level then - ClearPlayerWantedLevel(PlayerId()) - TriggerServerEvent('vf_interaction:pay', Costs.clear_wanted_level) - DisplayNotification(GetLabelText("FMMC_LOST_WANTED_LEVEL")) - else - DisplayNotification(GetLabelText("BB_NOMONEY")) - end - else - DisplayNotification(GetLabelText("CHEAT_WANTED_DOWN_DENIED")) - end - end - end -end - -function VehiclesInventoryMenu(menu) - local submenu = _menuPool:AddSubMenu(menu, GetLabelText("VEX_NMB")) - local personalVehicles = DefaultVehicles - - local personalAirVehs = { - "lazer", - } - - local engineStatus = { - GetLabelText("BIK_AGPOS_ON"), - GetLabelText("BIK_AGPOS_OFF") - } - - local doorStatus = { - GetLabelText("BM_UNLOCKED"), - GetLabelText("PM_UCON_LCK"), - GetLabelText("CMM_MOD_ST28"), - GetLabelText("CMM_MOD_S12"), - GetLabelText("CMOD_MOD_HOD"), - GetLabelText("PM_CJACK_1") - } - - vehItem = NativeUI.CreateListItem(GetLabelText("PIM_TRPV"), personalVehicles, 1, GetLabelText("MPCT_PERVEH1B")) - submenu:AddItem(vehItem) - - vehAirItem = NativeUI.CreateListItem(GetLabelText("PIM_TRPA"), personalAirVehs, 1, GetLabelText("MPCT_PERVEH1B")) - submenu:AddItem(vehAirItem) - - DestroyVeh = UIMenuItem.New(GetLabelText("PIM_TA16"), "") - submenu:AddItem(DestroyVeh) - DestroyVeh.Activated = function(ParentMenu, SelectedItem) - if SelectedItem == DestroyVeh then - Vehicles.Destroy(personalVeh) - end - end - - emptyVeh = UIMenuItem.New(GetLabelText("PIM_TEMV"), GetLabelText("PIM_HEMV0")) - submenu:AddItem(emptyVeh) - emptyVeh.Activated = function(ParentMenu, SelectedItem) - if SelectedItem == emptyVeh then - if IsPedInAnyVehicle(PlayerPedId(), false) then - currentVeh = GetVehiclePedIsUsing(PlayerPedId()) - TaskEveryoneLeaveVehicle(currentVeh) - else - DisplayNotification(GetLabelText("PIM_HEMV1")) - end - end - end - - vehDoorsItem = NativeUI.CreateListItem(GetLabelText("PIM_TDPV"), doorStatus, 1, "") - submenu:AddItem(vehDoorsItem) - - submenu.OnListSelect = function(sender, item, index) - if item == vehItem then - if not DoesEntityExist(personalVeh) then - Selected = item:IndexToItem(index) - personalVeh = Vehicles.Request(Selected) - else - DisplayNotification(GetLabelText("PIM_HRPV9")) - end - elseif item == vehAirItem then - if not DoesEntityExist(personalVeh) then - Selected = item:IndexToItem(index) - personalVeh = Vehicles.Request(Selected) - else - DisplayNotification(GetLabelText("PIM_HRPV9")) - end - elseif item == vehDoorsItem then - Selected = item:IndexToItem(index) - if Selected == tostring(GetLabelText("PM_UCON_LCK")) then - SetVehicleDoorsLocked(personalVeh, 2) - SetVehicleDoorsLockedForAllPlayers(personalVeh, 0) - elseif Selected == tostring(GetLabelText("CMM_MOD_ST28")) then - SetVehicleDoorOpen(personalVeh, 1, false, false) - elseif Selected == tostring(GetLabelText("CMM_MOD_S12")) then - if IsVehicleDoorFullyOpen(personalVeh, 5) then - print('Close ' .. GetLabelText("CMM_MOD_S12")) - SetVehicleDoorShut(personalVeh, 5, false) - else - SetVehicleDoorOpen(personalVeh, 5, false, false) - end - - elseif Selected == tostring(GetLabelText("PM_CJACK_1")) then - SetVehicleDoorsShut(personalVeh, false) - else - SetVehicleDoorsLocked(personalVeh, 1) - DisplayNotification(GetLabelText("PIM_TDPV") .. " " .. GetLabelText("PM_UCON_ULK")) - end - end - end - - local vehRepair = UIMenuItem.New(GetLabelText("BLIP_544"), "") - vehRepair:RightLabel('$ ' .. Costs.repair_vehicle) - submenu:AddItem(vehRepair) - - vehRepair.Activated = function(ParentMenu, SelectedItem) - if SelectedItem == vehRepair then - if IsPedInAnyVehicle(PlayerPedId(), false) then - local something, CashAmount = StatGetInt("MP0_WALLET_BALANCE",-1) - if CashAmount >= tonumber(50) then - currentVeh = GetVehiclePedIsUsing(PlayerPedId()) - SetVehicleFixed(currentVeh) - TriggerServerEvent('vf_interaction:pay', tonumber(Costs.repair_vehicle)) - DisplayNotification("~g~" .. GetLabelText("FM_BET_VEH") .. " " ..GetLabelText("ITEM_REPAIR")) - else - DisplayNotification(GetLabelText("BB_NOMONEY")) - end - else - DisplayNotification(GetLabelText("PIM_HEMV1")) - end - end - end -end - -Citizen.CreateThread(function() - ClearPrints() - ClearAllHelpMessages() - - while true do - Wait(250) - if DoesEntityExist(personalVeh) then - if GetVehicleEngineHealth(personalVeh) == 0 then - Vehicles.Destroy(personalVeh) - else - if IsPedInVehicle(PlayerPedId() , personalVeh, true) then - SetBlipDisplay(pvBlip, 0) - else - vehicleC = GetEntityCoords(personalVeh, true) - if DoesBlipExist(pvBlip) then - SetBlipDisplay(pvBlip, 2) - end - end - end - end - end -end) - -Citizen.CreateThread(function() - local CAT = 'mod_mnu' - local CurrentSlot = 0 - while HasAdditionalTextLoaded(CurrentSlot) and not HasThisAdditionalTextLoaded(CAT, CurrentSlot) do - Wait(0) - CurrentSlot = CurrentSlot + 1 - end - - if not HasThisAdditionalTextLoaded(CAT, CurrentSlot) then - ClearAdditionalText(CurrentSlot, true) - RequestAdditionalText(CAT, CurrentSlot) - while not HasThisAdditionalTextLoaded(CAT, CurrentSlot) do - Citizen.Wait(0) - end - end - - playerID = PlayerId() - playerName = GetPlayerName(playerID) - playerPed = PlayerPedId() - - while true do - Wait(10) - if not DoesInteractionMenuExist then - _menuPool = MenuPool.New() - mainMenu = UIMenu.New(playerName, "~b~" .. GetLabelText("INPUT_INTERACTION_MENU")) - _menuPool:Add(mainMenu) - - AddInterActionMenu(mainMenu) - VehiclesInventoryMenu(mainMenu) - - _menuPool:RefreshIndex() - _menuPool:MouseControlsEnabled(false) - DoesInteractionMenuExist = true - end - - _menuPool:ProcessMenus() - if IsControlJustPressed(1, 244) then - mainMenu:Visible(not mainMenu:Visible()) - end - end +firstTickPassed = false +inventoryItems = {} +local bodyarm = 1 +local currentWalkStyle = 1 + +RegisterNetEvent('vf_inventory:queryClient') +AddEventHandler('vf_inventory:queryClient', function(array) + inventoryItems = {} + inventoryItems = array + firstTickPassed = true +end) + +DoesInteractionMenuExist = false +IsPlayerNearImpoundGate = false +personalVeh = nil +gateBlip = nil +gateHash = "prop_facgate_08" +playerPed = nil + +function DisplayWarning(text) + BeginTextCommandDisplayHelp(text) + EndTextCommandDisplayHelp(0, 0, 0, 8000) +end + +function DisplayNotification(text) + SetNotificationTextEntry("STRING") + SetNotificationBackgroundColor(140) + AddTextComponentString(text) + DrawNotification(false, false) +end + +function AddInterActionMenu(menu) + local normal = GetLabelText("MO_GFX_NORM") + local femme = GetLabelText("PM_WALK_1") + local gangster = GetLabelText("collision_8axpk3h") + local tough = GetLabelText("collision_9y6p771") + local posh = GetLabelText("collision_9y6p770") + + local walkStyles = {normal, femme, gangster, posh, tough} + + local newitem = UIMenuItem.New(GetLabelText("PM_SETTING_10"), '') + menu:AddItem(newitem) + newitem.Activated = function(ParentMenu, SelectedItem) + if SelectedItem == newitem then + menu:Visible(not menu:Visible()) + SetEntityHealth(PlayerPedId(), 0) + end + end + + local newitem = UIMenuItem.New(GetLabelText("GC_MENU26"), "") + newitem:RightLabel('$ ' .. Costs.clear_wanted_level) + menu:AddItem(newitem) + newitem.Activated = function(ParentMenu, SelectedItem) + if SelectedItem == newitem then + if IsPlayerWantedLevelGreater(PlayerId(), 0) then + local something, CashAmount = StatGetInt("MP0_WALLET_BALANCE",-1) + if tonumber(CashAmount) >= Costs.clear_wanted_level then + ClearPlayerWantedLevel(PlayerId()) + TriggerServerEvent('vf_interaction:pay', Costs.clear_wanted_level) + DisplayNotification(GetLabelText("FMMC_LOST_WANTED_LEVEL")) + else + DisplayNotification(GetLabelText("BB_NOMONEY")) + end + else + DisplayNotification(GetLabelText("CHEAT_WANTED_DOWN_DENIED")) + end + end + end + + WalkStyle = NativeUI.CreateListItem(GetLabelText("PIM_TWALKN"), walkStyles, currentWalkStyle, GetLabelText("PIM_HWALKN")) + menu:AddItem(WalkStyle) + menu.OnListChange = function(sender, item, index) + if item == WalkStyle then + local wType = item:IndexToItem(index) + if wType == normal then + if IsPedMale(PlayerPedId()) then + clipSet = "MOVE_P_M_ONE" + else + clipSet = "MOVE_P_M_ONE" + end + currentWalkStyle = 1 + elseif wType == femme then + if IsPedMale(PlayerPedId()) then + clipSet = "MOVE_M@FEMME@" + else + clipSet = "MOVE_F@FEMME@" + end + currentWalkStyle = 2 + elseif wType == gangster then + if IsPedMale(PlayerPedId()) then + clipSet = "MOVE_M@GANGSTER@NG" + else + clipSet = "MOVE_F@GANGSTER@NG" + end + currentWalkStyle = 3 + elseif wType == posh then + if IsPedMale(PlayerPedId()) then + clipSet = "MOVE_M@POSH@" + else + clipSet = "MOVE_F@POSH@" + end + currentWalkStyle = 4 + elseif wType == tough then + if IsPedMale(PlayerPedId()) then + clipSet = "MOVE_M@TOUGH_GUY@" + else + clipSet = "MOVE_F@TOUGH_GUY@" + end + currentWalkStyle = 5 + end + + RequestClipSet(clipSet) + while not HasClipSetLoaded(clipSet) do + Citizen.Wait(1) + end + + SetPedMovementClipset(PlayerPedId(), clipSet, 1048576000) + RemoveClipSet(clipSet) + end + end + +end + +function GeneralInventoryMenu(menu) + InvMenu = _menuPool:AddSubMenu(menu, GetLabelText("PIM_TINVE"), GetLabelText("PIM_INVOFF")) + local foods = {GetLabelText("PM_DISPLAY_3"), GetLabelText("WT_BA_0"), GetLabelText("WT_BA_1"), GetLabelText("WT_BA_2"), GetLabelText("WT_BA_3"), GetLabelText("WT_BA_4")} + local newitem = NativeUI.CreateListItem(GetLabelText("WT_BA"), foods, bodyarm, GetLabelText("PIM_HARMO")) + InvMenu:AddItem(newitem) + InvMenu.OnListChange = function(sender, item, index) + if item == newitem then + local SelectedItem = item:IndexToItem(index) + if SelectedItem == GetLabelText("PM_DISPLAY_3") then + bodyarm = 1 + SetPedComponentVariation(PlayerPedId(), 9, 0, 0, 0) + elseif SelectedItem == GetLabelText("WT_BA_0") then + bodyarm = 2 + SetPedComponentVariation(PlayerPedId(), 9, 17, 0, 0) + elseif SelectedItem == GetLabelText("WT_BA_1") then + bodyarm = 3 + SetPedComponentVariation(PlayerPedId(), 9, 1, 0, 0) + elseif SelectedItem == GetLabelText("WT_BA_2") then + bodyarm = 4 + SetPedComponentVariation(PlayerPedId(), 9, 1, 1, 0) + elseif SelectedItem == GetLabelText("WT_BA_3") then + bodyarm = 5 + SetPedComponentVariation(PlayerPedId(), 9, 15, 1, 0) + elseif SelectedItem == GetLabelText("WT_BA_4") then + bodyarm = 6 + SetPedComponentVariation(PlayerPedId(), 9, 28, 0, 0) + end + end + end +end + +function SnacksInventoryMenu(menu) + Wait(100) + Snacksmenu = _menuPool:AddSubMenu(menu, GetLabelText("ACCNA_SNACK"), GetLabelText("PIM_HSNAC")) + if #inventoryItems < 1 then + local thisItem = NativeUI.CreateItem(GetLabelText("JIPMP_NA"), "") + Snacksmenu:AddItem(thisItem) + else + for k,v in pairs(inventoryItems) do + local totalItems = v.total + local thisItem = NativeUI.CreateItem(tostring(GetLabelText(v.item)), "") + + thisItem:RightLabel(v.total) + thisItem.Activated = function(ParentMenu, SelectedItem) + if SelectedItem == thisItem then + if totalItems > 0 then + totalItems = totalItems - 1 + thisItem:RightLabel(totalItems) + TriggerServerEvent('vf_base:UpdateInventory', v.item) + + if totalItems < 1 then + thisItem:SetRightBadge(BadgeStyle.Lock) + thisItem:RightLabel('') + end + + if v.item == "SNK_ITEM4" then + if not IsPedInAnyVehicle(PlayerPedId(), false) then + TaskStartScenarioInPlace(PlayerPedId(), "WORLD_HUMAN_SMOKING", 5000, true) + end + else + if not IsEntityDead(PlayerPedId()) then + local health = GetEntityHealth(PlayerPedId()) + uHealth = health + GetRandomIntInRange(10, 20) + SetEntityHealth(PlayerPedId(), uHealth) + ClearPedTasks(PlayerPedId()) + end + end + end + end + end + + Snacksmenu:AddItem(thisItem) + end + end +end + +function VehiclesInventoryMenu(menu) + Vehmenu = _menuPool:AddSubMenu(menu, GetLabelText("VEX_NMB")) + local personalVehicles = DefaultVehicles + + local personalAirVehs = { + "lazer", + } + + local engineStatus = { + GetLabelText("BIK_AGPOS_ON"), + GetLabelText("BIK_AGPOS_OFF") + } + + local doorStatus = { + GetLabelText("BM_UNLOCKED"), + GetLabelText("PM_UCON_LCK"), + GetLabelText("CMM_MOD_ST28"), + GetLabelText("CMM_MOD_S12"), + GetLabelText("CMOD_MOD_HOD"), + GetLabelText("PM_CJACK_1") + } + + vehItem = NativeUI.CreateListItem(GetLabelText("PIM_TRPV"), personalVehicles, 1, GetLabelText("MPCT_PERVEH1B")) + Vehmenu:AddItem(vehItem) + + vehAirItem = NativeUI.CreateListItem(GetLabelText("PIM_TRPA"), personalAirVehs, 1, GetLabelText("MPCT_PERVEH1B")) + Vehmenu:AddItem(vehAirItem) + + DestroyVeh = UIMenuItem.New(GetLabelText("PIM_TA16"), "") + Vehmenu:AddItem(DestroyVeh) + DestroyVeh.Activated = function(ParentMenu, SelectedItem) + if SelectedItem == DestroyVeh then + Vehicles.Destroy(personalVeh) + end + end + + emptyVeh = UIMenuItem.New(GetLabelText("PIM_TEMV"), GetLabelText("PIM_HEMV0")) + Vehmenu:AddItem(emptyVeh) + emptyVeh.Activated = function(ParentMenu, SelectedItem) + if SelectedItem == emptyVeh then + if IsPedInAnyVehicle(PlayerPedId(), false) then + currentVeh = GetVehiclePedIsUsing(PlayerPedId()) + TaskEveryoneLeaveVehicle(currentVeh) + else + DisplayNotification(GetLabelText("PIM_HEMV1")) + end + end + end + + vehDoorsItem = NativeUI.CreateListItem(GetLabelText("PIM_TDPV"), doorStatus, 1, "") + Vehmenu:AddItem(vehDoorsItem) + + Vehmenu.OnListSelect = function(sender, item, index) + if item == vehItem then + if not DoesEntityExist(personalVeh) then + Selected = item:IndexToItem(index) + personalVeh = Vehicles.Request(Selected) + else + DisplayNotification(GetLabelText("PIM_HRPV9")) + end + elseif item == vehAirItem then + if not DoesEntityExist(personalVeh) then + Selected = item:IndexToItem(index) + personalVeh = Vehicles.Request(Selected) + else + DisplayNotification(GetLabelText("PIM_HRPV9")) + end + elseif item == vehDoorsItem then + Selected = item:IndexToItem(index) + if Selected == tostring(GetLabelText("PM_UCON_LCK")) then + SetVehicleDoorsLocked(personalVeh, 2) + SetVehicleDoorsLockedForAllPlayers(personalVeh, 0) + elseif Selected == tostring(GetLabelText("CMM_MOD_ST28")) then + if GetVehicleDoorAngleRatio(personalVeh, 1) > 0.0 then + SetVehicleDoorShut(personalVeh, 1, false) + else + SetVehicleDoorOpen(personalVeh, 1, false, false) + end + elseif Selected == tostring(GetLabelText("CMM_MOD_S12")) then + if GetVehicleDoorAngleRatio(personalVeh, 5) > 0.0 then + SetVehicleDoorShut(personalVeh, 5, false) + else + SetVehicleDoorOpen(personalVeh, 5, false, false) + end + + elseif Selected == tostring(GetLabelText("CMOD_MOD_HOD")) then + if GetVehicleDoorAngleRatio(personalVeh, 4) > 0.0 then + SetVehicleDoorShut(personalVeh, 4, false) + else + SetVehicleDoorOpen(personalVeh, 4, false, false) + end + + elseif Selected == tostring(GetLabelText("PM_CJACK_1")) then + SetVehicleDoorsShut(personalVeh, false) + else + SetVehicleDoorsLocked(personalVeh, 1) + DisplayNotification(GetLabelText("PIM_TDPV") .. " " .. GetLabelText("PM_UCON_ULK")) + end + end + end + + local vehRepair = UIMenuItem.New(GetLabelText("BLIP_544"), "") + vehRepair:RightLabel('$ ' .. Costs.repair_vehicle) + Vehmenu:AddItem(vehRepair) + + vehRepair.Activated = function(ParentMenu, SelectedItem) + if SelectedItem == vehRepair then + if IsPedInAnyVehicle(PlayerPedId(), false) then + local something, CashAmount = StatGetInt("MP0_WALLET_BALANCE",-1) + if CashAmount >= tonumber(50) then + currentVeh = GetVehiclePedIsUsing(PlayerPedId()) + SetVehicleFixed(currentVeh) + TriggerServerEvent('vf_interaction:pay', tonumber(Costs.repair_vehicle)) + DisplayNotification("~g~" .. GetLabelText("FM_BET_VEH") .. " " ..GetLabelText("ITEM_REPAIR")) + else + DisplayNotification(GetLabelText("BB_NOMONEY")) + end + else + DisplayNotification(GetLabelText("PIM_HEMV1")) + end + end + end +end + +Citizen.CreateThread(function() + ClearPrints() + ClearAllHelpMessages() + firstTickPassed = true + while true do + Wait(250) + if DoesEntityExist(personalVeh) then + if GetVehicleEngineHealth(personalVeh) == 0 then + Vehicles.Destroy(personalVeh) + else + if IsPedInVehicle(PlayerPedId() , personalVeh, true) then + vehicle = GetVehiclePedIsUsing(PlayerPedId()) + if DoesBlipExist(GetBlipFromEntity(vehicle)) then + SetBlipDisplay(GetBlipFromEntity(vehicle), 0) + end + else + vehicleC = GetEntityCoords(personalVeh, true) + if DoesBlipExist(pvBlip) then + SetBlipDisplay(pvBlip, 2) + end + end + end + end + + if IsPedUsingScenario(PlayerPedId(), "WORLD_HUMAN_SMOKING") then + if not IsEntityDead(PlayerPedId()) then + Wait(9000) + local health = GetEntityHealth(PlayerPedId()) + uHealth = health - 10 + SetEntityHealth(PlayerPedId(), uHealth) + end + + Wait(5000) + ClearPedTasks(PlayerPedId()) + Wait(2000) + end + end +end) + +Citizen.CreateThread(function() + local CAT = 'mod_mnu' + local CurrentSlot = 0 + while HasAdditionalTextLoaded(CurrentSlot) and not HasThisAdditionalTextLoaded(CAT, CurrentSlot) do + Wait(0) + CurrentSlot = CurrentSlot + 1 + end + + if not HasThisAdditionalTextLoaded(CAT, CurrentSlot) then + ClearAdditionalText(CurrentSlot, true) + RequestAdditionalText(CAT, CurrentSlot) + while not HasThisAdditionalTextLoaded(CAT, CurrentSlot) do + Citizen.Wait(0) + end + end + + playerID = PlayerId() + playerName = GetPlayerName(playerID) + playerPed = PlayerPedId() + + Wait(500) + + while true do + Wait(10) + if firstTickPassed then + coords = GetEntityCoords(PlayerPedId(), true) + + if not DoesInteractionMenuExist then + if IsControlJustPressed(1, 244) then + inventoryItems = exports.vf_base:GetInventory() + _menuPool = MenuPool.New() + mainMenu = UIMenu.New(playerName, "~b~" .. GetLabelText("INPUT_INTERACTION_MENU")) + _menuPool:Add(mainMenu) + + AddInterActionMenu(mainMenu) + GeneralInventoryMenu(mainMenu) + SnacksInventoryMenu(InvMenu) + VehiclesInventoryMenu(mainMenu) + + _menuPool:RefreshIndex() + _menuPool:MouseControlsEnabled(false) + + mainMenu:Visible(not mainMenu:Visible()) + DoesInteractionMenuExist = true + end + else + _menuPool:ProcessMenus() + + if mainMenu:Visible() or InvMenu:Visible() or Snacksmenu:Visible() or Vehmenu:Visible() then + + else + _menuPool:CloseAllMenus() + _menuPool:Remove() + DoesInteractionMenuExist = false + end + end + end + + end end) \ No newline at end of file diff --git a/vf_interaction/config/costs.lua b/vf_interaction/config/costs.lua index ff9e300..d193ea9 100644 --- a/vf_interaction/config/costs.lua +++ b/vf_interaction/config/costs.lua @@ -1,4 +1,4 @@ -Costs = { - ["clear_wanted_level"] = 400, - ["repair_vehicle"] = 50, +Costs = { + ["clear_wanted_level"] = 400, + ["repair_vehicle"] = 50, } \ No newline at end of file diff --git a/vf_interaction/config/vehicles.lua b/vf_interaction/config/vehicles.lua index 17f8429..3709cbb 100644 --- a/vf_interaction/config/vehicles.lua +++ b/vf_interaction/config/vehicles.lua @@ -1,39 +1,39 @@ -DefaultVehicles = { - "AUTARCH", - "BALLER", - "BANSHEE", - "BATI", - "BATI2", - "casco", - "BESTIAGTS", - "FLASHGT", - "FUROREGT", - "GT500", - "GRANGER", - "INFERNUS2", - "KAMACHO", - "LECTRO", - "MANANA", - "PIGALLE", - "RATBIK", - "SADLER", - "SCHAFTER2", - "SPECTER", - "STRETCH", - "voltic2", - "boxville5", - "oppressor2", - "tampa3", - "deluxo", - "wastelander", - "boxville5", - "blazer5", - "dune5", - "phantom2", - "technical", - "technical2", - "thruster", - "viseris", - "nero", - "terbyte" +DefaultVehicles = { + "AUTARCH", + "BALLER", + "BANSHEE", + "BATI", + "BATI2", + "casco", + "BESTIAGTS", + "FLASHGT", + "FUROREGT", + "GT500", + "GRANGER", + "INFERNUS2", + "KAMACHO", + "LECTRO", + "MANANA", + "PIGALLE", + "RATBIK", + "SADLER", + "SCHAFTER2", + "SPECTER", + "STRETCH", + "voltic2", + "boxville5", + "oppressor2", + "tampa3", + "deluxo", + "wastelander", + "boxville5", + "blazer5", + "dune5", + "phantom2", + "technical", + "technical2", + "thruster", + "viseris", + "nero", + "terbyte" } \ No newline at end of file diff --git a/vf_interaction/server.lua b/vf_interaction/server.lua index 9d78587..9476504 100644 --- a/vf_interaction/server.lua +++ b/vf_interaction/server.lua @@ -1,11 +1,11 @@ -RegisterServerEvent('vf_interaction:pay') -AddEventHandler('vf_interaction:pay', function(price) - local src = source - - TriggerEvent('vf_base:FindPlayer', src, function(user) - local cash = user.cash - if cash >= tonumber(price) then - TriggerEvent('vf_base:ClearCash', src, tonumber(price)) - end - end) -end) \ No newline at end of file +RegisterServerEvent('vf_interaction:pay') +AddEventHandler('vf_interaction:pay', function(price) + local src = source + + TriggerEvent('vf_base:FindPlayer', src, function(user) + local cash = user.cash + if cash >= tonumber(price) then + TriggerEvent('vf_base:ClearCash', src, tonumber(price)) + end + end) +end) diff --git a/vf_interaction/vehicles.lua b/vf_interaction/vehicles.lua index 1472239..7c36113 100644 --- a/vf_interaction/vehicles.lua +++ b/vf_interaction/vehicles.lua @@ -1,85 +1,85 @@ -Vehicles = {} - -function Vehicles.Request(vehicleHash) - local modelHash = vehicleHash - local playerPed = PlayerPedId() - - if IsModelValid(modelHash) then - RequestModel(modelHash) - while not HasModelLoaded(modelHash) do - Wait(10) - end - - local x,y,z = table.unpack(GetEntityCoords(playerPed, true)) - local _, vector = GetNthClosestVehicleNodeWithHeading(x, y, z, math.random(5, 10), 0, 0, 0) - local SpawnX, SpawnY, SpawnZ, SpawnH = table.unpack(vector) - - if not IsThisModelAPlane(modelHash) then - veh = CreateVehicle(modelHash, SpawnX, SpawnY, SpawnZ, SpawnH, true, false) - while not DoesEntityExist(veh) do - Wait(10) - end - - SetEntityHeading(veh, SpawnH) - else - veh = CreateVehicle(modelHash, x, y, z+395.0, SpawnH, true, false) - while not DoesEntityExist(veh) do - Wait(10) - end - - SetHeliBladesFullSpeed(veh) - end - - if DoesEntityExist(veh) then - SetVehicleHasBeenOwnedByPlayer(veh, true) - - if not DoesBlipExist(pvBlip) then - pvBlip = AddBlipForEntity(veh) - if IsThisModelAPlane(modelHash) then - SetBlipSprite(pvBlip, 16) - elseif IsThisModelAHeli(modelHash) then - SetBlipSprite(pvBlip, 43) - elseif IsThisModelABoat(modelHash) then - SetBlipSprite(pvBlip, 427) - elseif IsThisModelABike(modelHash) then - SetBlipSprite(pvBlip, 226) - else - SetBlipSprite(pvBlip, 225) - end - - SetBlipNameFromTextFile(pvBlip, "PVEHICLE") - SetBlipColour(pvBlip, 4) - - SetBlipFlashes(pvBlip, true) - SetBlipFlashTimer(pvBlip, 7000) - end - SetVehicleEngineOn(veh, true, true, true) - TaskWarpPedIntoVehicle(playerPed, veh, -1) - - SetModelAsNoLongerNeeded(modelHash) - return veh - end - end -end - -function Vehicles.Destroy(personalVeh) - if DoesEntityExist(personalVeh) then - if DoesBlipExist(pvBlip) then - RemoveBlip(pvBlip) - end - - if IsPedInVehicle(PlayerPedId(), personalVeh, false) then - TaskEveryoneLeaveVehicle(personalVeh) - TaskLeaveVehicle(PlayerPedId(), personalVeh, 0) - Wait(2000) - end - DeleteEntity(personalVeh) - personalVeh = nil - else - DisplayNotification(GetLabelText("PIM_HEMV1")) - end -end - -function Vehicles.Impound(personalVeh) - SetEntityCoords(personalVeh, 420.705, -1638.87, 29.2919, 0.0, 0.0, 0.0, true) +Vehicles = {} + +function Vehicles.Request(vehicleHash) + local modelHash = vehicleHash + local playerPed = PlayerPedId() + + if IsModelValid(modelHash) then + RequestModel(modelHash) + while not HasModelLoaded(modelHash) do + Wait(10) + end + + local x,y,z = table.unpack(GetEntityCoords(playerPed, true)) + local _, vector = GetNthClosestVehicleNodeWithHeading(x, y, z, math.random(5, 10), 0, 0, 0) + local SpawnX, SpawnY, SpawnZ, SpawnH = table.unpack(vector) + + if not IsThisModelAPlane(modelHash) then + veh = CreateVehicle(modelHash, SpawnX, SpawnY, SpawnZ, SpawnH, true, false) + while not DoesEntityExist(veh) do + Wait(10) + end + + SetEntityHeading(veh, SpawnH) + else + veh = CreateVehicle(modelHash, x, y, z+395.0, SpawnH, true, false) + while not DoesEntityExist(veh) do + Wait(10) + end + + SetHeliBladesFullSpeed(veh) + end + + if DoesEntityExist(veh) then + SetVehicleHasBeenOwnedByPlayer(veh, true) + + if not DoesBlipExist(pvBlip) then + pvBlip = AddBlipForEntity(veh) + if IsThisModelAPlane(modelHash) then + SetBlipSprite(pvBlip, 16) + elseif IsThisModelAHeli(modelHash) then + SetBlipSprite(pvBlip, 43) + elseif IsThisModelABoat(modelHash) then + SetBlipSprite(pvBlip, 427) + elseif IsThisModelABike(modelHash) then + SetBlipSprite(pvBlip, 226) + else + SetBlipSprite(pvBlip, 225) + end + + SetBlipNameFromTextFile(pvBlip, "PVEHICLE") + SetBlipColour(pvBlip, 4) + + SetBlipFlashes(pvBlip, true) + SetBlipFlashTimer(pvBlip, 7000) + end + SetVehicleEngineOn(veh, true, true, true) + TaskWarpPedIntoVehicle(playerPed, veh, -1) + + SetModelAsNoLongerNeeded(modelHash) + return veh + end + end +end + +function Vehicles.Destroy(personalVeh) + if DoesEntityExist(personalVeh) then + if DoesBlipExist(pvBlip) then + RemoveBlip(pvBlip) + end + + if IsPedInVehicle(PlayerPedId(), personalVeh, false) then + TaskEveryoneLeaveVehicle(personalVeh) + TaskLeaveVehicle(PlayerPedId(), personalVeh, 0) + Wait(2000) + end + DeleteEntity(personalVeh) + personalVeh = nil + else + DisplayNotification(GetLabelText("PIM_HEMV1")) + end +end + +function Vehicles.Impound(personalVeh) + SetEntityCoords(personalVeh, 420.705, -1638.87, 29.2919, 0.0, 0.0, 0.0, true) end \ No newline at end of file From 8a55574aa532c3f2a518dca8f5e2b6a1fe81717f Mon Sep 17 00:00:00 2001 From: pongo1231 Date: Sun, 15 Sep 2019 16:12:12 +0200 Subject: [PATCH 05/15] vf_phone: Control & Pause Menu related improvements --- [phone]/vf_phone/phone/app/cl_app.lua | 10 ++++++---- [phone]/vf_phone/phone/app/cl_appmain.lua | 13 +++++++------ [phone]/vf_phone/phone/cl_phone.lua | 9 ++++++++- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/[phone]/vf_phone/phone/app/cl_app.lua b/[phone]/vf_phone/phone/app/cl_app.lua index f972a72..0d007b3 100644 --- a/[phone]/vf_phone/phone/app/cl_app.lua +++ b/[phone]/vf_phone/phone/app/cl_app.lua @@ -37,6 +37,7 @@ Citizen.CreateThread(function() screenFound = true end end + if not screenFound then -- No existing screen found Apps.Kill() end @@ -86,17 +87,17 @@ Citizen.CreateThread(function() end local navigated = true - if IsControlJustPressed(0, 300) then -- Up + if IsControlJustPressed(3, 172) then -- INPUT_CELLPHONE_UP (arrow up) _SelectedItem = _SelectedItem - 1 if _SelectedItem < 0 then _SelectedItem = #_CurrentScreen.Items - 1 end - elseif IsControlJustPressed(0, 299) then -- Down + elseif IsControlJustPressed(3, 173) then -- INPUT_CELLPHONE_DOWN (arrow down) _SelectedItem = _SelectedItem + 1 if _SelectedItem > #_CurrentScreen.Items - 1 then _SelectedItem = 0 end - elseif IsControlJustPressed(0, 255) then -- Enter + elseif IsControlJustPressed(3, 176) then -- INPUT_CELLPHONE_SELECT (enter / lmb) if #_CurrentScreen.Items > 0 then local item = _CurrentScreen.Items[_SelectedItem + 1] if type(item.Callback) == "table" then -- Action (Should be function, but it isn't because it's a table according to Msgpack!) @@ -107,7 +108,7 @@ Citizen.CreateThread(function() _SelectedItem = 0 end end - elseif IsControlJustPressed(0, 202) then -- Back + elseif IsControlJustPressed(3, 177) then -- INPUT_CELLPHONE_CANCEL (backspace / esc / rmb) if #_PrevScreens > 0 then _CurrentScreen = _PrevScreens[#_PrevScreens] table.remove(_PrevScreens) @@ -120,6 +121,7 @@ Citizen.CreateThread(function() else navigated = false end + if navigated then PlaySoundFrontend(-1, "Menu_Navigate", "Phone_SoundSet_Default") end diff --git a/[phone]/vf_phone/phone/app/cl_appmain.lua b/[phone]/vf_phone/phone/app/cl_appmain.lua index 6c6e8a4..faf8adf 100644 --- a/[phone]/vf_phone/phone/app/cl_appmain.lua +++ b/[phone]/vf_phone/phone/app/cl_appmain.lua @@ -31,30 +31,31 @@ Citizen.CreateThread(function() PopScaleformMovieFunctionVoid() local navigated = true - if IsControlJustPressed(0, 300) then -- Up + if IsControlJustPressed(3, 172) then -- INPUT_CELLPHONE_UP (arrow up) selectedItem = selectedItem - 3 if selectedItem < 0 then selectedItem = 9 + selectedItem end - elseif IsControlJustPressed(0, 299) then -- Down + elseif IsControlJustPressed(3, 173) then -- INPUT_CELLPHONE_DOWN (arrow down) selectedItem = selectedItem + 3 if selectedItem > 8 then selectedItem = selectedItem - 9 end - elseif IsControlJustPressed(0, 307) then -- Right + elseif IsControlJustPressed(3, 175) then -- INPUT_CELLPHONE_RIGHT (arrow right) selectedItem = selectedItem + 1 if selectedItem > 8 then selectedItem = 0 end - elseif IsControlJustPressed(0, 308) then -- Left + elseif IsControlJustPressed(3, 174) then -- INPUT_CELLPHONE_LEFT (arrow left) selectedItem = selectedItem - 1 if selectedItem < 0 then selectedItem = 8 end else - if IsControlJustPressed(0, 255) then -- Enter + if IsControlJustPressed(3, 176) then -- INPUT_CELLPHONE_SELECT (enter / lmb) + Wait(0) -- Workaround to next app from registering enter press too Apps.Start(selectedItem + 1) - elseif IsControlJustPressed(0, 202) then -- Back + elseif IsControlJustPressed(3, 177) then -- INPUT_CELLPHONE_CANCEL (backspace / esc / rmb) Phone.Kill() end navigated = false diff --git a/[phone]/vf_phone/phone/cl_phone.lua b/[phone]/vf_phone/phone/cl_phone.lua index 385e2c6..36ac6dc 100644 --- a/[phone]/vf_phone/phone/cl_phone.lua +++ b/[phone]/vf_phone/phone/cl_phone.lua @@ -18,6 +18,7 @@ Citizen.CreateThread(function() Wait(0) if Phone.Visible then + SetPauseMenuActive(false) SetMobilePhonePosition(58.0, -21.0 - Phone.VisibleAnimProgress, -60.0) SetMobilePhoneRotation(-90.0, Phone.VisibleAnimProgress * 4.0, 0.0) if Phone.VisibleAnimProgress > 0 then @@ -50,7 +51,7 @@ Citizen.CreateThread(function() SetTextRenderId(renderId) DrawScaleformMovie(Phone.Scaleform, 0.0998, 0.1775, 0.1983, 0.364, 255, 255, 255, 255); SetTextRenderId(1) - elseif IsControlJustPressed(0, 300) then + elseif IsControlJustPressed(3, 27) then -- INPUT_PHONE (arrow up / mmb) PlaySoundFrontend(-1, "Pull_Out", "Phone_SoundSet_Default") Phone.Scaleform = RequestScaleformMovie("CELLPHONE_IFRUIT") while not HasScaleformMovieLoaded(Phone.Scaleform) do @@ -71,4 +72,10 @@ function Phone.Kill() Phone.Scaleform = nil Phone.Visible = false DestroyMobilePhone() + + -- Prevent esc from immediately opening the pause menu + while IsControlPressed(3, 177) do + Wait(0) + SetPauseMenuActive(false) + end end \ No newline at end of file From 3a42e9ad4bec3855c75f6036c1cecc374b5df9af Mon Sep 17 00:00:00 2001 From: pongo1231 Date: Sun, 15 Sep 2019 17:05:56 +0200 Subject: [PATCH 06/15] vf_phone: Update native names --- [phone]/vf_phone/__resource.lua | 2 +- [phone]/vf_phone/phone/app/cl_app.lua | 43 +++++++++++++---------- [phone]/vf_phone/phone/app/cl_appmain.lua | 32 +++++++++-------- [phone]/vf_phone/phone/cl_phone.lua | 34 +++++++++--------- 4 files changed, 60 insertions(+), 51 deletions(-) diff --git a/[phone]/vf_phone/__resource.lua b/[phone]/vf_phone/__resource.lua index 0271d3b..9b94899 100644 --- a/[phone]/vf_phone/__resource.lua +++ b/[phone]/vf_phone/__resource.lua @@ -1,4 +1,4 @@ -resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' +resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937" client_scripts { "phone/cl_phone.lua", diff --git a/[phone]/vf_phone/phone/app/cl_app.lua b/[phone]/vf_phone/phone/app/cl_app.lua index 0d007b3..da15ad5 100644 --- a/[phone]/vf_phone/phone/app/cl_app.lua +++ b/[phone]/vf_phone/phone/app/cl_app.lua @@ -43,43 +43,48 @@ Citizen.CreateThread(function() end end else - PushScaleformMovieFunction(Phone.Scaleform, "SET_DATA_SLOT_EMPTY") - PushScaleformMovieFunctionParameterInt(_CurrentScreen.Type) - PopScaleformMovieFunctionVoid() + BeginScaleformMovieMethod(Phone.Scaleform, "SET_DATA_SLOT_EMPTY") + ScaleformMovieMethodAddParamInt(_CurrentScreen.Type) + EndScaleformMovieMethod() - local header + local header = "" if _CurrentScreen.Header then header = _CurrentScreen.Header - else + elseif _CurrentApp.Name then header = _CurrentApp.Name end - PushScaleformMovieFunction(Phone.Scaleform, "SET_HEADER") - PushScaleformMovieFunctionParameterString(header) - PopScaleformMovieFunctionVoid() + BeginScaleformMovieMethod(Phone.Scaleform, "SET_HEADER") + BeginTextCommandScaleformString("STRING") + AddTextComponentString(header) + EndTextCommandScaleformString() + EndScaleformMovieMethod() for i, item in ipairs(_CurrentScreen.Items) do - PushScaleformMovieFunction(Phone.Scaleform, "SET_DATA_SLOT") - PushScaleformMovieFunctionParameterInt(_CurrentScreen.Type) - PushScaleformMovieFunctionParameterInt(i - 1) + BeginScaleformMovieMethod(Phone.Scaleform, "SET_DATA_SLOT") + ScaleformMovieMethodAddParamInt(_CurrentScreen.Type) + ScaleformMovieMethodAddParamInt(i - 1) for _, data in ipairs(item.Data) do if type(data) == "number" then if math.type(data) == "integer" then - PushScaleformMovieFunctionParameterInt(data) + ScaleformMovieMethodAddParamInt(data) else - PushScaleformMovieFunctionParameterFloat(data) + ScaleformMovieMethodAddParamFloat(data) end elseif type(data) == "string" then - PushScaleformMovieFunctionParameterString(data) + BeginTextCommandScaleformString("STRING") + AddTextComponentString(data) + EndTextCommandScaleformString() elseif not data then - PushScaleformMovieFunctionParameterInt() + ScaleformMovieMethodAddParamInt() end end - PopScaleformMovieFunctionVoid() + EndScaleformMovieMethod() end - PushScaleformMovieFunction(Phone.Scaleform, "DISPLAY_VIEW") - PushScaleformMovieFunctionParameterInt(_CurrentScreen.Type) - PushScaleformMovieFunctionParameterInt(_SelectedItem) + BeginScaleformMovieMethod(Phone.Scaleform, "DISPLAY_VIEW") + ScaleformMovieMethodAddParamInt(_CurrentScreen.Type) + ScaleformMovieMethodAddParamInt(_SelectedItem) + EndScaleformMovieMethod() -- Fix _SelectedItem in case last item got removed while it was selected if _SelectedItem > #_CurrentScreen.Items - 1 then diff --git a/[phone]/vf_phone/phone/app/cl_appmain.lua b/[phone]/vf_phone/phone/app/cl_appmain.lua index faf8adf..38b66cd 100644 --- a/[phone]/vf_phone/phone/app/cl_appmain.lua +++ b/[phone]/vf_phone/phone/app/cl_appmain.lua @@ -6,29 +6,33 @@ Citizen.CreateThread(function() if Phone.Visible and not Phone.InApp then for i = 0, 8 do - PushScaleformMovieFunction(Phone.Scaleform, "SET_DATA_SLOT") - PushScaleformMovieFunctionParameterInt(1) - PushScaleformMovieFunctionParameterInt(i) + BeginScaleformMovieMethod(Phone.Scaleform, "SET_DATA_SLOT") + ScaleformMovieMethodAddParamInt(1) + ScaleformMovieMethodAddParamInt(i) if Apps[i + 1] and Apps[i + 1].Icon then - PushScaleformMovieFunctionParameterInt(Apps[i + 1].Icon) + ScaleformMovieMethodAddParamInt(Apps[i + 1].Icon) else - PushScaleformMovieFunctionParameterInt(3) + ScaleformMovieMethodAddParamInt(3) end - PopScaleformMovieFunctionVoid() + EndScaleformMovieMethod() end - PushScaleformMovieFunction(Phone.Scaleform, "DISPLAY_VIEW") - PushScaleformMovieFunctionParameterInt(1) - PushScaleformMovieFunctionParameterInt(selectedItem) - PopScaleformMovieFunctionVoid() + BeginScaleformMovieMethod(Phone.Scaleform, "DISPLAY_VIEW") + ScaleformMovieMethodAddParamInt(1) + ScaleformMovieMethodAddParamInt(selectedItem) + EndScaleformMovieMethod() - PushScaleformMovieFunction(Phone.Scaleform, "SET_HEADER") + BeginScaleformMovieMethod(Phone.Scaleform, "SET_HEADER") if Apps[selectedItem + 1] and Apps[selectedItem + 1].Name then - PushScaleformMovieFunctionParameterString(Apps[selectedItem + 1].Name) + BeginTextCommandScaleformString("STRING") + AddTextComponentString(Apps[selectedItem + 1].Name) + EndTextCommandScaleformString() else - PushScaleformMovieFunctionParameterString("") + BeginTextCommandScaleformString("STRING") + AddTextComponentString("") + EndTextCommandScaleformString() end - PopScaleformMovieFunctionVoid() + EndScaleformMovieMethod() local navigated = true if IsControlJustPressed(3, 172) then -- INPUT_CELLPHONE_UP (arrow up) diff --git a/[phone]/vf_phone/phone/cl_phone.lua b/[phone]/vf_phone/phone/cl_phone.lua index 36ac6dc..c890fb5 100644 --- a/[phone]/vf_phone/phone/cl_phone.lua +++ b/[phone]/vf_phone/phone/cl_phone.lua @@ -26,26 +26,26 @@ Citizen.CreateThread(function() end local h, m = NetworkGetServerTime() - PushScaleformMovieFunction(Phone.Scaleform, "SET_TITLEBAR_TIME") - PushScaleformMovieFunctionParameterInt(h) - PushScaleformMovieFunctionParameterInt(m) - PopScaleformMovieFunctionVoid() + BeginScaleformMovieMethod(Phone.Scaleform, "SET_TITLEBAR_TIME") + ScaleformMovieMethodAddParamInt(h) + ScaleformMovieMethodAddParamInt(m) + EndScaleformMovieMethod() - PushScaleformMovieFunction(Phone.Scaleform, "SET_SLEEP_MODE") - PushScaleformMovieFunctionParameterBool(Phone.SleepMode) - PopScaleformMovieFunctionVoid() + BeginScaleformMovieMethod(Phone.Scaleform, "SET_SLEEP_MODE") + ScaleformMovieMethodAddParamBool(Phone.SleepMode) + EndScaleformMovieMethod() - PushScaleformMovieFunction(Phone.Scaleform, "SET_THEME") - PushScaleformMovieFunctionParameterInt(Phone.Theme) - PopScaleformMovieFunctionVoid() + BeginScaleformMovieMethod(Phone.Scaleform, "SET_THEME") + ScaleformMovieMethodAddParamInt(Phone.Theme) + EndScaleformMovieMethod() - PushScaleformMovieFunction(Phone.Scaleform, "SET_BACKGROUND_IMAGE") - PushScaleformMovieFunctionParameterInt(Phone.Wallpaper) - PopScaleformMovieFunctionVoid() + BeginScaleformMovieMethod(Phone.Scaleform, "SET_BACKGROUND_IMAGE") + ScaleformMovieMethodAddParamInt(Phone.Wallpaper) + EndScaleformMovieMethod() - PushScaleformMovieFunction(Phone.Scaleform, "SET_SIGNAL_STRENGTH") - PushScaleformMovieFunctionParameterInt(GetZoneScumminess(GetZoneAtCoords(GetEntityCoords(PlayerPedId())))) - PopScaleformMovieFunctionVoid() + BeginScaleformMovieMethod(Phone.Scaleform, "SET_SIGNAL_STRENGTH") + ScaleformMovieMethodAddParamInt(GetZoneScumminess(GetZoneAtCoords(GetEntityCoords(PlayerPedId())))) + EndScaleformMovieMethod() local renderID = GetMobilePhoneRenderId() SetTextRenderId(renderId) @@ -61,7 +61,7 @@ Citizen.CreateThread(function() Phone.Visible = true SetMobilePhonePosition() SetMobilePhoneScale(285.0) - CreateMobilePhone(0) + CreateMobilePhone() end end end) From b6860bd5e5b2b3825b425d75cab79748c2825a46 Mon Sep 17 00:00:00 2001 From: pongo1231 Date: Sun, 15 Sep 2019 17:25:29 +0200 Subject: [PATCH 07/15] vf_phone: Change no items screen deletion logic --- [phone]/vf_phone/phone/app/api/cl_api_item.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/[phone]/vf_phone/phone/app/api/cl_api_item.lua b/[phone]/vf_phone/phone/app/api/cl_api_item.lua index f382477..eef25a0 100644 --- a/[phone]/vf_phone/phone/app/api/cl_api_item.lua +++ b/[phone]/vf_phone/phone/app/api/cl_api_item.lua @@ -11,30 +11,37 @@ local function _CreateBaseItem(screen, data, callback) return item end -function Item.RemoveItem(app, screen, item) +function Item.RemoveItem(app, screen, item, doNotRemoveScreen) local itemIndex -- Check if screen isn't being used anywhere else - local removeScreen = true + local removeScreen = not doNotRemoveScreen for _, screen in ipairs(app.Screens) do for i, screenItem in ipairs(screen.Items) do if screenItem == item then itemIndex = i + + -- Don't bother continuing if removeScreen is false already + if not removeScreen then + break + end elseif screenItem.Callback == item.Callback then removeScreen = false end end end + -- Remove screen if possible if removeScreen then table.remove(app.Screens, item.Callback) end + -- Remove item table.remove(screen.Items, itemIndex) end function Item.RemoveItemsInScreen(app, screen) for i = #screen.Items, 1, -1 do -- Reverse looping for safe table content removal - Item.RemoveItem(app, screen, screen.Items[i]) + Item.RemoveItem(app, screen, screen.Items[i], true) end end From e22156cb56e3e797c12b6509f272e3ee1cb21230 Mon Sep 17 00:00:00 2001 From: pongo1231 Date: Sun, 15 Sep 2019 17:26:09 +0200 Subject: [PATCH 08/15] vf_baseapps: Show no players item in playerlist --- [phone]/vf_baseapps/apps/cl_appplayerlist.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/[phone]/vf_baseapps/apps/cl_appplayerlist.lua b/[phone]/vf_baseapps/apps/cl_appplayerlist.lua index 6c7685f..566f262 100644 --- a/[phone]/vf_baseapps/apps/cl_appplayerlist.lua +++ b/[phone]/vf_baseapps/apps/cl_appplayerlist.lua @@ -11,17 +11,24 @@ AddEventHandler("vf_phone:setup", function(phone) while _App == loopApp do -- Destroy this loop (and coroutine) on vf_phone restart Wait(1000) _PlayerListScreen.ClearItems() - for i = 0, 64 do + + local hasPlayers = false + for i = 0, 255 do if NetworkIsPlayerConnected(i) and (IsDebug or i ~= PlayerId()) then + hasPlayers = true + local playerName = GetPlayerName(i) local playerOptionsMenu = _App.CreateListScreen(playerName) + _PlayerListScreen.AddScreenItem(playerName, 0, playerOptionsMenu) playerOptionsMenu.AddCallbackItem(GetLabelText("collision_uy2q01"), 0, function() Wait(0) -- Stop from instantly confirming message + DisplayOnscreenKeyboard(6, "FMMC_KEY_TIP8", "", "", "", "", "", 60) while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do Wait(0) end + if UpdateOnscreenKeyboard() == 1 then local message = GetOnscreenKeyboardResult() SetNotificationTextEntry("STRING") @@ -31,11 +38,16 @@ AddEventHandler("vf_phone:setup", function(phone) TriggerServerEvent("vf_phone:SendPlayerMessage", GetPlayerServerId(i), message) AddTextComponentString("~g~Message sent!") end + DrawNotification(true, true) end end) end end + + if not hasPlayers then + _PlayerListScreen.AddCallbackItem("No Players") + end end end) end) From 0dd6f954d37a1070a59dabdd81090353cdc5746e Mon Sep 17 00:00:00 2001 From: pongo1231 Date: Sun, 15 Sep 2019 17:43:09 +0200 Subject: [PATCH 09/15] vf_baseapps: Change new text message text --- [phone]/vf_baseapps/__resource.lua | 4 ++-- [phone]/vf_baseapps/apps/cl_appmessages.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/[phone]/vf_baseapps/__resource.lua b/[phone]/vf_baseapps/__resource.lua index a8be4b2..3cb37e7 100644 --- a/[phone]/vf_baseapps/__resource.lua +++ b/[phone]/vf_baseapps/__resource.lua @@ -1,5 +1,5 @@ -resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' -resource_debugmode "0" +resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937" +resource_debugmode "1" client_scripts { "cl_main.lua", diff --git a/[phone]/vf_baseapps/apps/cl_appmessages.lua b/[phone]/vf_baseapps/apps/cl_appmessages.lua index 2ed2881..c18f7b1 100644 --- a/[phone]/vf_baseapps/apps/cl_appmessages.lua +++ b/[phone]/vf_baseapps/apps/cl_appmessages.lua @@ -14,7 +14,7 @@ AddEventHandler("vf_phone:ReceivePlayerMessage", function(playerServer, message) if not _Phone.IsSleepModeOn() then SetNotificationTextEntry("STRING") AddTextComponentString(message) - SetNotificationMessage(headshotTxd, headshotTxd, true, 1, "New Message!", playerName) + SetNotificationMessage(headshotTxd, headshotTxd, true, 1, "New Message", playerName) DrawNotification(true, true) PlaySound(-1, "Text_Arrive_Tone", "Phone_SoundSet_Default") end From 1d8f912fd203257ce34809c4c9ac6ca0b6defc56 Mon Sep 17 00:00:00 2001 From: pongo1231 Date: Sun, 15 Sep 2019 17:46:35 +0200 Subject: [PATCH 10/15] vf_phone: Display current time instead of network time --- [phone]/vf_phone/phone/cl_phone.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[phone]/vf_phone/phone/cl_phone.lua b/[phone]/vf_phone/phone/cl_phone.lua index c890fb5..2c04495 100644 --- a/[phone]/vf_phone/phone/cl_phone.lua +++ b/[phone]/vf_phone/phone/cl_phone.lua @@ -25,7 +25,7 @@ Citizen.CreateThread(function() Phone.VisibleAnimProgress = Phone.VisibleAnimProgress - 3 end - local h, m = NetworkGetServerTime() + local h, m = GetClockHours(), GetClockMinutes() BeginScaleformMovieMethod(Phone.Scaleform, "SET_TITLEBAR_TIME") ScaleformMovieMethodAddParamInt(h) ScaleformMovieMethodAddParamInt(m) From 5d679ba1fb3158ceb658a11f528f4327953a8c54 Mon Sep 17 00:00:00 2001 From: ghermans Date: Wed, 2 Oct 2019 00:25:01 +0200 Subject: [PATCH 11/15] Initial progress on #45 --- venomous.cfg | 1 + vf_convenience/README.md | 3 + vf_convenience/__resource.lua | 13 +++ vf_convenience/cl_menu.lua | 109 ++++++++++++++++++ vf_convenience/cl_ped.lua | 135 ++++++++++++++++++++++ vf_convenience/client.lua | 209 ++++++++++++++++++++++++++++++++++ vf_convenience/config.lua | 87 ++++++++++++++ vf_convenience/server.lua | 22 ++++ 8 files changed, 579 insertions(+) create mode 100644 vf_convenience/README.md create mode 100644 vf_convenience/__resource.lua create mode 100644 vf_convenience/cl_menu.lua create mode 100644 vf_convenience/cl_ped.lua create mode 100644 vf_convenience/client.lua create mode 100644 vf_convenience/config.lua create mode 100644 vf_convenience/server.lua diff --git a/venomous.cfg b/venomous.cfg index 69d259b..a9fd0c1 100644 --- a/venomous.cfg +++ b/venomous.cfg @@ -20,5 +20,6 @@ start vf_ammunation start vf_bank start vf_cinema start vf_loading +start vf_convenience start vf_interaction start vf_vending \ No newline at end of file diff --git a/vf_convenience/README.md b/vf_convenience/README.md new file mode 100644 index 0000000..5a55ff6 --- /dev/null +++ b/vf_convenience/README.md @@ -0,0 +1,3 @@ +# vf_convenience + +Purchase snacks to increase your health. \ No newline at end of file diff --git a/vf_convenience/__resource.lua b/vf_convenience/__resource.lua new file mode 100644 index 0000000..62519a8 --- /dev/null +++ b/vf_convenience/__resource.lua @@ -0,0 +1,13 @@ +resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' + +dependencies {'ghmattimysql', 'NativeUI', 'vf_base'} + +client_scripts { + "@NativeUI/NativeUI.lua", + "config.lua", + "cl_ped.lua", + "cl_menu.lua", + "client.lua" +} + +server_script "server.lua" \ No newline at end of file diff --git a/vf_convenience/cl_menu.lua b/vf_convenience/cl_menu.lua new file mode 100644 index 0000000..0d2cc7b --- /dev/null +++ b/vf_convenience/cl_menu.lua @@ -0,0 +1,109 @@ +CurrentSlot = 10 +gxt = "SNK_MNU" + + +RegisterNetEvent('vf_convenience:update') +AddEventHandler('vf_convenience:update', function() + if DoesStoreMenuExist then + _generalStorePool:Clear() + _generalStorePool:Remove() + + -- Create the store menu + _generalStorePool = NativeUI.CreatePool() + storeMenu = NativeUI.CreateMenu("", "~s~" .. GetLabelText("SNK_ITEM"), "", "", MenuType, MenuType) + _generalStorePool:Add(storeMenu) + + _generalStorePool:ControlDisablingEnabled(true) + _generalStorePool:MouseControlsEnabled(false) + + Wait(10) + + CreateStoreMenu(storeMenu) + _generalStorePool:RefreshIndex() + storeMenu:Visible(not storeMenu:Visible()) + DoesStoreMenuExist = true + end +end) + +Citizen.CreateThread(function() + while not NetworkIsGameInProgress() and not IsPlayerPlaying(PlayerId()) do + Citizen.Wait(0) + end + + while HasAdditionalTextLoaded(CurrentSlot) and not HasThisAdditionalTextLoaded(gxt, CurrentSlot) do + Citizen.Wait(0) + CurrentSlot = CurrentSlot + 1 + end + + if not HasThisAdditionalTextLoaded(gxt, CurrentSlot) then + ClearAdditionalText(CurrentSlot, true) + RequestAdditionalText(gxt, CurrentSlot) + while not HasThisAdditionalTextLoaded(gxt, CurrentSlot) do + Citizen.Wait(0) + end + end + + Citizen.Wait(1800) +end) + +function CreateStoreMenu(menu) + inventoryItems = exports.vf_base:GetInventory() + ConvenienceStore = { + {name = "SNK_ITEM1", description = "SNK_ITEM1_D", price = 10}, + {name = "SNK_ITEM2", description = "SNK_ITEM2_D", price = 20}, + {name = "SNK_ITEM3", description = "SNK_ITEM3_D", price = 10}, + {name = "SNK_ITEM4", description = "SNK_ITEM4_D", price = 30}, + {name = "SNK_ITEM5", description = "SNK_ITEM5_D", price = 50}, + {name = "SNK_ITEM6", description = "SNK_ITEM6_D", price = 50} + } + + for k, item in pairs(ConvenienceStore) do + local locked = false + local thisItem = nil + + for i, inventory in pairs(inventoryItems) do + if item.name == inventory.item then + if inventory.total >= 9 then + locked = true + else + locked = false + end + end + end + + if not locked then + thisItem = NativeUI.CreateItem(GetLabelText(item.name), GetLabelText(item.description)) + thisItem:RightLabel("$" .. item.price) + thisItem:SetRightBadge(BadgeStyle.None) + else + thisItem = NativeUI.CreateItem(GetLabelText(item.name), GetLabelText("SNK_SOUT")) + thisItem:SetRightBadge(BadgeStyle.Lock) + + end + + thisItem.Activated = function(ParentMenu, SelectedItem) + if SelectedItem == thisItem then + if not locked then + TriggerServerEvent("vf_convenience:item-selected", item.name, item.price) + PlaySoundFrontend(-1, "PURCHASE", "HUD_LIQUOR_STORE_SOUNDSET", true) + if not IsAnySpeechPlaying(storeKeeper) then + PlayAmbientSpeech1(storeKeeper, "SHOP_SELL", "SPEECH_PARAMS_FORCE") + end + else + PlayAmbientSpeech1(storeKeeper, "SHOP_OUT_OF_STOCK", "SPEECH_PARAMS_FORCE") + end + end + end + + menu:AddItem(thisItem) + end +end + +Citizen.CreateThread(function() + while true do + Wait(6) + if DoesStoreMenuExist then + _generalStorePool:ProcessMenus() + end + end +end) \ No newline at end of file diff --git a/vf_convenience/cl_ped.lua b/vf_convenience/cl_ped.lua new file mode 100644 index 0000000..5f8e868 --- /dev/null +++ b/vf_convenience/cl_ped.lua @@ -0,0 +1,135 @@ +IsStoreKeeperAlive = false + +pos = {} + +function CreateStorePed(x, y, z, heading) + modelHash = GetHashKey("mp_m_shopkeep_01") + + if IsModelValid(modelHash) and IsModelInCdimage(modelHash) then + RequestModel(modelHash) + while not HasModelLoaded(modelHash) do + Wait(50) + end + + local ped = CreatePed(4, modelHash, x, y, z-1, heading, true, false) + while not DoesEntityExist(ped) do + Wait(10) + end + + netID = PedToNet(ped) + + if not NetworkDoesNetworkIdExist(netID) then + NetworkRegisterEntityAsNetworked(ped) + else + SetNetworkIdExistsOnAllMachines(netID, true) + end + + GiveWeaponToPed(ped, GetHashKey("weapon_pistol"), -1, false, false) + + SetEntityHeading(ped, heading) + SetPedFleeAttributes(ped, 0, 0) + SetEntityInvincible(ped, false) + TaskSetBlockingOfNonTemporaryEvents(ped, true) + + SetModelAsNoLongerNeeded(modelHash) + return ped + else + print('vf_convenience | You are loading a invalid model') + return false + end +end + +function TaskStartHoldUp(ped) + PlayAmbientSpeech1(ped, "SHOP_SCARED_START", "SPEECH_PARAMS_FORCE") + Wait(50) + + TaskGoStraightToCoord(storeKeeper, atmX, atmY, atmZ, 0.2, 4000, GetEntityHeading(register), 0.5) + Wait(300) + + local _, taskSequence = OpenSequenceTask(0) + TaskTurnPedToFaceEntity(storeKeeper, PlayerPedId(), 10000) + TaskLookAtEntity(ped, PlayerId(), -1, 0, 2) + TaskPlayAnim(ped, "mp_am_hold_up", "holdup_victim_20s", 8.0, -8.0, -1, 262192, 0, 0, 0, 0) + Wait(1000) + + storebag = GetHashKey("p_poly_bag_01_s") + RequestModel(storebag) + while not HasModelLoaded(storebag) do + Citizen.Wait(50) + end + + coords = GetEntityCoords(storeKeeper, true) + + bag = CreateObject(storebag, coords.x, coords.y, coords.z, false, true, true) + AttachEntityToEntity(bag, storeKeeper, 11816, 0.0, 0.0, 0.0, 0.0, -90.0, 180.0, false, false, false, false, 2, true) + + --AttachEntityToEntity(entity1, entity2, boneIndex, xPos, yPos, zPos, xRot, yRot, zRot, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot) + -- TaskPlayAnim(ped, "mp_am_hold_up", "handsup_base", 4.0, -4.0, -1, 49, 0, 0, 0, 0) + CloseSequenceTask(taskSequence) + TaskPerformSequence(ped, taskSequence) + + Wait(20000) + SetPlayerWantedLevel(PlayerId(), 2, false) + SetPlayerWantedLevelNow(PlayerId()) +end + +function TaskStartRobbing(ped) + animDict = "random@shop_robbery" + if not HasAnimDictLoaded(animDict) then + RequestAnimDict(animDict) + while not HasAnimDictLoaded(animDict) do + Wait(10) + end + end + + register = GetClosestObjectOfType(GetEntityCoords(ped, true), 0.75, GetHashKey("prop_till_02"), false) + if DoesEntityExist(register) then + atmX, atmY, atmZ = table.unpack(GetOffsetFromEntityInWorldCoords(register, 0.0, 0.2, 0.0)) + TaskGoStraightToCoord(playerPed, atmX, atmY, atmZ, 0.1, 4000, GetEntityHeading(register), 0.5) + print('found the cash register.') + Wait(3000) + end + + _, taskSequence = OpenSequenceTask(0) + TaskPlayAnim(ped, animDict, "robbery_intro_loop_a", 8.0, -8.0, -1, 0, 0, 0, 0, 0) + TaskPlayAnim(ped, animDict, "robbery_intro_loop_b", 8.0, -8.0, 4000, 1, 0, 0, 0, 0) + TaskPlayAnim(ped, animDict, "robbery_intro_loop_bag", 8.0, -8.0, 4000, 1, 0, 0, 0, 0) + + CloseSequenceTask(taskSequence) + TaskPerformSequence(ped, taskSequence) + RemoveAnimDict(animDict) +end + +function isNearGeneralStore() + local distance = 60.0 + local coords = GetEntityCoords(PlayerPedId(), 0) + + for k, item in pairs(locations) do + local bCoords = item["blip"] + local currentDistance = GetDistanceBetweenCoords(coords.x, coords.y, coords.z, bCoords.x, bCoords.y, bCoords.z, true) + + if currentDistance < distance then + if not DoesEntityExist(storeKeeper) then + local x, y, z, w = table.unpack(item["ped"]) + local menu = item["menu"] + + storeKeeper = CreateStorePed(x, y, z, w) + print('Created store ped ' .. storeKeeper) + MenuType = menu + Wait(10) + end + + return true + end + end +end + +function IsPlayerNearShopKeeper(ped) + local coords = GetEntityCoords(PlayerPedId(), 0) + local pcoords = GetEntityCoords(ped, 0) + local distance = GetDistanceBetweenCoords(coords.x, coords.y , coords.z, pcoords.x, pcoords.y, pcoords.z, true) + + if distance <= 2.0 then + return true + end +end \ No newline at end of file diff --git a/vf_convenience/client.lua b/vf_convenience/client.lua new file mode 100644 index 0000000..05819f2 --- /dev/null +++ b/vf_convenience/client.lua @@ -0,0 +1,209 @@ +local objects = {"p_poly_bag_01_s", "prop_till_01", "prop_till_02", "p_till_01_s"} +local modeltypes = {'prop_till_01', 'prop_till_02', 'p_till_01_s'} + +function DisplayHelpLabel(label, sublabel, time) + ClearBrief() + + BeginTextCommandDisplayHelp(label) + if sublabel then + AddTextComponentSubstringPlayerName(sublabel) + end + + if time then + displayTime = time + else + displayTime = 10000 + end + EndTextCommandDisplayHelp(0, 0, false, displayTime) +end + +Citizen.CreateThread(function() + ClearPedBloodDamage(PlayerPedId()) + ClearPlayerWantedLevel(PlayerId()) + + for k,v in pairs(objects) do + local object = GetHashKey(v) + RequestModel(object) + while not HasModelLoaded(object) do + Wait(10) + end + end + + RequestAnimDict("mp_am_hold_up") + while not HasAnimDictLoaded("mp_am_hold_up") do + Wait(10) + end + + for _, item in pairs(locations) do + local bCoords = item["blip"] + local currentBlip = AddBlipForCoord(bCoords.x, bCoords.y, bCoords.z) + + SetBlipSprite(currentBlip, 52) + SetBlipScale(currentBlip, 0.7) + SetBlipAsShortRange(currentBlip, true) + SetBlipNameFromTextFile(currentBlip, "collision_78czu4") + end + + while true do + Wait(700) + IsNearStore = isNearGeneralStore() + if IsNearStore then + IsStoreKeeperAlive = DoesEntityExist(storeKeeper) + end + PlayerPed = PlayerPedId() + PedCoords = GetEntityCoords(PlayerPed, true) + + if GetClockHours() == 07 then + speech = "SHOP_GREET_START" + elseif GetClockHours() >= 09 and GetClockHours() <= 22 then + speech = "SHOP_GREET" + else + speech = "SHOP_GREET_END" + end + end +end) + +Citizen.CreateThread(function() + DestroyAllCams(0) + Wait(5000) + + while true do + Wait(10) + if IsNearStore then + if IsStoreKeeperAlive then + if IsPlayerNearShopKeeper(storeKeeper) and not IsPedDeadOrDying(storeKeeper) then + if IsPedInMeleeCombat(PlayerPed) then + if not IsAnySpeechPlaying(storeKeeper) then + PlayAmbientSpeech1(storeKeeper, "SHOP_NO_FIGHTING", "SPEECH_PARAMS_FORCE") + Wait(5000) + end + end + + if IsPedShooting(PlayerPed) then + if not IsAnySpeechPlaying(storeKeeper) then + PlayAmbientSpeech1(storeKeeper, "CALL_COPS_THREAT", "SPEECH_PARAMS_FORCE") + Wait(5000) + end + end + + if not DoesStoreMenuExist then + if not IsPlayerWantedLevelGreater(PlayerId(), 0) then + NoCops = false + if not GreetPlayer then + GreetPlayer = true + end + + if not IsHelpMessageBeingDisplayed() then + DisplayHelpLabel("SHR_MENU", 1) + end + + if IsControlJustPressed(0, 51) then + if not DoesCamExist(camera) then + camera = CreateCameraWithParams(26379945, 0.0, 0.0, 0.0, 0.0, .0, 0.0, 50.0, 0, 2) + while not DoesCamExist(camera) do + Wait(50) + end + + AttachCamToEntity(camera, PlayerPedId(), 1.8146, -3.0635, 0.680+0.7, 1) + PointCamAtEntity(camera, PlayerPedId(), 0.3874, -0.0957, 0.3008+0.2, 1) + SetCamFov(camera, 20.0) + ShakeCam(camera, "HAND_SHAKE", 0.1) + SetCamActive(camera, true) + RenderScriptCams(true, false, 3000, 1, 0, 0) + end + + TaskTurnPedToFaceEntity(storeKeeper, PlayerPedId(), 10000) + TaskTurnPedToFaceEntity(PlayerPedId(), storeKeeper, 10000) + -- Create the store menu + _generalStorePool = NativeUI.CreatePool() + storeMenu = NativeUI.CreateMenu("", "~s~" .. GetLabelText("SNK_ITEM"), "", "", MenuType, MenuType) + _generalStorePool:Add(storeMenu) + + _generalStorePool:ControlDisablingEnabled(true) + _generalStorePool:MouseControlsEnabled(false) + + CreateStoreMenu(storeMenu) + _generalStorePool:RefreshIndex() + DoesStoreMenuExist = true + PlayAmbientSpeech1(storeKeeper, "SHOP_GREET_SPECIAL", "SPEECH_PARAMS_FORCE") + storeMenu:Visible(not storeMenu:Visible()) + end + else + NoCops = true + end + end + + if storeMenu then + if not storeMenu:Visible() then + _generalStorePool:Clear() + _generalStorePool:Remove() + + DestroyAllCams(0) + RenderScriptCams(false, false, 3000, 0, 0) + + DoesStoreMenuExist = false + else + DisableControlAction(0, 0, true) + DisableControlAction(0, 22, true) + DisableControlAction(0, 30, true) + + DisableControlAction(0, 31, true) + DisableControlAction(0, 32, true) + DisableControlAction(0, 33, true) + + DisableControlAction(0, 34, true) + DisableControlAction(0, 35, true) + DisableControlAction(0, 36, true) + + DisableControlAction(0, 37, true) + + DisableControlAction(0, 44, true) + DisableControlAction(0, 47, true) + DisableControlAction(0, 55, true) + end + end + end + end + else + if IsStoreKeeperAlive then + DeleteEntity(storeKeeper) + IsStoreKeeperAlive = false + end + end + end +end) + +Citizen.CreateThread(function() + while true do + Wait(10) + if IsStoreKeeperAlive then + if GreetPlayer and not NoCops then + if not GreetingPlayer then + if GetClockHours() == 07 then + speech = "SHOP_GREET_START" + elseif GetClockHours() >= 09 and GetClockHours() <= 22 then + speech = "SHOP_GREET" + else + speech = "SHOP_GREET_END" + end + + PlayAmbientSpeech1(storeKeeper, speech, "SPEECH_PARAMS_FORCE") + GreetingPlayer = true + end + end + + if NoCops then + if GetClockHours() == 07 then + speech = "SHOP_NO_COPS_START" + elseif GetClockHours() >= 09 and GetClockHours() <= 21 then + speech = "SHOP_NO_ENTRY" + else + speech = "SHOP_NO_COPS_END" + end + else + speech "" + end + end + + end +end) \ No newline at end of file diff --git a/vf_convenience/config.lua b/vf_convenience/config.lua new file mode 100644 index 0000000..94bc8c4 --- /dev/null +++ b/vf_convenience/config.lua @@ -0,0 +1,87 @@ +-- Configure the coordinates for each shop +locations = { + ["1"] = { + ["blip"] = vector3(-69.3353042602539, -1776.7222900390625, 28.543842315673828), + ["menu"] = "shopui_title_gasstation", + ["ped"] = vector4(-46.313, -1757.504, 29.421, 46.395), + ["door"] = vector3(-53.470420837402344, -1756.8638916015625, 29.43963623046875), + }, + ["2"] = { + ["blip"] = vector3(26.017168045043945, -1353.472900390625, 29.33883285522461), + ["menu"] = "shopui_title_conveniencestore", + ["ped"] = vector4(24.376, -1345.558, 29.421, 267.940), + ["door"] = vector3(29.204355239868164, 1350.133056640625, 29.33132553100586), + }, + ["3"] = { + ["blip"] = vector3(376.7219848632813, 320.2231750488281, 103.417724609375), + ["menu"] = "shopui_title_conveniencestore", + ["ped"] = vector4(373.015, 328.332, 103.566, 257.309), + ["door"] = vector3(376.5338745117187, 323.00653076171875, 103.57288360595705), + }, + ["4"] = { + ["blip"] = vector3(1145.4398193359375, -980.5490112304688, 46.2032585144043), + ["menu"] = "shopui_title_liquorstore2", + ["ped"] = vector4(1134.182, -982.477, 46.416, 275.432), + ["door"] = vector3(1141.9202880859375, -980.8821411132812, 46.19901657104492), + }, + ["5"] = { + ["blip"] = vector3(2685.930419921875, 3284.34033203125, 55.24053192138672), + ["menu"] = "shopui_title_conveniencestore", + ["ped"] = vector4(2676.389, 3280.362, 55.241, 332.305), + ["door"] = vector3(2685.930419921875, 3284.34033203125, 55.24053192138672), + }, + ["6"] = { + ["blip"] = vector3(1966.7060546875, 3737.554931640625, 32.192169189453125), + ["menu"] = "shopui_title_conveniencestore", + ["ped"] = vector4(1958.960, 3741.979, 32.344, 303.196), + ["door"] = vector3(1965.3636474609375, 3740.43701171875, 32.33184814453125), + }, + ["7"] = { + ["blip"] = vector3(-2977.73388671875, 391.07135009765625, 15.02270793914795), + ["menu"] = "shopui_title_liquorstore2", + ["ped"] = vector4(-2966.391, 391.324, 15.043, 88.867), + ["door"] = vector3(-2974.0458984375, 390.7870178222656, 15.034119606018066), + }, + ["8"] = { + ["blip"] = vector3(1160.7017822265625, -331.40130615234375, 68.89907836914062), + ["menu"] = "shopui_title_gasstation", + ["ped"] = vector4(1164.565, -322.121, 69.205, 100.492), + ["door"] = vector3(1159.8760986328125, -326.99432373046875, 69.21745300292969), + }, + ["9"] = { + ["blip"] = vector3(-1493.5517578125, -385.7423400878906, 39.890830993652344), + ["menu"] = "shopui_title_liquorstore2", + ["ped"] = vector4(-1486.530, -377.768, 40.163, 147.669), + ["door"] = vector3(-1491.3759765625, -383.4170227050781, 40.165184020996094), + }, + ["10"] = { + ["blip"] = vector3(-1228.534423828125, -899.4459838867188, 12.280976295471191), + ["menu"] = "shopui_title_liquorstore2", + ["ped"] = vector4(-1221.568, -908.121, 12.326, 31.739), + ["door"] = vector3(-1226.547607421875, -902.0326538085938, 12.28719425201416), + }, + ["11"] = { + ["blip"] = vector3(-708.9332885742188, -920.1010131835938, 19.013906478881836), + ["menu"] = "shopui_title_liquorstore2", + ["ped"] = vector4(-706.153, -913.464, 19.216, 82.056), + ["door"] = vector3(-712.0322265625, -916.9070434570312, 19.214242935180664), + }, + ["12"] = { + ["blip"] = vector3(-1812.6617431640625, 776.0027465820312, 136.80467224121094), + ["menu"] = "shopui_title_gasstation", + ["ped"] = vector4(-1820.230, 794.369, 138.089, 130.327), + ["door"] = vector3(-1822.2608642578125, 787.783203125, 138.18797302246094), + }, + ["13"] = { + ["blip"] = vector3(2566.368408203125, 385.0050354003906, 108.6210479736328), + ["menu"] = "shopui_title_conveniencestore", + ["ped"] = vector4(2555.474, 380.909, 108.623, 355.737), + ["door"] = vector3(2559.598388671875, 385.2843933105469, 108.6210479736328), + }, + ["14"] = { + ["blip"] = vector3(1725.73388671875, 6399.884765625, 34.44724655151367), + ["menu"] = "shopui_title_conveniencestore", + ["ped"] = vector4(1728.614, 6416.729, 35.037, 247.369), + ["door"] = vector3(1731.052734375, 6411.2568359375, 35.00066375732422), + }, +} \ No newline at end of file diff --git a/vf_convenience/server.lua b/vf_convenience/server.lua new file mode 100644 index 0000000..5853e79 --- /dev/null +++ b/vf_convenience/server.lua @@ -0,0 +1,22 @@ +RegisterServerEvent('vf_convenience:item-selected') +AddEventHandler('vf_convenience:item-selected', function(item, price) + local src = source + TriggerEvent('vf_base:FindPlayer', src, function(user) + local purchased = false + if user.cash >= tonumber(price) then + TriggerEvent('vf_base:ClearCash', src, price) + purchased = true + elseif user.bank >= tonumber(price) then + TriggerEvent('vf_base:ClearBank', src, price) + purchased = true + else + TriggerClientEvent('vf_convenience:nocash', src) + purchased = false + end + + if purchased then + exports.vf_base:AddInventoryItem(src, item) + TriggerClientEvent("vf_convenience:update", src) + end + end) +end) \ No newline at end of file From d2916648f66010b13783be1268340bd26f78e8e6 Mon Sep 17 00:00:00 2001 From: ghermans Date: Wed, 2 Oct 2019 00:29:24 +0200 Subject: [PATCH 12/15] Added store: smoke on the water --- venomous.cfg | 3 +- vf_sotw/__resource.lua | 11 ++++ vf_sotw/client.lua | 119 +++++++++++++++++++++++++++++++++++++++++ vf_sotw/config.lua | 17 ++++++ vf_sotw/server.lua | 13 +++++ 5 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 vf_sotw/__resource.lua create mode 100644 vf_sotw/client.lua create mode 100644 vf_sotw/config.lua create mode 100644 vf_sotw/server.lua diff --git a/venomous.cfg b/venomous.cfg index a9fd0c1..b39dee0 100644 --- a/venomous.cfg +++ b/venomous.cfg @@ -22,4 +22,5 @@ start vf_cinema start vf_loading start vf_convenience start vf_interaction -start vf_vending \ No newline at end of file +start vf_vending +start vf_sotw \ No newline at end of file diff --git a/vf_sotw/__resource.lua b/vf_sotw/__resource.lua new file mode 100644 index 0000000..2b7975d --- /dev/null +++ b/vf_sotw/__resource.lua @@ -0,0 +1,11 @@ +resource_manifest_version '05cfa83c-a124-4cfa-a768-c24a5811d8f9' + +dependencies {'NativeUI', 'vf_base'} + +client_scripts { + '@NativeUI/NativeUI.lua', + 'client.lua' +} + +server_script "server.lua" + diff --git a/vf_sotw/client.lua b/vf_sotw/client.lua new file mode 100644 index 0000000..0839caa --- /dev/null +++ b/vf_sotw/client.lua @@ -0,0 +1,119 @@ +-- Configure the weed products +weedItems = { + {text="Amnesia Haze", price=12}, + {text="Black Domina", price=15}, + {text="Blue Cheese", price=15}, + {text="Bubblegum", price=9}, + {text="Cheeze Haze", price=9}, + {text="Dr.Grinspoon", price=18}, + {text="G13 Haze", price=15}, + {text="Liberty Haze", price=17}, + {text="Mexican Haze", price=12}, + {text="N.L.X", price=6}, + {text="Silver Haze", price=12}, + {text="Smoke mix", price=5}, + {text="Utopia Kush", price=17}, + {text="Vanilla Kush", price=15}, + {text="White Widow", price=9} +} + +_weedPool = MenuPool.New() +weedMenu = UIMenu.New(GetLabelText("PN_WEED"), '~b~' .. GetLabelText("SHOP_L_ITEMS")) +_weedPool:Add(weedMenu) + +local function DisplayHelpTextTimed(text, time) + BeginTextCommandDisplayHelp("STRING") + AddTextComponentSubstringPlayerName(text) + EndTextCommandDisplayHelp(0, 0, 1, tonumber(time)) +end + +function AddWeedMenu(menu) + for k,v in pairs(weedItems) do + local item = UIMenuItem.New(v.text, '') + item:RightLabel(GetLabelText('BB_CASHAMT') .. ' ' .. v.price) + menu:AddItem(item) + + item.Activated = function(ParentMenu, SelectedItem) + if SelectedItem == item then + TriggerServerEvent('sotw:purchase', v.price) + menu:Visible(not menu:Visible()) + end + end + end +end + +Citizen.CreateThread(function() + AddWeedMenu(weedMenu) + _weedPool:MouseControlsEnabled(false) + _weedPool:RefreshIndex() + + storeBlip = AddBlipForCoord(-1172.406, -1572.292, 4.664) + SetBlipSprite(storeBlip, 140) + SetBlipColour(storeBlip, 15) + SetBlipAsShortRange(storeBlip, true) + SetBlipNameFromTextFile(storeBlip, "EMSTR_437") + + SetBlipScale(storeBlip, 0.8) + + while true do + _weedPool:ProcessMenus() + x, y, z = table.unpack(GetEntityCoords(PlayerPedId(), true)) + DrawMarker(1, -1172.406, -1572.292, 4.664-1.0001, 0, 0, 0, 0, 0, 0, 1.0, 1.0, 1.0, 107, 218, 16, 155, 0, 0, 2, 0, 0, 0, 0) + + if GetDistanceBetweenCoords(x, y, z, -1172.406, -1572.292, 4.664, true) < 0.6 then + DisplayHelpTextTimed(GetLabelText("SHR_MENU"), 8000) + if IsControlJustPressed(1, 51) then + weedMenu:Visible(not weedMenu:Visible()) + end + end + + Wait(1) + end +end) + + +Citizen.CreateThread(function() + while true do + Wait(1) + if toxicated then + Wait(120000) + if HasClipSetLoaded("MOVE_M@DRUNK@SLIGHTLYDRUNK") then + ClearTimecycleModifier() + SetPedMotionBlur(PlayerPedId(), false) + + ResetPedMovementClipset(PlayerPedId(), 0.0) + ResetScenarioTypesEnabled() + StopGameplayCamShaking(true) + StopScreenEffect("DrugsMichaelAliensFightIn") + RemoveClipSet("MOVE_M@DRUNK@SLIGHTLYDRUNK") + end + toxicated = false + end + end +end) + +RegisterNetEvent("sotw:buyweed") +AddEventHandler("sotw:buyweed", function() + RequestClipSet("MOVE_M@DRUNK@SLIGHTLYDRUNK") + while not HasClipSetLoaded("MOVE_M@DRUNK@SLIGHTLYDRUNK") do + Wait(0) + end + + TaskStartScenarioInPlace(PlayerPedId(), "WORLD_HUMAN_DRUG_DEALER", 0, -1) + buyweed = true + + while buyweed do + Wait(10000) + ClearPedTasks(PlayerPedId()) + FreezeEntityPosition(PlayerPedId(), false) + buyweed = false + end + + ShakeGameplayCam("FAMILY5_DRUG_TRIP_SHAKE", 0.5) + SetPedMovementClipset(PlayerPedId(), "MOVE_M@DRUNK@SLIGHTLYDRUNK", 1048576000) + SetPedMotionBlur(PlayerPedId(), true) + StartScreenEffect("DrugsMichaelAliensFightIn", -1, false) + + SetTimecycleModifier("Drug_deadman_blend") + toxicated = true +end) \ No newline at end of file diff --git a/vf_sotw/config.lua b/vf_sotw/config.lua new file mode 100644 index 0000000..0b5adff --- /dev/null +++ b/vf_sotw/config.lua @@ -0,0 +1,17 @@ +-- Configure the weed products +weedItems = { + {text="Amnesia Haze", price=12}, + {text="Blue Cheese", price=15}, + {text="Bubblegum", price=9}, + {text="Cheeze Haze", price=9}, + {text="Dr.Grinspoon", price=18}, + {text="G13 Haze", price=15}, + {text="Liberty Haze", price=17}, + {text="Mexican Haze", price=12}, + {text="N.L.X", price=6}, + {text="Silver", price=12}, + {text="Smoke mix", price=5}, + {text="Utopia Kush", price=17}, + {text="Vanilla Kush", price=15}, + {text="White Widow", price=9}, +} \ No newline at end of file diff --git a/vf_sotw/server.lua b/vf_sotw/server.lua new file mode 100644 index 0000000..f78d606 --- /dev/null +++ b/vf_sotw/server.lua @@ -0,0 +1,13 @@ +RegisterServerEvent('sotw:purchase') +AddEventHandler('sotw:purchase', function(price) + local src = source + TriggerEvent('vf_base:FindPlayer', src, function(user) + if user.cash >= tonumber(price) then + TriggerEvent('vf_base:ClearCash', src, tonumber(price)) + TriggerClientEvent('sotw:buyweed', src, model, name) + elseif user.bank >= tonumber(price) then + TriggerEvent('vf_base:ClearBank', src, tonumber(price)) + TriggerClientEvent('sotw:buyweed', src, model, name) + end + end) +end) \ No newline at end of file From 91f232581d3dc728e13670060592d47b3f49cdde Mon Sep 17 00:00:00 2001 From: Glenn Hermans Date: Wed, 2 Oct 2019 14:14:36 +0200 Subject: [PATCH 13/15] Update CHANGELOG.md --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc41356..29e90d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,17 @@ # Changelog +## 1.1.2 + +### Added +- Added Smoke on the Water, a pharmacy that sells prescription marijuana for "medical" purposes. +- Added convenience stores where players can purchase items. + +## Fixed +vf_phone: Display current time instead of network time +vf_baseapps: Change new text message text +vf_baseapps: Show no players item in playerlist +vf_phone: Change no items screen deletion logic +vf_phone: Update native names +vf_phone: Control & Pause Menu related improvements ## 1.1.1 From d15956a50f28f629724fc477eff8119272838daf Mon Sep 17 00:00:00 2001 From: Glenn Hermans Date: Thu, 3 Oct 2019 22:00:44 +0200 Subject: [PATCH 14/15] fixed typo --- vf_convenience/client.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vf_convenience/client.lua b/vf_convenience/client.lua index 05819f2..74a761b 100644 --- a/vf_convenience/client.lua +++ b/vf_convenience/client.lua @@ -201,9 +201,9 @@ Citizen.CreateThread(function() speech = "SHOP_NO_COPS_END" end else - speech "" + speech = "" end end end -end) \ No newline at end of file +end) From 4b3d0c70776cc7512eab71844ee491eb9d0a96f4 Mon Sep 17 00:00:00 2001 From: Glenn Hermans Date: Sat, 5 Oct 2019 02:42:34 +0200 Subject: [PATCH 15/15] Removed debug line --- vf_base/client/spawn.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vf_base/client/spawn.lua b/vf_base/client/spawn.lua index 626dabb..14c87e8 100644 --- a/vf_base/client/spawn.lua +++ b/vf_base/client/spawn.lua @@ -17,8 +17,6 @@ Citizen.CreateThread(function() Wait(800) end - print('Ready to start the intro') - if not IsPlayerSwitchInProgress() then SetEntityVisible(PlayerPedId(), false, 0) SwitchOutPlayer(PlayerPedId(), 32, 1) @@ -129,4 +127,4 @@ Citizen.CreateThread(function() end end end -end) \ No newline at end of file +end)