Custom/ Add-on Vehicle Spawner Menu (NativeUI Lua)
I got the inspiration from LondonStudio’s Vehicle Spawner. I was looking into it and figured why not custom make it, but using NativeUI Lua, as not many people know C#. And thus the project began.
It’s not perfect, nor will it ever be. I guarantee there will be some bugs or issues with it. I stress tested it with over 200 vehicles, using multiple sub menus, and it never broke over 1.00 ms in the resource monitor.
Features
Anti-Crash System (See below)
Right-Aligned so chat isnt in the way
Easily configurable
Credits LondonStudios for the inspiration NativeUILua for the conversion and ability to create this project.
if you want to make it where you press a key to open the menu instead of a command do the following:
Replace line 169-171 with the code below:
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
menuPool:ProcessMenus()
if IsControlJustPressed(1, 51) then
mainMenu:Visible(not mainMenu:Visible())
end
end
end)
I’m having some issues it seems. We’ve added vehicles (all following the same format). However, I have some that load and some that don’t, always with the “Couldn’t load model in time…” message. Which, leads me to two questions, I guess.
Is there a specific folder format these vehicles need to be in for the spawner to read it correctly?
Is there anyone who can dumb down, or give a brief explanation of, the code? We’re 99% sure we get how it works, where names go, we just dont’ necessarily understand what each section does, which I think makes it a little more difficult to understand the problems.
[CANT OPEN NATIVEUI]
Hi! thanks for a menu like this! But I have a Problem. I’ve watched this video https://www.youtube.com/watch?v=x1A4jZeexnU
(from BGHDDevelopment) and have done everything like he in the video but with my own car 2018 Lamborghini Aventador S Roadster [Add-On | Wipers | Auto-Spoiler | Template] - GTA5-Mods.com
My spawnmanager opens up everytime in the cfx console that opens up if you open FXServer.exe
The Problem is that my NativeUI in the server.cfg script is not opening and in the console ingame is the command /car, that 've binded, is also doing nothing. Thanks for help!
function spawnVehicle(vehicle, name)
local x,y,z = table.unpack(GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 8.0, 0.5))
local color = "~y~"
local color2 = "~r~"
local ped = GetPlayerPed(-1)
if DoesEntityExist(ped) then
vehiclehash = GetHashKey(vehicle)
RequestModel(vehiclehash)
Citizen.CreateThread(function()
local waiting = 0
while not HasModelLoaded(vehiclehash) do
waiting = waiting + 100
Citizen.Wait(100)
if waiting > 5000 then
ShowInfo(color2 .."Could not load model in time. Crash was prevented.")
break
end
end
local spawnedVeh = CreateVehicle(vehiclehash, x, y, z, GetEntityHeading(PlayerPedId())+90, 1, 0)
SetPedIntoVehicle(PlayerPedId(), spawnedVeh, -1)
SetVehicleDirtLevel(spawnedVeh, 0.0)
end)
ShowInfo("You have recieved the keys to a ".. color .. name .. ".")
Wait(1000)
return true
end
ShowInfo("All parking spots are currently full.")
return false
end
The line that says “if waiting > 500 …” change it to 1000, see if that helps. The models may be taking a long time to load.
Hey man. I installed the menu into the resource folder and it didn’t work. I’ve added the SO vehicles so far and when I typed the command, /cars, it didn’t work. Please help me by replying