diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a1e870f..03ac6f1 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -5,7 +5,7 @@ Guidelines for bug reports: - Use the github issue search - check if the issue is already reported. -- Check if the issue has been fixed - try to reproduce it using the lastest master or development branch in the repo. +- Check if the issue has been fixed - try to reproduce it using the lastest version. - isolate the problem - So the community doesn't have hard times finding the possible bug. ## Labels diff --git a/CHANGELOG.md b/CHANGELOG.md index 68f88b5..1c729fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ # Changelog All notable changes to this project will be documented in this file. +## v1.3.1 +This release contains some improvements to the resource and as a Christmas gift we added the vehicle shop with CouchDB and MySQL support. + +- Added GTA:O chat as a option that you can enable or disable in the config file. Keep in mind that this chat does not support commands. +- Premium Deluxe Motorsport where players can buy multiple vehicles. +- Added Lesters office. +- Added Humane Labs and Research blip. +- Fixed Database table creation for MariaDB. +- Fixed Office banner and ped skin. +- Removed wanted and voice head display, we will add this feature soon in Cops-Fivem. + ## v1.3 - Added mysql-async support. - Removed the stats preview since this will get replaced in the future. diff --git a/README.md b/README.md index 6c9f8f8..75fa12e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # fs_freemode -[![Version](https://img.shields.io/badge/Version-1.3-brightgreen.svg)]() +[![Version](https://img.shields.io/badge/Version-v1.3.1-brightgreen.svg)]() Discord Status ## Requirements diff --git a/__resource.lua b/__resource.lua index f20bf3e..dddeb2f 100644 --- a/__resource.lua +++ b/__resource.lua @@ -19,10 +19,12 @@ client_scripts { 'libs/events.lua', 'libs/scoreboard.lua', 'libs/warmenu.lua', + 'config/vehicles.lua', 'config.lua', 'client.lua', 'int/comedy.lua', 'int/office.lua', + 'int/vehicles.lua', 'int/weapons.lua', 'int/warehouses.lua', 'ext/locations.lua', @@ -36,5 +38,4 @@ server_scripts { 'database.lua', 'libs/db.lua', 'server.lua', - 'int/weapons_s.lua' } diff --git a/client.lua b/client.lua index 27515f3..daeec00 100644 --- a/client.lua +++ b/client.lua @@ -6,23 +6,22 @@ AddEventHandler('onClientMapStart', function() end) AddEventHandler("playerSpawned", function(spawn) - local playerID = PlayerId() - local player = GetPlayerPed(-1) - local playerName = GetPlayerName(playerID) - - Citizen.InvokeNative(GetHashKey("ADD_TEXT_ENTRY"), 'FE_THDR_GTAO', Setup.ServerName) - if Setup.DisplayWelcomeNotification then - TriggerEvent("fs_freemode:notify", "CHAR_SOCIAL_CLUB", 4, 2, Setup.ServerName, false, i18n.translate("welcome_message") .. playerName) - end - - SetAudioFlag("LoadMPData", true) - SetAudioFlag("WantedMusicDisabled", Setup.WantedMusicDisabled) + local player = GetPlayerPed(-1) + local playerID = PlayerId() + local playerName = GetPlayerName(playerID) + + AddTextEntry('FE_THDR_GTAO', Setup.ServerName) + if Setup.DisplayWelcomeNotification then + TriggerEvent("fs_freemode:notify", "CHAR_SOCIAL_CLUB", 4, 2, Setup.ServerName, false, i18n.translate("welcome_message") .. playerName) + end - GiveWeaponToPed(player, GetHashKey("WEAPON_PISTOL"), 100, false, true) - GiveWeaponToPed(player, GetHashKey("WEAPON_KNIFE"), true, true) - spawned = true - TriggerServerEvent("fs_freemode:playerSpawned") - + if Setup.SetTextChatEnabled then + SetTextChatEnabled(true) + else + SetTextChatEnabled(false) + end + + TriggerServerEvent("fs_freemode:playerSpawned") end) Citizen.CreateThread(function() @@ -37,33 +36,3 @@ Citizen.CreateThread(function() end end end) - -Citizen.CreateThread(function() - while true do - Citizen.Wait(1) - -- Check if the player is wanted - if Setup.WantedHeadDisplay == true then - if GetPlayerWantedLevel(PlayerId()) ~= 0 then - gamerTagId = CreateMpGamerTag(GetPlayerPed(-1), "", false, false, "", 0) - SetMpGamerTagWantedLevel(gamerTagId, PlayerId()) - SetMpGamerTagVisibility(gamerTagId, 7, true) - SetMpGamerTagAlpha(gamerTagId, 7, 240) - else - SetMpGamerTagVisibility(gamerTagId, 7, false) - end - end - - -- Check if the player is talking - if Setup.VoiceHeadDisplay == true then - local pid = GetPlayerServerId(PlayerId()) - if NetworkIsPlayerTalking(pid) then - gamerTagId = CreateMpGamerTag(GetPlayerPed(-1), "", false, false, "", 0) - SetMpGamerTagWantedLevel(gamerTagId, PlayerId()) - SetMpGamerTagVisibility(gamerTagId, 4, true) - SetMpGamerTagAlpha(gamerTagId, 4, 240) - else - SetMpGamerTagVisibility(gamerTagId, 4, false) - end - end - end -end) diff --git a/config.lua b/config.lua index ed2ae47..22fb7d7 100644 --- a/config.lua +++ b/config.lua @@ -3,15 +3,13 @@ Setup = {} Setup.ServerName = "My Server" Setup.DisplayWelcomeNotification = true Setup.blips = true -Setup.Money = 500000 +Setup.Money = 800000 Setup.NativeMoney = false Setup.Currency = "$" -Setup.WantedMusicDisabled = true -Setup.WantedHeadDisplay = true -Setup.VoiceHeadDisplay = true Setup.SpawnPickups = true Setup.pvp = true Setup.debug = false +Setup.SetTextChatEnabled = false PickupItems = { "PICKUP_ARMOUR_STANDARD", diff --git a/config/vehicles.lua b/config/vehicles.lua new file mode 100644 index 0000000..ef4d789 --- /dev/null +++ b/config/vehicles.lua @@ -0,0 +1,189 @@ +-- No need to change the CarGroups table. +carGroups = { + {name="Compacts", type="compacts"}, + {name="Coupes", type="coupes"}, + {name="Muscle", type="muscle"}, + {name="Off-Road", type="offroad"}, + {name="Sedans", type="sedans"}, + {name="Sports", type="sports"}, + {name="Sport Classics", type="sportclassics"}, + {name="Super", type="super"}, + {name="SUVs", type="suvs"}, + {name="Vans", type="vans"} +} + +-- Change vehicle prices below +compacts = { + {name= "Blista", costs = 15000, model = "blista"}, + {name= "Brioso R/A", costs = 155000, model = "brioso"}, + {name= "Dilettante", costs = 25000, model = "Dilettante"}, + {name= "Issi", costs = 18000, model = "issi2"}, + {name= "Panto", costs = 85000, model = "panto"}, + {name= "Prairie", costs = 30000, model = "prairie"}, + {name= "Rhapsody", costs = 120000, model = "rhapsody"} +} + +coupes = { + {name= "Cognoscenti Cabrio", costs = 180000, model = "cogcabrio"}, + {name= "Exemplar", costs = 200000, model = "exemplar"}, + {name= "F620", costs = 80000, model= "f620"}, + {name= "Felon", costs = 90000, model= "felon"}, + {name= "Felon GT", costs = 95000, model= "felon2"}, + {name= "Jackal", costs = 60000, model= "jackal"}, + {name= "Oracle", costs = 80000, model= "oracle"}, + {name= "Oracle XS", costs = 82000, model= "oracle2"}, + {name= "Sentinel", costs = 90000, model= "sentinel"}, + {name= "Sentinel XS", costs = 60000, model= "sentinel2"}, + {name= "Windsor", costs = 800000, model= "windsor"}, + {name= "Windsor Drop", costs = 850000, model= "windsor2"}, + {name= "Zion", costs = 60000, model = "zion"}, + {name= "Zion Cabrio", costs = 65000, model = "zion2"} +} + +sedans = { + {name = "Asea", costs = 1000000, model = "asea"}, + {name = "Asterope", costs = 1000000, model = "asterope"}, + {name = "Cognoscenti", costs = 1000000, model = "cognoscenti"}, + {name = "Cognoscenti(Armored)", costs = 1000000, model = "cognoscenti2"}, + {name = "Cognoscenti 55", costs = 1000000, model = "cognoscenti3"}, + {name = "Cognoscenti 55(Armored", costs = 1500000, model = "ZENTORNO"}, + {name = "Fugitive", costs = 24000, model = "fugitive"}, + {name = "Glendale", costs = 200000, model = "glendale"}, + {name = "Ingot", costs = 9000, model = "ingot"}, + {name = "Intruder", costs = 16000, model = "intruder"}, + {name = "Premier", costs = 10000, model = "premier"}, + {name = "Primo", costs = 9000, model = "primo"}, + {name = "Primo Custom", costs = 9500, model = "primo2"}, + {name = "Regina", costs = 8000, model = "regina"}, + {name = "Schafter", costs = 65000, model = "schafter2"}, + {name = "Stanier", costs = 10000, model = "stanier"}, + {name = "Stratum", costs = 10000, model = "stratum"}, + {name = "Stretch", costs = 30000, model = "stretch"}, + {name = "Super Diamond", costs = 250000, model = "superd"}, + {name = "Surge", costs = 38000, model = "surge"}, + {name = "Tailgater", costs = 55000, model = "tailgater"}, + {name = "Warrener", costs = 120000, model = "warrener"}, + {name = "Washington", costs = 15000, model = "washington"} +} + +sports = { + {name= "9F", costs = 120000, model = "ninef"}, + {name= "9F Cabrio", costs = 130000, model = "ninef2"}, + {name= "Alpha", costs = 150000, model = "alpha"}, + {name= "Banshee", costs = 105000, model = "banshee"}, + {name= "Bestia GTS", costs = 610000, model = "bestiagts"}, + {name= "Blista Compact", costs = 42000, model = "blista"}, + {name= "Buffalo", costs = 35000, model = "buffalo"}, + {name= "Buffalo S", costs = 96000, model = "buffalo2"}, + {name= "Carbonizzare", costs = 195000, model = "carbonizzare"}, + {name= "Comet", costs = 100000, model = "comet2"}, + {name= "Comet Retro Custom", costs = 100000, model = "comet2"}, + {name= "Coquette", costs = 138000, model = "coquette"}, + {name= "Drift Tampa", costs = 995000, model = "tampa2"}, + {name= "Feltzer", costs = 130000, model = "feltzer2"}, + {name= "Furore GT", costs = 448000, model = "furoregt"}, + {name= "Fusiladzae", costs = 36000, model = "fusilade"}, + {name= "Jester", costs = 240000, model = "jester"}, + {name= "Jester(Racecar)", costs = 350000, model = "jester2"}, + {name= "Kuruma", costs = 95000, model = "kuruma"}, + {name= "Lynx", costs = 1735000, model = "lynx"}, + {name= "Massacro", costs = 275000, model = "massacro"}, + {name= "Massacro(Racecar)", costs = 385000, model = "massacro2"}, + {name= "Omnis", costs = 701000, model = "omnis"}, + {name= "Ruiner 2000", costs=5745600, model= "ruiner2"}, + {name= "Penumbra", costs = 24000, model = "penumbra"}, + {name= "Rapid GT", costs = 140000, model = "rapidgt"}, + {name= "Rapid GT Convertible", costs = 150000, model = "rapidgt2"}, + {name= "Schafter V12", costs = 140000, model = "schafter3"}, + {name= "Sultan", costs = 12000, model = "sultan"}, + {name= "Surano", costs = 110000, model = "surano"}, + {name= "Tropos", costs = 816000, model = "tropos"}, + {name= "Verkierer", costs = 695000, model = "verlierer2"} +} + +sportclassics = { + {name = "Casco", costs = 680000, model = "casco"}, + {name = "Coquette Classic", costs = 665000, model = "coquette2"}, + {name = "JB 700", costs = 350000, model = "jb700"}, + {name = "Pigalle", costs = 400000, model = "pigalle"}, + {name = "Stinger", costs = 850000, model = "stinger"}, + {name = "Stinger GT", costs = 875000, model = "stingergt"}, + {name = "Stirling GT", costs = 975000, model = "feltzer3"}, + {name = "Z-Type", costs = 950000, model = "ztype"} +} + +super = { + {name = "Adder", costs = 1000000, model = "adder"}, + {name = "Banshee 900R", costs = 565000, model = "banshee2"}, + {name = "Bullet", costs = 155000, model = "bullet"}, + {name = "Cheetah", costs = 650000, model = "cheetah"}, + {name = "Entity XF", costs = 795000, model = "entityxf"}, + {name = "ETR1", costs = 199500, model = "sheava"}, + {name = "FMJ", costs = 1750000, model = "fmj"}, + {name = "Infernus", costs = 440000, model = "infernus"}, + {name = "Osiris", costs = 1950000, model = "osiris"}, + {name = "RE-7B", costs = 2475000, model = "le7b"}, + {name = "Reaper", costs = 1595000, model = "reaper"}, + {name = "Sultan RS", costs = 795000, model = "sultanrs"}, + {name = "T20", costs = 2200000, model = "t20"}, + {name = "Turismo R", costs = 500000, model = "turismor"}, + {name = "Tyrus", costs = 2550000, model = "tyrus"}, + {name = "Vacca", costs = 240000, model = "vacca"}, + {name = "Voltic", costs = 150000, model = "voltic"}, + {name = "X80 Proto", costs = 2700000, model = "prototipo"}, + {name = "Zentorno", costs = 725000, model = "zentorno"} +} + +muscle = { + {name = "Blade", costs = 160000, model = "blade"}, + {name = "Buccaneer", costs = 29000, model = "buccaneer"}, + {name = "Chino", costs = 225000, model = "chino"}, + {name = "Coquette BlackFin", costs = 695000, model = "coquette3"}, + {name = "Dominator", costs = 35000, model = "dominator"}, + {name = "Dukes", costs = 62000, model = "dukes"}, + {name = "Gauntlet", costs = 32000, model = "gauntlet"}, + {name = "Hotknife", costs = 90000, model = "hotknife"}, + {name = "Faction", costs = 36000, model = "faction"}, + {name = "Nightshade", costs = 585000, model = "nightshade"}, + {name = "Picador", costs = 9000, model = "picador"}, + {name = "Sabre Turbo", costs = 15000, model = "sabregt"}, + {name = "Tampa", costs = 375000, model = "tampa"}, + {name = "Virgo", costs = 195000, model = "virgo"}, + {name = "Vigero", costs = 21000, model = "vigero"}, + } + +offroad = { + {name = "Bifta", costs = 75000, model = "bifta"}, + {name = "Blazer", costs = 8000, model = "blazer"}, + {name = "Brawler", costs = 715000, model = "brawler"}, + {name = "Bubsta 6x6", costs = 249000, model = "dubsta3"}, + {name = "Dune Buggy", costs = 20000, model = "dune"}, + {name = "Rebel", costs = 22000, model = "rebel2"}, + {name = "Sandking", costs = 38000, model = "sandking"}, + {name = "The Liberator", costs = 550000, model = "monster"}, + {name = "Trophy Truck", costs = 550000, model = "trophytruck"}, +} + +suvs = { + {name = "Baller", costs = 90000, model = "baller"}, + {name = "Cavalcade", costs = 60000, model = "cavalcade"}, + {name = "Grabger", costs = 35000, model = "granger"}, + {name = "Huntley S", costs = 195000, model = "huntley"}, + {name = "Landstalker", costs = 58000, model = "landstalker"}, + {name = "Radius", costs = 32000, model = "radi"}, + {name = "Rocoto", costs = 85000, model = "rocoto"}, + {name = "Seminole", costs = 30000, model = "seminole"}, + {name = "XLS", costs = 253000, model = "xls"} +} + +vans = { + {name = "Bison", costs = 30000, model = "bison"}, + {name = "Bobcat XL", costs = 23000, model = "bobcatxl"}, + {name = "Gang Burrito", costs = 65000, model = "gburrito"}, + {name = "Journey", costs = 15000, model = "journey"}, + {name = "Minivan", costs = 30000, model = "minivan"}, + {name = "Paradise", costs = 25000, model = "paradise"}, + {name = "Rumpo", costs = 13000, model = "rumpo"}, + {name = "Surfer", costs = 11000, model = "surfer"}, + {name = "Youga", costs = 16000, model = "youga"} +} \ No newline at end of file diff --git a/database.lua b/database.lua index f39af85..11a1a5b 100644 --- a/database.lua +++ b/database.lua @@ -1,5 +1,7 @@ +-- no need to change this, use convars instead +-- Check the documentation https://freemode.readme.io/docs/getting-started database = { - driver = GetConvar('database_driver', 'mysql-async'), + driver = GetConvar('database_driver', 'couchdb'), host = GetConvar('es_couchdb_url', '127.0.0.1'), port = GetConvar('es_couchdb_port', '5984'), username = GetConvar('es_couchdb_password', 'admin:changeme') diff --git a/ext/locations.lua b/ext/locations.lua index 024bc12..45dd30f 100644 --- a/ext/locations.lua +++ b/ext/locations.lua @@ -1,4 +1,5 @@ local locations = { + {name="Altruist Cult Camp", id=269, c=4, x=-1042.29, y=4910.17, z=94.92}, {name="Ammu-Nation", id=110, c=4, x=1701.292, y=3750.450, z=34.365}, {name="Ammu-Nation", id=110, c=4, x=237.428, y=-43.655, z=69.698}, {name="Ammu-Nation", id=110, c=4, x=843.604, y=-1017.784, z=27.546}, @@ -12,9 +13,7 @@ local locations = { {name="Carwash", id=100, x=55.7, y=-1391.3, z=30.5}, {name="Carwash", id=100, x=-699.320, y=-941.078, z=19.077}, {name="Comedy Club", id=102, x=-420.087, y=264.681, z=83.1927}, - {name="Movie Theater", id=135, c=4, x= 300.788, y= 200.752, z= 104.385}, - {name="Movie Theater", id=135, c=4, x= -1423.954, y= -213.62, z= 46.5}, - {name="Movie Theater", id=135, c=4, x=302.907, y= 135.939, z= 160.946}, + {name="Masks store", id=362, c=4, x= -1166.284, y= -1586.368, z=4.377}, {name="Strip club", id=121, c=4, x=134.476, y=-1307.887, z=28.983}, {name="Tequil-La La", id=93, c=4, x=-565.171, y=276.625, z=83.286}, {name="Gang", id=437, c=9, x=298.68, y=-2010.10, z=20.07}, @@ -22,14 +21,15 @@ local locations = { {name="Gang", id=437, c=9, x=-183.52, y=-1632.62, z=33.34}, {name="Gang", id=437, c=9, x=989.37, y=-1777.56, z=31.32}, {name="Gang", id=437, c=9, x=960.24, y=-140.31, z=74.50}, - {name="Gang", id=437, c=9, x=-1042.29, y=4910.17, z=94.92}, {name="Gang", id=437, c=9, x=29.4838, y=3735.593, z=38.688}, {name="Gang", id=437, c=9, x=-455.752, y=-1711.884, z=18.642}, {name="FIB", id=106, c=4, x=105.455, y=-745.483, z=44.754}, + {name="Lester", id=77, c=4, x=718.413, y=-981.006, z=24.124}, {name="Police station", id=60, c=4, x=425.130, y=-979.558, z=30.711}, {name="Police station", id=60, c=4, x=1859.234, y= 3678.742, z=33.690}, {name="Police station", id=60, c=4, x=-438.862, y=6020.768, z=31.490}, {name="Police station", id=60, c=4, x=818.221, y=-1289.883, z=26.300}, + {name="Premium Deluxe MotorSport", id=326, c=4, x=-67.264, y=-1091.146, z=26.632}, {name="Prison", id=285, c=4, x=1679.049, y=2513.711, z=45.565}, {name="Yacht", id=410, c=4, x=-2045.800, y=-1031.200, z=11.900}, {name="Warehouse", id=473, c=4, x=958.50, y=-1586.30, z=30.0}, @@ -40,8 +40,8 @@ local locations = { {name="Meth Production", id=499, c=4, x=1179.732, y=-3114.203, z=6.028}, {name="Money Production", id=500, c=4, x=639.35, y=2769.65, z=30}, {name="Fake ID Production", id=498, c=4, x=378.646, y=-834.4833, z=29.292}, - {name="Office", id=475, c=4, x=-79.25, y=-833.75, z=30}, - {name="Bunker", id=557, c=4, x=2110.75, y=3326.50, z=30.0} + {name="Office", id=475, c=4, x=-43.954, y=-796.541, z=44.225}, + {name="Humane Labs", id=80, c=4, x=3624.632, y=3756.963, z=28.516} } Citizen.CreateThread(function() @@ -120,5 +120,7 @@ Citizen.CreateThread(function() RequestIpl("ex_exec_warehouse_placement_interior_1_int_warehouse_s_dlc_milo") RequestIpl("ex_exec_warehouse_placement_interior_0_int_warehouse_m_dlc_milo") RequestIpl("ex_exec_warehouse_placement_interior_2_int_warehouse_l_dlc_milo") - RequestIpl("ex_dt1_11_office_02b") + RequestIpl("ex_dt1_11_office_02c") + RequestIpl("id2_14_during_door") + RequestIpl("id2_14_during1") end) diff --git a/ext/trains.lua b/ext/trains.lua index 9920006..ddf836d 100644 --- a/ext/trains.lua +++ b/ext/trains.lua @@ -3,10 +3,7 @@ local trainCoords = {} local storedTrains = {} Citizen.CreateThread(function() - -- Define the train models local trainModels = {"freight", "freightcar", "freightgrain", "freightcont1", "freightcont2","tankercar", "freighttrailer", "metrotrain"} - - -- Define the train coordinates local trains = { {type=0, x=-498.4123, y=4304.3, z=88.40305}, {type=0, x=2324.3, y=2670.7, z=44.45}, @@ -17,7 +14,6 @@ Citizen.CreateThread(function() {type=24, x=181.1, y=-1198.8, z=37.6}, } - -- Load the train models for i= 1, 8 do RequestModel(GetHashKey(trainModels[i])) while not HasModelLoaded(GetHashKey(trainModels[i])) do @@ -25,13 +21,11 @@ Citizen.CreateThread(function() end end - -- Load the traindriver RequestModel(GetHashKey("s_m_m_lsmetro_01")) while not HasModelLoaded(GetHashKey("s_m_m_lsmetro_01")) do Citizen.Wait(1) end - -- Start the trains for i=1, 7, 1 do local trainCoords = trains[i] local thisTrain = CreateMissionTrain(trainCoords.type, trainCoords.x, trainCoords.y, trainCoords.z, true) diff --git a/int/bunkers.lua b/int/bunkers.lua deleted file mode 100644 index 9cc8bdb..0000000 --- a/int/bunkers.lua +++ /dev/null @@ -1,413 +0,0 @@ -local function LoadBunkerWorkers() - local Workers = { - {x=885.606, y=-3199.558, z=-98.196, heading= 33.884}, - {x= 893.9716, y= -3201.912, z= -98.19622, heading= 33.884}, - {x= 889.994, y= -3201.95, z= -98.1963, heading= 100.0} - } - - RequestModel(GetHashKey("s_m_m_scientist_01")) - while not HasModelLoaded(GetHashKey("s_m_m_scientist_01")) do - Wait(0) - end - - for k,v in pairs(Workers) do - worker = CreatePed(6, GetHashKey("s_m_m_scientist_01"), v.x, v.y, v.z, v.heading, true, false) - SetBlockingOfNonTemporaryEvents(worker, true) - SetEntityInvincible(worker, true) - end - - SetModelAsNoLongerNeeded(GetHashKey("s_m_m_scientist_01")) -end - - -local function LoadMocInt() - if not HasModelLoaded(GetHashKey("gr_prop_gr_trailer_monitor_03")) then - RequestModel(GetHashKey("gr_prop_gr_trailer_monitor_03")) - while not HasModelLoaded(GetHashKey("gr_prop_gr_trailer_monitor_03")) do - Wait(0) - end - end - - if not HasModelLoaded(-2083549178) then - RequestModel(-2083549178) - while not HasModelLoaded(-2083549178) do - Wait(0) - end - end - - if DoesEntityExist(GetClosestObjectOfType(1102.596, -3001.493,-40.00575, 2.0, -2083549178, 0, 0, 0)) then - mocIntCarMod = GetClosestObjectOfType(1102.596, -3001.493,-40.00575, 2.0, -2083549178, 0, 0, 0) - SetObjectTextureVariant(mocIntCarMod, 7) - end - - if not DoesEntityExist(mocIntCarMod) then - mocIntCarMod = CreateObjectNoOffset(-2083549178, 1102.596, -3001.493,-40.00575, 0, 1, 0) - SetEntityRotation(mocIntCarMod, -0, -0, -0.1030985) - SetEntityHeading(mocIntCarMod, 359.89691162109) - FreezeEntityPosition(mocIntCarMod, 1) - SetEntityCollision(mocIntCarMod, true, true) - SetObjectTextureVariant(mocIntCarMod, 7) - else - SetObjectTextureVariant(mocIntCarMod, 7) - end - - if not HasModelLoaded(-2104782239) then - RequestModel(-2104782239) - end - - if DoesEntityExist(GetClosestObjectOfType(1102.572, -3009.447, -39.98857, 2.0, -2104782239, 0, 0, 0)) then - mocIntCommand = GetClosestObjectOfType(1102.572, -3009.447, -39.98857, 2.0, -2104782239, 0, 0, 0) - end - - if not DoesEntityExist(mocIntCommand) then - mocIntCommand = CreateObjectNoOffset(-2104782239, 1102.572, -3009.447, -39.98857, 0, 1, 0) - SetEntityRotation(mocIntCommand, -0, -0, -0.2033111) - SetEntityHeading(mocIntCommand, 359.79669189453) - FreezeEntityPosition(mocIntCommand, 1) - - SetEntityCollision(mocIntCommand, true, true) - SetObjectTextureVariant(mocIntCommand, 7) - else - SetObjectTextureVariant(mocIntCommand, 7) - end - - if DoesEntityExist(GetClosestObjectOfType(1102.189, -3009.409, -39.97825, 2.0, -901846631, 0, 0, 0)) then - mocIntClosedDoor = GetClosestObjectOfType(1102.189, -3009.409, -39.97825, 2.0, -901846631, 0, 0, 0) - end - - if not DoesEntityExist(mocIntClosedDoor) then - mocIntClosedDoor = CreateObjectNoOffset(-901846631, 1102.189, -3009.409, -39.97825, 0, 1, 0) - SetEntityRotation(mocIntClosedDoor, -0, -0, -179.9231) - SetEntityHeading(mocIntClosedDoor, 180.07693481445) - FreezeEntityPosition(mocIntClosedDoor, 1) - SetEntityCollision(mocIntClosedDoor, true, true) - SetObjectTextureVariant(mocIntClosedDoor, 7) - else - SetObjectTextureVariant(mocIntClosedDoor, 7) - end - - if not DoesEntityExist(mocMonitor3) then - mocMonitor3 = CreateObjectNoOffset(GetHashKey("gr_prop_gr_trailer_monitor_03"), 1106.366, -3008.03, -40.01062, 0, 1, 0) - SetEntityRotation(mocMonitor3, -0, -0, 97.5754) - SetEntityHeading(mocMonitor3, 97.575401306152) - FreezeEntityPosition(mocMonitor3, 1) - end -end - -local function LoadBunkerPed() - if not DoesEntityExist(bunkerPed) then - RequestModel(GetHashKey("MP_M_WeapExp_01")) - while not HasModelLoaded(GetHashKey("MP_M_WeapExp_01")) do - Wait(0) - end - - bunkerPed = CreatePed(26, GetHashKey("MP_M_WeapExp_01"), 834.137, -3244.638, -98.699, -18.0, true, false) - SetNetworkIdExistsOnAllMachines(bunkerPed, 0) - NetworkUnregisterNetworkedEntity(bunkerPed) - NetworkSetEntityVisibleToNetwork(bunkerPed, 0) - - - SetBlockingOfNonTemporaryEvents(bunkerPed, true) - SetAmbientVoiceName(bunkerPed, "MALE_GENERICWORKER_R2PVG") - SetEntityInvincible(bunkerPed, true) - - SetModelAsNoLongerNeeded(GetHashKey("MP_M_WeapExp_01")) - end -end - -local function LoadBunkerInterior() - RequestIpl("grdlc_int_01_shell") - RequestIpl("gr_grdlc_int_01") - RequestIpl("gr_grdlc_int_02") - - RequestIpl("gr_entrance_placement") - RequestIpl("gr_grdlc_interior_placement") - RequestIpl("gr_grdlc_interior_placement_interior_0_grdlc_int_01_milo_") - - RequestIpl("gr_grdlc_interior_placement_interior_1_grdlc_int_02_milo_") - - EnableInteriorProp(258561, "bunker_style_b") - EnableInteriorProp(258561, "upgrade_bunker_set") - EnableInteriorProp(258561, "upgrade_bunker_set_more") - - EnableInteriorProp(258561, "security_upgrade") - EnableInteriorProp(258561, "Office_Upgrade_set") - - EnableInteriorProp(258561, "gun_range_lights") - EnableInteriorProp(258561, "gun_schematic_set") - EnableInteriorProp(258561, "gun_locker_upgrade") - RefreshInterior(258561) -end - -local function LoadBunkerTruck() - if DoesEntityExist(GetClosestVehicle(890.708, -3236.804, -98.8961, 30.0, GetHashKey("hauler2"), 131078)) and DoesEntityExist(GetClosestVehicle(834.2265, -3234.795, -98.4865, 30.0, 1502869817, 131078)) then - mocTruck = GetClosestVehicle(834.2265, -3234.795, -98.4865, 30.0, GetHashKey("hauler2"), 131078) - SetNetworkIdExistsOnAllMachines(NetworkGetNetworkIdFromEntity(mocTruck), 0) - - NetworkSetEntityVisibleToNetwork(mocTruck, 0) - SetEntityCollision(mocTruck, true, false) - - mocTrailer = GetClosestVehicle(842.6267, -3239.217, -96.8499, 30.0, GetHashKey("trailerlarge"), 131078) - SetNetworkIdExistsOnAllMachines(NetworkGetNetworkIdFromEntity(mocTrailer), 0) - NetworkSetEntityVisibleToNetwork(mocTrailer, 0) - SetEntityCollision(mocTrailer, true, false) - - else - RequestModel(GetHashKey("trailerlarge")) - RequestModel(GetHashKey("hauler2")) - - if not DoesEntityExist(mocTruck) and not DoesEntityExist(mocTrailer) then - while not HasModelLoaded(GetHashKey("trailerlarge"))do - Wait(0) - end - - while not HasModelLoaded(GetHashKey("hauler2"))do - Wait(0) - end - - if HasModelLoaded(GetHashKey("hauler2")) and HasModelLoaded(GetHashKey("trailerlarge")) then - mocTruck = CreateVehicle(GetHashKey("hauler2"), 834.2265, -3234.795, -98.4865, 62.28, true, false) - SetNetworkIdExistsOnAllMachines(NetworkGetNetworkIdFromEntity(mocTruck), 0) - NetworkSetEntityVisibleToNetwork(mocTruck, 0) - - SetVehicleOnGroundProperly(mocTruck) - SetVehicleDoorsLocked(mocTruck, 2) - SetEntityProofs(mocTruck, true, true, true, true, true, false, 0, false) - - mocTrailer = CreateVehicle(GetHashKey("trailerlarge"), 842.6267, -3239.217, -96.8499, 62.28, true, false) - SetNetworkIdExistsOnAllMachines(NetworkGetNetworkIdFromEntity(mocTrailer), 0) - NetworkSetEntityVisibleToNetwork(mocTrailer, 0) - SetEntityCollision(mocTrailer, true, false) - - AttachVehicleToTrailer(mocTruck, mocTrailer, 1.0) - end - - SetModelAsNoLongerNeeded(GetHashKey("hauler2")) - SetModelAsNoLongerNeeded(GetHashKey("trailerlarge")) - end - end -end - -local function LoadBunkerCars() - if DoesEntityExist(GetClosestVehicle(890.708, -3236.804, -98.8961, 1.0, GetHashKey("caddy3"))) then - buggyA = GetClosestVehicle(887.824, -3236.251, -98.8946, 1.0, GetHashKey("caddy3")) - SetNetworkIdExistsOnAllMachines(NetworkGetNetworkIdFromEntity(buggyA), 0) - NetworkSetEntityVisibleToNetwork(buggyA, 0) - - SetVehicleExtra(buggyA, 2, false) - SetVehicleExtra(buggyA, 3, false) - SetVehicleExtra(buggyA, 1, false) - ForceRoomForEntity(buggyA, 258561, -1116396409) - end - - if DoesEntityExist(GetClosestVehicle(890.708, -3236.804, -98.8961, 1.0, GetHashKey("caddy3"))) then - buggyB = GetClosestVehicle(890.708, -3236.804, -98.8961, 1.0, GetHashKey("caddy3")) - SetNetworkIdExistsOnAllMachines(NetworkGetNetworkIdFromEntity(buggyB), 0) - NetworkSetEntityVisibleToNetwork(buggyB, 0) - - SetVehicleExtra(buggyB, 2, true) - SetVehicleExtra(buggyB, 3, true) - SetVehicleExtra(buggyB, 1, true) - - ForceRoomForEntity(buggyB, 258561, -1116396409) - end - - if not DoesEntityExist(buggyA) and not DoesEntityExist(buggyB) then - RequestModel(GetHashKey("caddy3")) - while not HasModelLoaded(GetHashKey("caddy3")) do - Wait(0) - end - - buggyA = CreateVehicle(GetHashKey("caddy3"), 887.824, -3236.251, -98.8946, 0.0, true, false) - SetNetworkIdExistsOnAllMachines(NetworkGetNetworkIdFromEntity(buggyA), 0) - NetworkSetEntityVisibleToNetwork(buggyA, 0) - - SetVehicleExtra(buggyA, 1, false) - SetVehicleExtra(buggyA, 2, false) - SetVehicleExtra(buggyA, 3, false) - - buggyB = CreateVehicle(GetHashKey("caddy3"), 890.708, -3236.804, -98.8961, 0.0, true, false) - SetNetworkIdExistsOnAllMachines(NetworkGetNetworkIdFromEntity(buggyB), 1) - NetworkSetEntityVisibleToNetwork(buggyB, 0) - - SetVehicleExtra(buggyB, 2, true) - SetVehicleExtra(buggyB, 3, true) - SetVehicleExtra(buggyB, 1, true) - ForceRoomForEntity(buggyB, 258561, -1116396409) - - SetModelAsNoLongerNeeded(GetHashKey("caddy3")) - end - end - - local function PrintMenu() - if WarMenu.IsMenuOpened('gunMod') then - if WarMenu.MenuButton('Cutomize Cab', 'customCab') then - - end - - if WarMenu.MenuButton('Cutomize Trailer', 'customTrailer') then - - end - - if WarMenu.MenuButton('Exit') then - - end - WarMenu.Display() - - elseif WarMenu.IsMenuOpened('customCab') then - if WarMenu.MenuButton('Armor', 'gunMod') then - -- - elseif WarMenu.MenuButton('Breakes', 'gunMod') then - -- - elseif WarMenu.MenuButton('Engine', 'gunMod') then - -- - elseif WarMenu.MenuButton('Horn', 'gunMod') then - -- - elseif WarMenu.MenuButton('Lights', 'gunMod') then - -- - elseif WarMenu.MenuButton('Respray', 'gunMod') then - -- - elseif WarMenu.MenuButton('Suspension', 'gunMod') then - -- - elseif WarMenu.MenuButton('Transmission', 'gunMod') then - -- - elseif WarMenu.MenuButton('Turbo', 'gunMod') then - -- - elseif WarMenu.MenuButton('Wheels', 'gunMod') then - -- - elseif WarMenu.MenuButton('Suspension', 'gunMod') then - -- - end - - WarMenu.Display() - - elseif WarMenu.IsMenuOpened('customTrailer') then - if WarMenu.Button('Livery') then - -- - elseif WarMenu.MenuButton('Plate', 'gunMod') then - -- - elseif WarMenu.MenuButton('Respray', 'gunMod') then - -- - elseif WarMenu.MenuButton('Weapons', 'gunMod') then - -- - end - WarMenu.Display() - elseif IsControlJustReleased(0, 38) then - WarMenu.OpenMenu('gunMod') - end - end - -Citizen.CreateThread(function() - WarMenu.CreateMenu('gunMod', 'gunmod') - WarMenu.CreateSubMenu('customCab', 'gunMod') - WarMenu.CreateSubMenu('customTrailer', 'gunMod') - - WarMenu.SetTitleColor('gunMod', 255, 255, 255) - WarMenu.SetTitleColor('customCab', 255, 255, 255) - WarMenu.SetTitleColor('customTrailer', 255, 255, 255) - - WarMenu.SetSubTitle('gunMod', i18n.translate('bunker_vehicle_workshop_title')) - WarMenu.SetSubTitle('customCab', i18n.translate('categories')) - WarMenu.SetSubTitle('customTrailer', i18n.translate('categories')) - - WarMenu.SetTitleBackgroundColor('gunMod', 255, 255, 255) - WarMenu.SetTitleBackgroundColor('customCab', 255, 255, 255) - WarMenu.SetTitleBackgroundColor('customTrailer', 255, 255, 255) - while true do - Wait(0) - local playerCoords = GetEntityCoords(GetPlayerPed(-1), true) - DrawMarker(1, 2107.249, 3324.453, 45.377-1.0001, 0, 0, 0, 0, 0, 0, 4.0, 4.0, 0.25, 240, 200, 80, 150, 0, 0, 1, 0, 0, 0, 0) - - if GetDistanceBetweenCoords(playerCoords.x, playerCoords.y, playerCoords.z, 2107.249, 3324.453, 45.377, true) <= 3.0 then - TriggerEvent("fs_freemode:displayHelp", i18n.translate("enter_bunker")) - if IsControlJustPressed(0, 38) then - DoScreenFadeOut(1000) - Citizen.Wait(1500) - - LoadBunkerInterior() - SetEntityCoords(GetPlayerPed(-1), 887.65, -3245.10, -98.27) - - ExitBlip = AddBlipForCoord(894.5, -3245.75, -98.27) - SetBlipSprite(ExitBlip, 1) - SetBlipColour(ExitBlip, 2) - - Citizen.Wait(1000) - - LoadBunkerCars() - LoadBunkerPed() - LoadBunkerWorkers() - Wait(1000) - DoScreenFadeIn(1000) - end - LoadBunkerTruck() - LoadMocInt() - end - - if GetInteriorFromEntity(GetPlayerPed()) == 258561 then - SetCurrentPedWeapon(PlayerPedId(), GetHashKey("weapon_unarmed")) - - DisableControlAction(0, 22) - DisableControlAction(0, 24) - DisableControlAction(0, 25) - - if GetDistanceBetweenCoords(playerCoords, 834.137, -3244.638, -98.699) <= 3.0 then - TriggerEvent("fs_freemode:displayHelp", i18n.translate("enter_bunker_workshop")) - PrintMenu() - end - - --this draws the marker to enter the MOC - DrawMarker(1, 848.4579, -3242.338, -99.69917, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.52, 0, 255, 255, 150, 0, 0, 2, 0, 0, 0, false) - if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1), true), 848.4579, -3242.338, -99.69917) < 2.8 then - TriggerEvent("fs_freemode:displayHelp", i18n.translate("enter_moc")) - if IsControlPressed(0, 38) then - DoScreenFadeOut(1000) - Citizen.Wait(1500) - - SetEntityCoords(GetPlayerPed(-1), 1103.5620, -3000.00, -40.00) - - Wait(1500) - DoScreenFadeIn(1500) - end - end - end - - --this draws the marker to return to the bunker from "MOC" - DrawMarker(1, 1102.645, -2986.465, -39.99833, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.52, 0, 255, 255, 150, 0, 0, 2, 0, 0, 0, false ) - if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1), true), 1102.645, -2986.465, -38.99833) < 3.8 then - TriggerEvent("fs_freemode:displayHelp", i18n.translate("exit_moc")) - if IsControlPressed(0, 38) then - DoScreenFadeOut(1000) - Citizen.Wait(1500) - - SetEntityCoords(GetPlayerPed(-1), 885.982, -3245.716, -98.278) - - Wait(1500) - DoScreenFadeIn(1500) - end - end - - if GetDistanceBetweenCoords(playerCoords.x, playerCoords.y, playerCoords.z, 894.5, -3245.75, -98.27, true) <= 5.0 then - TriggerEvent("fs_freemode:displayHelp", i18n.translate("exit_bunker")) - if IsControlJustPressed(0, 38) then - DoScreenFadeOut(1000) - Citizen.Wait(1500) - - RemoveBlip(ExitBlip) - RemoveIpl("grdlc_int_01_shell") - RemoveIpl("gr_grdlc_int_01") - - RemoveIpl("gr_grdlc_int_02") - RemoveIpl("gr_entrance_placement") - RemoveIpl("gr_grdlc_interior_placement") - - RemoveIpl("gr_grdlc_interior_placement_interior_0_grdlc_int_01_milo_") - RemoveIpl("gr_grdlc_interior_placement_interior_1_grdlc_int_02_milo_") - - SetEntityCoords(GetPlayerPed(-1), 2123.116, 3320.529, 45.388) - Citizen.Wait(1000) - DoScreenFadeIn(1000) - end - end - - end -end) diff --git a/int/office.lua b/int/office.lua index 7e2bca0..f7a34ef 100644 --- a/int/office.lua +++ b/int/office.lua @@ -1,137 +1,191 @@ -local function loadOffice() - RequestModel(GetHashKey("mp_f_execpa_01")) - while not HasModelLoaded(GetHashKey("mp_f_execpa_01")) do - Wait(0) - end +local assistant = nil + +local function CreateAssistantPed() + if not DoesEntityExist(assistant) then + + RequestModel(GetHashKey("mp_f_execpa_01")) + while not HasModelLoaded(GetHashKey("mp_f_execpa_01")) do + Wait(0) + end - local assistant = CreatePed(5, GetHashKey("mp_f_execpa_01"), -72.021, -814.392, 243.386, 153.236, false, false) - SetBlockingOfNonTemporaryEvents(assistant, true) - SetEntityInvincible(assistant, true) + assistant = CreatePed(5, GetHashKey("mp_f_execpa_01"),-72.011, -814.007, 243.384-1.0001, false, false) + SetEntityHeading(assistant, 153.236) - EnableInteriorProp(239617, "office_chairs") - EnableInteriorProp(239617, "office_booze") + SetPedComponentVariation(assistant, 3, 2, 0, 0) + SetPedComponentVariation(assistant, 11, 1, 0, 0) + SetPedComponentVariation(assistant, 8, 2, 0, 0) + SetPedComponentVariation(assistant, 4, 2, 0, 0) + + SetBlockingOfNonTemporaryEvents(assistant, true) + SetEntityInvincible(assistant, true) + end +end - EnableInteriorProp(239617, "cash_set_01") - EnableInteriorProp(239617, "cash_set_02") - EnableInteriorProp(239617, "cash_set_03") +local function EnableOfficeInterior(interiorID) - EnableInteriorProp(239617, "cash_set_04") - EnableInteriorProp(239617, "cash_set_05") - EnableInteriorProp(239617, "cash_set_06") - EnableInteriorProp(239617, "cash_set_07") + EnableInteriorProp(interiorID, "office_chairs") + EnableInteriorProp(interiorID, "office_booze") - EnableInteriorProp(239617, "cash_set_08") - EnableInteriorProp(239617, "cash_set_09") - EnableInteriorProp(239617, "cash_set_10") + EnableInteriorProp(interiorID, "cash_set_01") + EnableInteriorProp(interiorID, "cash_set_02") + EnableInteriorProp(interiorID, "cash_set_03") - EnableInteriorProp(239617, "cash_set_11") - EnableInteriorProp(239617, "cash_set_12") - EnableInteriorProp(239617, "cash_set_13") + EnableInteriorProp(interiorID, "cash_set_04") + EnableInteriorProp(interiorID, "cash_set_05") + EnableInteriorProp(interiorID, "cash_set_06") + EnableInteriorProp(interiorID, "cash_set_07") - EnableInteriorProp(239617, "cash_set_14") - EnableInteriorProp(239617, "cash_set_15") - EnableInteriorProp(239617, "cash_set_16") + EnableInteriorProp(interiorID, "cash_set_08") + EnableInteriorProp(interiorID, "cash_set_09") + EnableInteriorProp(interiorID, "cash_set_10") - EnableInteriorProp(239617, "cash_set_17") - EnableInteriorProp(239617, "cash_set_18") - EnableInteriorProp(239617, "cash_set_19") + EnableInteriorProp(interiorID, "cash_set_11") + EnableInteriorProp(interiorID, "cash_set_12") + EnableInteriorProp(interiorID, "cash_set_13") - EnableInteriorProp(239617, "cash_set_20") - EnableInteriorProp(239617, "cash_set_21") - EnableInteriorProp(239617, "cash_set_22") + EnableInteriorProp(interiorID, "cash_set_14") + EnableInteriorProp(interiorID, "cash_set_15") + EnableInteriorProp(interiorID, "cash_set_16") - EnableInteriorProp(239617, "cash_set_23") - EnableInteriorProp(239617, "cash_set_24") - EnableInteriorProp(239617, "swag_silver") + EnableInteriorProp(interiorID, "cash_set_17") + EnableInteriorProp(interiorID, "cash_set_18") + EnableInteriorProp(interiorID, "cash_set_19") - EnableInteriorProp(239617, "swag_silver2") - EnableInteriorProp(239617, "swag_silver3") - EnableInteriorProp(239617, "swag_drugbags") + EnableInteriorProp(interiorID, "cash_set_20") + EnableInteriorProp(interiorID, "cash_set_21") + EnableInteriorProp(interiorID, "cash_set_22") - EnableInteriorProp(239617, "swag_drugbags2") - EnableInteriorProp(239617, "swag_drugbag3") - EnableInteriorProp(239617, "swag_booze_cigs") + EnableInteriorProp(interiorID, "cash_set_23") + EnableInteriorProp(interiorID, "cash_set_24") + EnableInteriorProp(interiorID, "swag_silver") - EnableInteriorProp(239617, "swag_booze_cigs2") - EnableInteriorProp(239617, "swag_booze_cigs3") - EnableInteriorProp(239617, "swag_electronic") + EnableInteriorProp(interiorID, "swag_silver2") + EnableInteriorProp(interiorID, "swag_silver3") + EnableInteriorProp(interiorID, "swag_drugbags") - EnableInteriorProp(239617, "swag_electronic2") - EnableInteriorProp(239617, "swag_electronic3") - EnableInteriorProp(239617, "swag_drugstatue") + EnableInteriorProp(interiorID, "swag_drugbags2") + EnableInteriorProp(interiorID, "swag_drugbag3") + EnableInteriorProp(interiorID, "swag_booze_cigs") - EnableInteriorProp(239617, "swag_drugstatue2") - EnableInteriorProp(239617, "swag_drugstatue3") - EnableInteriorProp(239617, "swag_ivory") + EnableInteriorProp(interiorID, "swag_booze_cigs2") + EnableInteriorProp(interiorID, "swag_booze_cigs3") + EnableInteriorProp(interiorID, "swag_electronic") - EnableInteriorProp(239617, "swag_ivory2") - EnableInteriorProp(239617, "swag_ivory3") + EnableInteriorProp(interiorID, "swag_electronic2") + EnableInteriorProp(interiorID, "swag_electronic3") + EnableInteriorProp(interiorID, "swag_drugstatue") - EnableInteriorProp(239617, "swag_pills") - EnableInteriorProp(239617, "swag_pills2") - EnableInteriorProp(239617, "swag_pills3") + EnableInteriorProp(interiorID, "swag_drugstatue2") + EnableInteriorProp(interiorID, "swag_drugstatue3") + EnableInteriorProp(interiorID, "swag_ivory") - EnableInteriorProp(239617, "swag_jewelwatch") - EnableInteriorProp(239617, "swag_jewelwatch2") - EnableInteriorProp(239617, "swag_jewelwatch3") + EnableInteriorProp(interiorID, "swag_ivory2") + EnableInteriorProp(interiorID, "swag_ivory3") - EnableInteriorProp(239617, "swag_furcoats") - EnableInteriorProp(239617, "swag_furcoats2") - EnableInteriorProp(239617, "swag_furcoats3") - EnableInteriorProp(239617, "swag_art") + EnableInteriorProp(interiorID, "swag_pills") + EnableInteriorProp(interiorID, "swag_pills2") + EnableInteriorProp(interiorID, "swag_pills3") - EnableInteriorProp(239617, "swag_art2") - EnableInteriorProp(239617, "swag_art3") - EnableInteriorProp(239617, "swag_guns") + EnableInteriorProp(interiorID, "swag_jewelwatch") + EnableInteriorProp(interiorID, "swag_jewelwatch2") + EnableInteriorProp(interiorID, "swag_jewelwatch3") - EnableInteriorProp(239617, "swag_guns2") - EnableInteriorProp(239617, "swag_guns3") - EnableInteriorProp(239617, "swag_med") + EnableInteriorProp(interiorID, "swag_furcoats") + EnableInteriorProp(interiorID, "swag_furcoats2") + EnableInteriorProp(interiorID, "swag_furcoats3") + EnableInteriorProp(interiorID, "swag_art") - EnableInteriorProp(239617, "swag_med2") - EnableInteriorProp(239617, "swag_med3") - EnableInteriorProp(239617, "swag_gems") + EnableInteriorProp(interiorID, "swag_art2") + EnableInteriorProp(interiorID, "swag_art3") + EnableInteriorProp(interiorID, "swag_guns") - EnableInteriorProp(239617, "swag_gems2") - EnableInteriorProp(239617, "swag_gems3") - EnableInteriorProp(239617, "swag_counterfeit") + EnableInteriorProp(interiorID, "swag_guns2") + EnableInteriorProp(interiorID, "swag_guns3") + EnableInteriorProp(interiorID, "swag_med") - EnableInteriorProp(239617, "swag_counterfeit2") - EnableInteriorProp(239617, "swag_counterfeit3") + EnableInteriorProp(interiorID, "swag_med2") + EnableInteriorProp(interiorID, "swag_med3") + EnableInteriorProp(interiorID, "swag_gems") - RefreshInterior(239617) + EnableInteriorProp(interiorID, "swag_gems2") + EnableInteriorProp(interiorID, "swag_gems3") + + EnableInteriorProp(interiorID, "swag_counterfeit") + EnableInteriorProp(interiorID, "swag_counterfeit2") + EnableInteriorProp(interiorID, "swag_counterfeit3") + + RefreshInterior(interiorID) +end + +local function SetOrganisationName() + local targetHash = -2082168399 + banner = RequestScaleformMovie("ORGANISATION_NAME") + + if HasScaleformMovieLoaded(banner) then + playerID = PlayerId() + playerName = GetPlayerName(playerID) + + PushScaleformMovieFunction(banner, "SET_ORGANISATION_NAME") + PushScaleformMovieFunctionParameterString(tostring(playerName)) + + PushScaleformMovieFunctionParameterInt(-1) -- scale + PushScaleformMovieFunctionParameterInt(0) -- color + PushScaleformMovieFunctionParameterInt(2) -- font + PopScaleformMovieFunction() + end + + if (not IsNamedRendertargetRegistered("prop_ex_office_text")) then + RegisterNamedRendertarget("prop_ex_office_text", 0) + LinkNamedRendertarget(targetHash) + + Wait(500) + + if (not IsNamedRendertargetLinked(targetHash)) then + ReleaseNamedRendertarget(GetHashKey("prop_ex_office_text")) + end + end + + local renderID = GetNamedRendertargetRenderId("prop_ex_office_text") + SetTextRenderId(renderID) + DrawScaleformMovie(banner, 0.196*1.75, 0.345*1.5, 0.46*2.5, 0.66*2.5, 255, 255, 255, 255, 1) + SetTextRenderId(GetDefaultScriptRendertargetRenderId()) end Citizen.CreateThread(function() while true do Citizen.Wait(0) - local playerCoords = GetEntityCoords(GetPlayerPed(-1), true) + local playerCoords = GetEntityCoords(PlayerPedId(), true) + local interiorCode = GetInteriorFromEntity(PlayerPedId()) + local intCoords = GetInteriorAtCoords(-72.021, -814.392, 243.386) - DrawMarker(1, -150.982, -874.066, 29.602-1.0001, 0, 0, 0, 0, 0, 0, 4.0, 4.0, 2.0, 13, 232, 255, 155, 0, 0, 2, 0, 0, 0, 0) DrawMarker(1, -50.148, -791.495, 44.225-1.0001, 0, 0, 0, 0, 0, 0, 4.0, 4.0, 2.0, 13, 232, 255, 155, 0, 0, 2, 0, 0, 0, 0) - if GetDistanceBetweenCoords(playerCoords, -150.982, -874.066, 29.602, true) <= 2.0 then + if GetDistanceBetweenCoords(playerCoords, -50.148, -791.495, 44.225-1.0001, true) <= 2.0 then TriggerEvent("fs_freemode:displayHelp", i18n.translate("enter_office")) if IsControlJustPressed(0, 38) then - loadOffice() - SetEntityCoords(GetPlayerPed(-1), -75.8466, -826.9893, 243.3859) + SetEntityCoords(PlayerPedId(), -75.8466, -826.9893, 243.3859) + if not DoesEntityExist(assistant) then + CreateAssistantPed() + end + + EnableOfficeInterior(intCoords) + PlayerInsideOffice = true end end + if PlayerInsideOffice then + DrawMarker(1, -78.087, -832.295, 243.386-1.0001, 0, 0, 0, 0, 0, 0, 0.5, 0.5, 0.5, 13, 232, 255, 155, 0, 0, 2, 0, 0, 0, 0) + SetOrganisationName() + else + SetScaleformMovieAsNoLongerNeeded(banner) + end - if GetDistanceBetweenCoords(playerCoords, -50.148, -791.495, 44.225-1.0001, true) <= 2.0 then - TriggerEvent("fs_freemode:displayHelp", i18n.translate("enter_office")) - if IsControlJustPressed(0, 38) then - loadOffice() - SetEntityCoords(GetPlayerPed(-1), -75.8466, -826.9893, 243.3859) - end - end - - DrawMarker(1, -78.087, -832.295, 243.386-1.0001, 0, 0, 0, 0, 0, 0, 0.5, 0.5, 0.5, 13, 232, 255, 155, 0, 0, 2, 0, 0, 0, 0) if GetDistanceBetweenCoords(playerCoords, -78.087, -832.295, 243.386, true) <= 3.0 then TriggerEvent("fs_freemode:displayHelp", i18n.translate("exit_office")) if IsControlJustPressed(0, 38) then - SetEntityCoords(GetPlayerPed(-1), -40.487, -775.333, 44.227, 90.790, false) + SetEntityCoords(PlayerPedId(), -40.487, -775.333, 44.227, 90.790, false) + SetEntityAsNoLongerNeeded(assistant) + PlayerInsideOffice = false end end diff --git a/int/vehicles.lua b/int/vehicles.lua new file mode 100644 index 0000000..51c1bc1 --- /dev/null +++ b/int/vehicles.lua @@ -0,0 +1,348 @@ +local carList = {} +local fakecar = {model = '', car = nil, costs= nil} + +RegisterNetEvent('es_vehshop:myVehicles') +AddEventHandler('es_vehshop:myVehicles', function(vehicles) + for i=1, #vehicles do + Citizen.Trace(vehicles[i] ..'\n') + end + carList = vehicles +end) + +AddEventHandler('playerSpawned', function(spawn) + TriggerServerEvent('es_vehshop:GetVehicles') +end) + + +local function SpawnFakeCar(vehicle, price) + local playerCoords = GetEntityCoords(playerPed) + + if fakecar.model ~= vehicle then + if DoesEntityExist(fakecar.car) then + Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car)) + end + + local hash = GetHashKey(vehicle) + + RequestModel(hash) + while not HasModelLoaded(hash) do + Citizen.Wait(0) + end + + local veh = CreateVehicle(hash, -46.56327, -1097.382, 25.99875, 0.0, false, false) + while not DoesEntityExist(veh) do + Citizen.Wait(0) + end + + FreezeEntityPosition(veh,true) + SetEntityInvincible(veh,true) + SetVehicleDoorsLocked(veh,4) + + TaskWarpPedIntoVehicle(GetPlayerPed(-1), veh,-1) + SetVehRadioStation(veh, "OFF") + SetVehicleLights(veh, 2) + for i = 0,24 do + SetVehicleModKit(veh,0) + RemoveVehicleMod(veh,i) + end + fakecar = { model = vehicle, car = veh, costs = price} + + WarMenu.OpenMenu('confirmMenu') + end +end + +local function spawnVehicle(vehicle) + local car = GetHashKey(vehicle) + local playerPed = GetPlayerPed(-1) + + if playerPed and playerPed ~= -1 then + if DoesEntityExist(fakecar.car) then + Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car)) + end + + RequestModel(car) + while not HasModelLoaded(car) do + Citizen.Wait(0) + end + + local veh = CreateVehicle(car, -19.521, -1117.096, 26.765, 175.394, true, true) + local id = NetworkGetNetworkIdFromEntity(veh) + SetNetworkIdCanMigrate(id, true) + SetVehicleOnGroundProperly(veh) + + TaskWarpPedIntoVehicle(playerPed, veh, -1) + SetEntityAsMissionEntity(veh, true, true) + FreezeEntityPosition(playerPed, false) + + SetEntityVisible(playerPed, true) + SetVehRadioStation(veh, "OFF") + SetVehicleHasBeenOwnedByPlayer(veh, true) + end +end + +CreateThread(function() + local currentItemIndex = 1 + local selectedItemIndex = 1 + local checkbox = true + + WarMenu.CreateMenu('vehshop', 'default', i18n.translate("vehicles_shop_title")) + WarMenu.SetMenuMaxOptionCountOnScreen('vehshop', 11) + + WarMenu.CreateSubMenu('confirmMenu', 'vehshop', i18n.translate("confirm")) + WarMenu.CreateSubMenu('closeMenu', 'vehshop', i18n.translate("vehicles_shop_title")) + + WarMenu.SetSubTitle('vehshop', i18n.translate("categories")) + WarMenu.SetSubTitle('confirmMenu', i18n.translate("vehicle_shop_confirmation")) + + WarMenu.SetTitleColor('vehshop', 255, 255, 255) + WarMenu.SetTitleColor('confirmMenu', 255, 255, 255) + + WarMenu.SetTitleBackgroundColor('vehshop', 255, 255, 255) + WarMenu.SetTitleBackgroundColor('confirmMenu', 255, 255, 255) + WarMenu.SetMenuBackgroundColor('closeMenu', 255, 255, 255) + + for k,v in ipairs(carGroups) do + WarMenu.CreateSubMenu(v.type, 'vehshop', v.name) + end + + while true do + local playerCoords = GetEntityCoords(GetPlayerPed(-1), true) + DrawMarker(1, -46.56327,-1097.382,25.99875-0.500,0,0,0,0,0,0,2.001,2.0001,0.5001,0,191,43,88,0,0,0,0) + if Vdist(playerCoords.x, playerCoords.y, playerCoords.z, -46.56327, -1097.382, 25.99875) <= 14.0 then + if IsPedInAnyVehicle(GetPlayerPed(-1), true) == false then + TriggerEvent("fs_freemode:displayHelp", i18n.translate("enter_vehicleshop")) + end + + if WarMenu.IsMenuOpened('vehshop') then + for k,v in ipairs(carGroups) do + if WarMenu.MenuButton(v.name, v.type) then + -- Go to the subcategory + + end + end + + if WarMenu.Button('Exit') then + WarMenu.CloseMenu('vehshop') + end + + WarMenu.Display() + elseif WarMenu.IsMenuOpened('compacts') then + for k,v in pairs(compacts) do + if WarMenu.Button(v.name, v.costs.." $") then + SpawnFakeCar(tostring(v.model), tonumber(v.costs)) + end + end + + WarMenu.Display() + + elseif WarMenu.IsMenuOpened('coupes') then + for k,v in pairs(coupes) do + if WarMenu.Button(v.name, v.costs.." $") then + SpawnFakeCar(tostring(v.model), tonumber(v.costs)) + end + end + + WarMenu.Display() + elseif WarMenu.IsMenuOpened('sedans') then + for k,v in pairs(sedans) do + if WarMenu.Button(v.name, v.costs.." $") then + SpawnFakeCar(tostring(v.model), tonumber(v.costs)) + end + end + + WarMenu.Display() + elseif WarMenu.IsMenuOpened('sports') then + for k,v in pairs(sports) do + if WarMenu.Button(v.name, v.costs.." $") then + SpawnFakeCar(tostring(v.model), tonumber(v.costs)) + end + end + + WarMenu.Display() + + elseif WarMenu.IsMenuOpened('sportclassics') then + for k,v in pairs(sportclassics) do + if WarMenu.Button(v.name, v.costs.." $") then + SpawnFakeCar(tostring(v.model), tonumber(v.costs)) + end + end + + WarMenu.Display() + + elseif WarMenu.IsMenuOpened('super') then + for k,v in pairs(super) do + if WarMenu.Button(v.name, v.costs.." $") then + SpawnFakeCar(tostring(v.model), tonumber(v.costs)) + end + end + + WarMenu.Display() + elseif WarMenu.IsMenuOpened('muscle') then + for k,v in pairs(muscle) do + if WarMenu.Button(v.name, v.costs.." $") then + SpawnFakeCar(tostring(v.model), tonumber(v.costs)) + end + end + + WarMenu.Display() + elseif WarMenu.IsMenuOpened('offroad') then + for k,v in pairs(offroad) do + if WarMenu.Button(v.name, v.costs.." $") then + SpawnFakeCar(tostring(v.model), tonumber(v.costs)) + end + end + + WarMenu.Display() + elseif WarMenu.IsMenuOpened('suvs') then + for k,v in pairs(suvs) do + if WarMenu.Button(v.name, v.costs.." $") then + SpawnFakeCar(tostring(v.model), tonumber(v.costs)) + end + end + + WarMenu.Display() + elseif WarMenu.IsMenuOpened('vans') then + for k,v in pairs(vans) do + if WarMenu.Button(v.name, v.costs.." $") then + SpawnFakeCar(tostring(v.model), tonumber(v.costs)) + end + end + + WarMenu.Display() + elseif WarMenu.IsMenuOpened('confirmMenu') then + if WarMenu.Button(i18n.translate("buy"), fakecar.costs .." $") then + TriggerServerEvent('CheckMoneyForVeh', fakecar.model, tonumber(fakecar.costs)) + WarMenu.CloseMenu() + elseif WarMenu.MenuButton(i18n.translate("no"), 'vehshop') then + + end + + WarMenu.Display() + elseif IsControlJustReleased(0, 38) then + FreezeEntityPosition(GetPlayerPed(-1),true) + SetEntityVisible(GetPlayerPed(-1),false) + local g = Citizen.InvokeNative(0xC906A7DAB05C8D2B,-46.56327,-1097.382,25.99875, Citizen.PointerValueFloat(),0) + SetEntityCoords(GetPlayerPed(-1),-46.56327,-1097.382,25.99875, g) + SetEntityHeading(GetPlayerPed(-1), 120.1953) + WarMenu.OpenMenu('vehshop') + end + end + + Citizen.Wait(0) + end +end) + +RegisterNetEvent('FinishMoneyCheckForVeh') +AddEventHandler('FinishMoneyCheckForVeh', function(moneyCheck) + if moneyCheck == "valid" then + local playerPed = GetPlayerPed(-1) + + local veh = GetVehiclePedIsUsing(playerPed) + local model = GetEntityModel(veh) + local colors = table.pack(GetVehicleColours(veh)) + local extra_colors = table.pack(GetVehicleExtraColours(veh)) + if DoesEntityExist(fakecar.car) then + Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car)) + end + + RequestModel(model) + while not HasModelLoaded(model) do + Citizen.Wait(0) + end + + FreezeEntityPosition(GetPlayerPed(-1), false) + local personal = CreateVehicle(model, -19.521, -1117.096, 26.765, 175.394, true, true) + local id = NetworkGetNetworkIdFromEntity(personal) + + SetNetworkIdCanMigrate(id, true) + SetVehicleOnGroundProperly(personal) + + SetEntityAsMissionEntity(personal, true, true) + SetEntityVisible(playerPed, true) + + SetVehRadioStation(personal, "OFF") + SetVehicleHasBeenOwnedByPlayer(personal, true) + + SetVehicleColours(personal, colors[1],colors[2]) + SetVehicleExtraColours(personal, extra_colors[1],extra_colors[2]) + TaskWarpPedIntoVehicle(GetPlayerPed(-1), personal, -1) + + else + WarMenu.OpenMenu('vehshop') + TriggerEvent("fs_freemode:notify", "CHAR_SIMEON", 4, 2, "Simeon", false, i18n.translate("more_cash_needed")) + + end +end) + +Citizen.CreateThread(function() + local currentItemIndex = 1 + local selectedItemIndex = 1 + local checkbox = true + + WarMenu.CreateMenu('test', 'default', i18n.translate("vehicle_inventory")) + WarMenu.SetTitleColor('test', 255, 255, 255) + WarMenu.SetTitleBackgroundColor('test', 255, 255, 255) + WarMenu.SetSubTitle('test', i18n.translate("options")) + while true do + if WarMenu.IsMenuOpened('test') then + if WarMenu.ComboBox(i18n.translate("vehicles_owned"), carList, currentItemIndex, selectedItemIndex, function(currentIndex, selectedIndex) + currentItemIndex = currentIndex + selectedItemIndex = selectedIndex + end) then + if selectedItemIndex then + Citizen.Trace('Selected index ' ..selectedItemIndex) + end + for k, v in pairs(carList) do + if selectedItemIndex == k then + TriggerEvent('vehshop:spawnVehicle', v) + WarMenu.CloseMenu() + end + end + elseif WarMenu.Button(i18n.translate("exit")) then + if fakecar.model then + if DoesEntityExist(fakecar.car) then + Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(fakecar.car)) + end + end + WarMenu.CloseMenu('test') + end + + WarMenu.Display() + elseif IsControlJustReleased(0, 56) then + WarMenu.OpenMenu('test') + end + + Citizen.Wait(0) + end +end) + +RegisterNetEvent('vehshop:spawnVehicle') +AddEventHandler('vehshop:spawnVehicle', function(v) + local car = GetHashKey(v) + local playerPed = GetPlayerPed(-1) + local playerCoords = GetEntityCoords(playerPed) + local lastVehicle = GetPlayersLastVehicle() + + if playerPed and playerPed ~= -1 then + if DoesEntityExist(lastVehicle) then + DeleteVehicle(lastVehicle) + end + + RequestModel(car) + while not HasModelLoaded(car) do + Citizen.Wait(0) + end + + local veh = CreateVehicle(car, playerCoords, true, true) + local id = NetworkGetNetworkIdFromEntity(veh) + SetNetworkIdCanMigrate(id, true) + + TaskWarpPedIntoVehicle(playerPed, veh, -1) + SetEntityAsMissionEntity(veh, true, true) + SetVehicleHasBeenOwnedByPlayer(veh, true) + SetVehRadioStation(veh, "OFF") + + FreezeEntityPosition(GetPlayerPed(-1), false) + SetEntityVisible(GetPlayerPed(-1), true) + end +end) \ No newline at end of file diff --git a/int/weapons.lua b/int/weapons.lua index 624f6e2..1206fc6 100644 --- a/int/weapons.lua +++ b/int/weapons.lua @@ -1,7 +1,6 @@ local weaponPed = {} local weaponsLoaded = false local WeaponPurchased = false - local weapon_peds = { {model="s_m_m_ammucountry", voice="S_M_M_AMMUCOUNTRY_WHITE_MINI_01", x=1692.733, y=3761.895, z=34.705, a=218.535}, {model="s_m_m_ammucountry", voice="S_M_M_AMMUCOUNTRY_WHITE_MINI_01", x=-330.933, y=6085.677, z=31.455, a=207.323}, @@ -38,8 +37,8 @@ Citizen.CreateThread(function() SetBlockingOfNonTemporaryEvents(weaponPed, true) SetPedFleeAttributes(weaponPed, 0, 0) SetEntityInvincible(weaponPed, true) - -- Annimations SetAmbientVoiceName(weaponPed, v.voice) + TaskPlayAnim(weaponPed,"random@shop_gunstore","_idle", 8.0, 0.0, -1, 1, 0, 0, 0, 0) end weaponsLoaded = true diff --git a/int/weapons_s.lua b/int/weapons_s.lua deleted file mode 100644 index cdf831e..0000000 --- a/int/weapons_s.lua +++ /dev/null @@ -1,50 +0,0 @@ -RegisterServerEvent('fivem-stores:weapon-menu:item-selected') -AddEventHandler('fivem-stores:weapon-menu:item-selected', function(s) - local src = source - TriggerEvent('es:getPlayerFromId', src, function(user) - local player = user.getIdentifier() - if user.getMoney() >= tonumber(s.Price) then - TriggerClientEvent('fivem-stores:giveWeapon', src, s.Name, s.FriendlyName) - if(database.driver == "couchdb") then - TriggerEvent('es:exposeDBFunctions', function(db) - db.getDocumentByRow('fs_freemode', 'identifier', player, function(freemodeuser) - local myWeapons = false - for k,v in ipairs(freemodeuser.weapons) do - if (v == s.Name) then - myWeapons = true - end - end - - if not myWeapons then - freemodeuser.weapons[#freemodeuser.weapons+1] = s.Name - db.updateDocument('fs_freemode', freemodeuser._id, {weapons = freemodeuser.weapons}, function() end) - user.removeMoney(tonumber(s.Price)) - end - end) - end) - elseif(database.driver == "mysql-async") then - MySQL.Async.fetchScalar("SELECT weapons FROM fs_freemode WHERE identifier = '"..player.."'", { ['@identifier'] = player}, function (weapons) - if(weapons) then - local arrayWeapons = json.decode(weapons) - local myWeapons = false - for k,v in ipairs(arrayWeapons) do - if (v == s.Name) then - print(k,v) - myWeapons = true - end - end - - if not myWeapons then - arrayWeapons[#arrayWeapons+1] = s.Name - local update = json.encode(arrayWeapons) - MySQL.Async.execute("UPDATE fs_freemode SET weapons='"..update.."' WHERE identifier = '"..player.."'", {}) - user.removeMoney(tonumber(s.Price)) - end - end - end) - else - print("Error : database driver not recognized!") - end - end - end) -end) diff --git a/lang/en.lua b/lang/en.lua index ea49383..d361a76 100644 --- a/lang/en.lua +++ b/lang/en.lua @@ -1,6 +1,12 @@ i18n.importData("en", { welcome_message = "Welcome~g~ ", + buy = "Buy", + no = "No", categories = "Categories", + confirm = "Confirm", + exit = "Exit", + options = "Options", + more_cash_needed = "You need more cash", enter_bunker_workshop = "Press ~INPUT_CONTEXT~ to access the Bunker Vehicle Workshop.", bunker_vehicle_workshop_title = "Bunker Vehicle Workshop", enter_bunker = "Press ~INPUT_CONTEXT~ to enter the bunker", @@ -9,8 +15,13 @@ i18n.importData("en", { exit_office = "Press ~INPUT_CONTEXT~ to exit the office", enter_moc = "Press ~INPUT_CONTEXT~ to enter the MOC", exit_moc = "Press ~INPUT_CONTEXT~ to exit the MOC", + enter_vehicleshop = "Press ~INPUT_CONTEXT~ to browse vehicles", enter_warehouse = "Press ~INPUT_CONTEXT~ to enter the warehouse", exit_warehouse = "Press ~INPUT_CONTEXT~ to exit the warehouse", browse_weapons = "Press ~INPUT_CONTEXT~ to browse weapons", - weapons_purchased = "Weapon Purchased" + weapons_purchased = "Weapon Purchased", + vehicles_shop_title = "Vehicle Shop", + vehicle_shop_confirmation = "Purchase confirmation", + vehicle_inventory = "Vehicle Inventory", + vehicles_owned = "Owned vehicles", }) \ No newline at end of file diff --git a/libs/db.lua b/libs/db.lua index b17e58d..743c124 100644 --- a/libs/db.lua +++ b/libs/db.lua @@ -26,11 +26,12 @@ local auth = toBase64Enc(pbytes) if(database.driver == "couchdb") then TriggerEvent('es:exposeDBFunctions', function(DB) db.createDocument = DB.createDocument - DB.createDatabase('fs_freemode', function()end) + DB.createDatabase('fs_freemode', function() end) + DB.createDatabase('es_vehshop', function() end) end) else MySQL.ready(function() - MySQL.Async.execute("CREATE TABLE IF NOT EXISTS fs_freemode (identifier varchar(255), weapons json DEFAULT NULL)") + MySQL.Async.execute("CREATE TABLE IF NOT EXISTS fs_freemode (identifier varchar(255), vehicles text, weapons text)") end) end @@ -47,7 +48,6 @@ function db.getUser(identifier, callback) end, "POST", json.encode(qu), {["Content-Type"] = 'application/json', Authorization = "Basic " .. auth}) elseif(database.driver == "mysql-async") then - print("Loading data from mysql-server for: " .. identifier) MySQL.Async.fetchAll("SELECT * FROM fs_freemode WHERE identifier = '"..identifier.."'", { ['@identifier'] = identifier}, function (result) if (result) then local user = { @@ -60,7 +60,7 @@ function db.getUser(identifier, callback) end end) else - print("Error: database driver not recognized!") + print("Error: database driver is not recognized!") end end @@ -69,22 +69,19 @@ AddEventHandler('es:newPlayerLoaded', function(source, user) local src = source if(database.driver == "couchdb") then TriggerEvent('es:exposeDBFunctions', function(db) - db.createDocument('fs_freemode', {identifier = user.get("identifier"), weapons = {}}, function() - end) + db.createDocument('fs_freemode', {identifier = user.get("identifier"), weapons = {"WEAPON_PISTOL", "WEAPON_KNIFE"}}, function() end) + db.createDocument('es_vehshop', {identifier = user.get("identifier"), personalvehicles = {}}, function() end) end) created[source] = true elseif(database.driver == "mysql-async") then local identifier = tostring(user.get("identifier")) - print("Checking if player exists " ..identifier) - MySQL.Async.fetchScalar("SELECT identifier FROM fs_freemode WHERE identifier = '"..identifier.."'", { ['@identifier'] = identifier}, function (userIdentifier) if(userIdentifier == nil) then - print("Adding identifier " .. identifier) - MySQL.Async.execute("INSERT INTO fs_freemode (`identifier`, `weapons`) VALUES (@identifier, @weapons)", { ['@identifier'] = identifier, ['@weapons'] = json.encode({"WEAPON_PISTOL", "WEAPON_KNIFE"}), }) + MySQL.Async.execute("INSERT INTO fs_freemode (`identifier`, `vehicles`, `weapons`) VALUES (@identifier, @vehicles, @weapons)", { ['@identifier'] = identifier, ['@vehicles'] = json.encode({}), ['@weapons'] = json.encode({"WEAPON_PISTOL", "WEAPON_KNIFE"})}) end end) created[source] = true else - print("Error : driver not recognize !") + print("Error : database driver is not recognized!") end end) diff --git a/libs/events.lua b/libs/events.lua index a370408..19a8864 100644 --- a/libs/events.lua +++ b/libs/events.lua @@ -18,6 +18,13 @@ AddEventHandler("fs_freemode:initStats", function(cash) StatSetInt("MP0_WALLET_BALANCE", cash, true) end) +RegisterNetEvent("fs_freemode:DisplayWanted") +AddEventHandler("fs_freemode:DisplayWanted", function(netid) + gamerTagId = CreateMpGamerTag(GetPlayerPed(netid), "", false, false, "", 0) + SetMpGamerTagVisibility(gamerTagId, 4, true) + SetMpGamerTagAlpha(gamerTagId, 4, 240) +end) + RegisterNetEvent("fs_freemode:notify") AddEventHandler("fs_freemode:notify", function(icon, type, color, sender, title, text) Citizen.InvokeNative(0x92F0DA1E27DB96DC, tonumber(color)) diff --git a/libs/scoreboard.lua b/libs/scoreboard.lua index 3ffda57..5894fbc 100644 --- a/libs/scoreboard.lua +++ b/libs/scoreboard.lua @@ -22,26 +22,26 @@ local Settings = { local function DrawPlayerList() local players = {} for i = 0, 31 do - if NetworkIsPlayerActive( i ) then - table.insert( players, i ) + if NetworkIsPlayerActive(i) then + table.insert(players, i) end end --Top bar - DrawRect( 0.11, 0.025, 0.2, 0.03, 0, 0, 0, 220 ) + DrawRect(0.11, 0.025, 0.2, 0.03, 0, 0, 0, 220) --Top bar title - SetTextFont( 4 ) - SetTextProportional( 0 ) - SetTextScale( 0.45, 0.45 ) - SetTextColour( 255, 255, 255, 255 ) - SetTextDropShadow( 0, 0, 0, 0, 255 ) - SetTextEdge( 1, 0, 0, 0, 255 ) - - SetTextEntry( "STRING" ) - AddTextComponentString( "Players: " .. #players ) + SetTextFont(4) + SetTextProportional(0) + SetTextScale(0.45, 0.45 ) + SetTextColour(255, 255, 255, 255) + SetTextDropShadow( 0, 0, 0, 0, 255) + SetTextEdge(1, 0, 0, 0, 255) + + SetTextEntry("STRING") + AddTextComponentString("Players: " .. #players) DrawText( 0.015, 0.007 ) - for k, v in pairs( players ) do + for k, v in pairs(players) do local r local g local b @@ -57,12 +57,12 @@ local function DrawPlayerList() end --Row BG - DrawRect( 0.11, 0.025 + ( k * 0.03 ), 0.2, 0.03, r, g, b, 220 ) + DrawRect(0.11, 0.025 + ( k * 0.03 ), 0.2, 0.03, r, g, b, 220) --Name Label - SetTextFont( 4 ) - SetTextScale( 0.45, 0.45 ) - SetTextColour( 255, 255, 255, 255 ) + SetTextFont(4) + SetTextScale(0.45, 0.45) + SetTextColour(255, 255, 255, 255) SetTextEntry( "STRING" ) if Settings["PlayerID"] then @@ -80,7 +80,7 @@ local function DrawPlayerList() if NetworkIsPlayerTalking(v) then transparency = 255 end - DrawSprite( "mplobby", "mp_charcard_stats_icons9", 0.2, 0.024 + ( k * 0.03 ), 0.015, 0.025, 0, 255, 255, 255, transparency ) + DrawSprite("mplobby", "mp_charcard_stats_icons9", 0.2, 0.024 + ( k * 0.03 ), 0.015, 0.025, 0, 255, 255, 255, transparency) end --Wanted Stars diff --git a/server.lua b/server.lua index 3cd868b..75a6de9 100644 --- a/server.lua +++ b/server.lua @@ -1,4 +1,12 @@ -local version = 'v1.3' +local carList = {} +local personalvehicles = {} +local version = 'v1.3.1' + +if Setup.SetTextChatEnabled then + StopResource('chat') +else + StartResource('chat') +end TriggerEvent("es:setDefaultSettings", { debugInformation = false, @@ -11,41 +19,208 @@ TriggerEvent("es:setDefaultSettings", { AddEventHandler('es:playerLoaded', function(source, player) player.displayMoney(player.getMoney()) + + if(database.driver == "couchdb") then + TriggerEvent('es:exposeDBFunctions', function(db) + db.getDocumentByRow('es_vehshop', 'identifier', player.get('identifier'), function(vehshopuser) + if(vehshopuser)then + personalvehicles = vehshopuser.personalvehicles + else + personalvehicles = {} + end + + TriggerClientEvent('es_vehshop:myVehicles', source, personalvehicles) + end) + end) + else + local identifier = player.get('identifier') + MySQL.Async.fetchScalar("SELECT vehicles FROM fs_freemode WHERE identifier = '"..identifier.."'", { ['@identifier'] = identifier}, function (vehicles) + if vehicles then + myVehicles = json.decode(vehicles) + personalvehicles = myVehicles + else + personalvehicles = {} + end + TriggerClientEvent('es_vehshop:myVehicles', source, personalvehicles) + end) + + end end) RegisterServerEvent("fs_freemode:playerSpawned") AddEventHandler("fs_freemode:playerSpawned", function(spawn) - TriggerEvent('fs_freemode:loadWeapons', source) + TriggerEvent('fs_freemode:loadInventory', source) end) -RegisterServerEvent("fs_freemode:loadWeapons") -AddEventHandler("fs_freemode:loadWeapons", function(source) -local src = source +RegisterServerEvent("fs_freemode:loadInventory") +AddEventHandler("fs_freemode:loadInventory", function(source) + local src = source TriggerEvent('es:getPlayerFromId', src, function(user) db.getUser(user.getIdentifier(), function(freemodeuser) for i=1, #freemodeuser.weapons do TriggerClientEvent('fs_freemode:spawnWeapons', source, freemodeuser.weapons[i]) end end) + + if(database.driver == "couchdb") then + TriggerEvent('es:exposeDBFunctions', function(db) + db.getDocumentByRow('es_vehshop', 'identifier', user.get('identifier'), function(vehshopuser) + if(vehshopuser)then + personalvehicles = vehshopuser.personalvehicles + else + personalvehicles = {} + end + TriggerClientEvent('es_vehshop:myVehicles', src, personalvehicles) + end) + end) + else + MySQL.Async.fetchScalar("SELECT vehicles FROM fs_freemode WHERE identifier = '"..user.get('identifier').."'", { ['@identifier'] = identifier}, function (vehicles) + if vehicles then + local myVehicles = json.decode(vehicles) + personalvehicles = myVehicles + else + personalvehicles = {} + end + TriggerClientEvent('es_vehshop:myVehicles', source, personalvehicles) + end) + end end) end) RegisterServerEvent('fs_freemode:missionComplete') AddEventHandler('fs_freemode:missionComplete', function(total) TriggerEvent("es:getPlayerFromId", source, function(user) - user.addMoney(total) + user.addMoney(tonumber(total)) end) end) + +RegisterServerEvent('fivem-stores:weapon-menu:item-selected') +AddEventHandler('fivem-stores:weapon-menu:item-selected', function(s) + local src = source + TriggerEvent('es:getPlayerFromId', src, function(user) + local player = user.getIdentifier() + if user.getMoney() >= tonumber(s.Price) then + TriggerClientEvent('fivem-stores:giveWeapon', src, s.Name, s.FriendlyName) + if(database.driver == "couchdb") then + TriggerEvent('es:exposeDBFunctions', function(db) + db.getDocumentByRow('fs_freemode', 'identifier', player, function(freemodeuser) + local myWeapons = false + for k,v in ipairs(freemodeuser.weapons) do + if (v == s.Name) then + myWeapons = true + end + end + + if not myWeapons then + freemodeuser.weapons[#freemodeuser.weapons+1] = s.Name + db.updateDocument('fs_freemode', freemodeuser._id, {weapons = freemodeuser.weapons}, function() end) + user.removeMoney(tonumber(s.Price)) + end + end) + end) + elseif(database.driver == "mysql-async") then + MySQL.Async.fetchScalar("SELECT weapons FROM fs_freemode WHERE identifier = '"..player.."'", { ['@identifier'] = player}, function (weapons) + if(weapons) then + local arrayWeapons = json.decode(weapons) + local myWeapons = false + + for k,v in ipairs(arrayWeapons) do + if (v == s.Name) then + print(k,v) + myWeapons = true + end + end + + if not myWeapons then + arrayWeapons[#arrayWeapons+1] = s.Name + local update = json.encode(arrayWeapons) + MySQL.Async.execute("UPDATE fs_freemode SET weapons='"..update.."' WHERE identifier = '"..player.."'", {}) + user.removeMoney(tonumber(s.Price)) + end + end + end) + else + print("Error: No database driver has been set in the server config.") + end + end + end) +end) + +RegisterServerEvent('CheckMoneyForVeh') +AddEventHandler('CheckMoneyForVeh', function(vehicle, price) + local Source = source + TriggerEvent('es:getPlayerFromId', Source, function(user) + local player = user.getIdentifier() + + if user.getMoney() >= tonumber(price) then + user.removeMoney(tonumber(price)) + personalvehicles[#personalvehicles + 1] = vehicle + TriggerClientEvent('es_vehshop:myVehicles', Source, personalvehicles) + TriggerClientEvent('FinishMoneyCheckForVeh', Source, "valid") + + if database.driver == "couchdb" then + TriggerEvent('es:exposeDBFunctions', function(db) + db.getDocumentByRow('es_vehshop', 'identifier', user.get('identifier'), function(vehshopuser) + local myVehicles = false + + for k,v in ipairs(vehshopuser.personalvehicles) do + if (v == vehicle) then + myVehicles = true + + end + end + + if not myVehicles then + vehshopuser.personalvehicles[#vehshopuser.personalvehicles+1] = vehicle + db.updateDocument('es_vehshop', vehshopuser._id, {personalvehicles = vehshopuser.personalvehicles}, function() end) + end + end) + end) + elseif database.driver == "mysql-async" then + MySQL.Async.fetchScalar("SELECT vehicles FROM fs_freemode WHERE identifier = '"..player.."'", { ['@identifier'] = player}, function (vehicles) + if vehicles then + arrayVehicles = json.decode(vehicles) + for k,v in ipairs(arrayVehicles) do + if (v == vehicle) then + vehicleExists = true + end + end + + if not vehicleExists then + arrayVehicles[#arrayVehicles+1] = vehicle + local update = json.encode(arrayVehicles) + MySQL.Async.execute("UPDATE fs_freemode SET vehicles='"..update.."' WHERE identifier = '"..player.."'", {}) + else + TriggerClientEvent('FinishMoneyCheckForVeh', Source, "exists") + end + end + end) + else + print("Error: No database driver has been set in the server config.") + end + else + TriggerClientEvent('FinishMoneyCheckForVeh', Source, "invalid") + end + end) +end) + PerformHttpRequest("https://updates.fivem-scripts.org/verify/" .. GetCurrentResourceName(), function(err, rData, headers) if err == 404 or err == 403 then - print("\nUPDATE ERROR: your version could not be verified\n") + print("\n***************************************************************************************************************") + print("\nFREEMODE UPDATE ERROR: your version could not be verified.\n") + print("Verify that the folder in your resources directory is named fs_freemode.") + print("\n***************************************************************************************************************") + + StopResource(GetCurrentResourceName()) else local vData = json.decode(rData) if vData.version ~= version then - print("\n************************************************************************************************") + print("\n***************************************************************************************************************") print("You are running an outdated version of " .. GetCurrentResourceName()) - print("************************************************************************************************\n") + print("Please get the latest version from our GitHub page https://github.com/FiveM-Scripts/fs_freemode/releases/latest") + print("\n***************************************************************************************************************") + end end end, "GET", "", {["Content-Type"] = 'application/json'})