Hi, so I am trying to make a pretty simple script for NativeUI. Basically, I draw interactable 3D text in 2 locations. 1 in the police station and 1 at the prison. Then, whenever you hit E near the text it will bring up a menu based on which one you are at. If you are at the police station, it will bring up a menu that says SASP on it. If you are at the prison, it will bring up one that says BCSO on it. Problem is, whenever I try to access the menu at the prison it doesn’t work. And when I access the one at the PD it loads both of them at the same time.
Here is my code:
BCSO Menu
--[Functions]--
function Draw3DText(x, y, z, text, scale)
local onScreen, _x, _y = World3dToScreen2d(x, y, z)
local pX, pY, pZ = table.unpack(GetGameplayCamCoords())
SetTextScale(scale, scale)
SetTextFont(4)
SetTextProportional(1)
SetTextEntry("STRING")
SetTextCentre(true)
SetTextColour(255, 255, 255, 215)
AddTextComponentString(text)
DrawText(_x, _y)
local factor = (string.len(text)) / 700
DrawRect(_x, _y + 0.0150, 0.06 + factor, 0.03, 41, 11, 41, 100)
end
function notify(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end
function giveWeapon(hash)
GiveWeaponToPed(GetPlayerPed(-1), GetHashKey(hash), 150, false, false)
end
--[Menus and Items]--
_menuPool = NativeUI.CreatePool()
bcsoarmoryMenu = NativeUI.CreateMenu("Armory", "~b~Blaine County Sheriff's Office")
_menuPool:Add(bcsoarmoryMenu)
function bcsoarmoryItems(menu)
local flashlightItem = NativeUI.CreateItem("Flashlight", "Equip ~b~flashlight?")
local nightstickItem = NativeUI.CreateItem("Nightstick", "Equip ~b~nightstick?")
local taserItem = NativeUI.CreateItem("Taser", "Equip ~b~taser?")
local pistolItem = NativeUI.CreateItem("Pistol", "Equip ~b~pistol?")
local cpistolItem = NativeUI.CreateItem("Combat Pistol", "Equip ~b~combat pistol?")
local smgItem = NativeUI.CreateItem("SMG", "Equip ~b~SMG?")
local assualtrifleItem = NativeUI.CreateItem("Assault Rifle", "Equip ~b~assault rifle?")
local shotgunItem = NativeUI.CreateItem("Shotgun", "Equip ~b~shotgun?")
local sniperItem = NativeUI.CreateItem("Sniper Rifle", "Equip ~b~sniper rifle?")
menu:AddItem(flashlightItem)
menu:AddItem(nightstickItem)
menu:AddItem(taserItem)
menu:AddItem(pistolItem)
menu:AddItem(cpistolItem)
menu:AddItem(smgItem)
menu:AddItem(assualtrifleItem)
menu:AddItem(shotgunItem)
menu:AddItem(sniperItem)
menu.OnItemSelect = function(sender, item, index)
if item == flashlightItem then
giveWeapon("WEAPON_FLASHLIGHT")
notify("Equiped ~g~Flashlight")
elseif item == nightstickItem then
giveWeapon("WEAPON_NIGHTSTICK")
notify("Equiped ~g~Nightstick")
elseif item == taserItem then
giveWeapon("WEAPON_STUNGUN")
notify("Equiped ~g~Taser")
elseif item == pistolItem then
giveWeapon("WEAPON_PISTOL")
notify("Equiped ~g~Pistol")
elseif item == cpistolItem then
giveWeapon("WEAPON_COMBATPISTOL")
notify("Equiped ~g~Combat Pistol")
elseif item == smgItem then
giveWeapon("WEAPON_SMG")
notify("Equiped ~g~SMG")
elseif item == assualtrifleItem then
giveWeapon("WEAPON_CARBINERIFLE")
notify("Equiped ~g~Assault Rifle")
elseif item == shotgunItem then
giveWeapon("WEAPON_PUMPSHOTGUN")
notify("Equiped ~g~Shotgun")
elseif item == sniperItem then
giveWeapon("WEAPON_SNIPERRIFLE")
notify("Equiped ~g~Sniper Rifle")
end
end
end
Citizen.CreateThread(function()
local ply = GetPlayerPed(-1)
local plyloc = GetEntityCoords(ply)
local textloc = vector3(1848.68, 2600.35, 45.50)
while true do
Citizen.Wait(0)
_menuPool:MouseControlsEnabled (false);
_menuPool:MouseEdgeEnabled (false);
_menuPool:ControlDisablingEnabled(false);
_menuPool:ProcessMenus()
if Vdist2(GetEntityCoords(PlayerPedId(), false), textloc) < 15 then
Draw3DText(textloc.x, textloc.y, textloc.z, "[E] - Armory", 0.4)
if IsControlJustReleased(0, 38) and Vdist2(GetEntityCoords(PlayerPedId()), textloc) < 5 then
bcsoarmoryMenu:Visible(not bcsoarmoryMenu:Visible())
end
end
end
end)
bcsoarmoryItems(bcsoarmoryMenu)
SASP Menu
--[Functions]--
function Draw3DText(x, y, z, text, scale)
local onScreen, _x, _y = World3dToScreen2d(x, y, z)
local pX, pY, pZ = table.unpack(GetGameplayCamCoords())
SetTextScale(scale, scale)
SetTextFont(4)
SetTextProportional(1)
SetTextEntry("STRING")
SetTextCentre(true)
SetTextColour(255, 255, 255, 215)
AddTextComponentString(text)
DrawText(_x, _y)
local factor = (string.len(text)) / 700
DrawRect(_x, _y + 0.0150, 0.06 + factor, 0.03, 41, 11, 41, 100)
end
function notify(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end
function giveWeapon(hash)
GiveWeaponToPed(GetPlayerPed(-1), GetHashKey(hash), 150, false, false)
end
--[Menus and Items]--
_menuPool = NativeUI.CreatePool()
sasparmoryMenu = NativeUI.CreateMenu("Armory", "~b~San Andreas State Police")
_menuPool:Add(sasparmoryMenu)
function sasparmoryItems(menu)
local flashlightItem = NativeUI.CreateItem("Flashlight", "Equip ~b~flashlight?")
local nightstickItem = NativeUI.CreateItem("Nightstick", "Equip ~b~nightstick?")
local taserItem = NativeUI.CreateItem("Taser", "Equip ~b~taser?")
local pistolItem = NativeUI.CreateItem("Pistol", "Equip ~b~pistol?")
local cpistolItem = NativeUI.CreateItem("Combat Pistol", "Equip ~b~combat pistol?")
local smgItem = NativeUI.CreateItem("SMG", "Equip ~b~SMG?")
local assualtrifleItem = NativeUI.CreateItem("Assault Rifle", "Equip ~b~assault rifle?")
local shotgunItem = NativeUI.CreateItem("Shotgun", "Equip ~b~shotgun?")
local sniperItem = NativeUI.CreateItem("Sniper Rifle", "Equip ~b~sniper rifle?")
menu:AddItem(flashlightItem)
menu:AddItem(nightstickItem)
menu:AddItem(taserItem)
menu:AddItem(pistolItem)
menu:AddItem(cpistolItem)
menu:AddItem(smgItem)
menu:AddItem(assualtrifleItem)
menu:AddItem(shotgunItem)
menu:AddItem(sniperItem)
menu.OnItemSelect = function(sender, item, index)
if item == flashlightItem then
giveWeapon("WEAPON_FLASHLIGHT")
notify("Equiped ~g~Flashlight")
elseif item == nightstickItem then
giveWeapon("WEAPON_NIGHTSTICK")
notify("Equiped ~g~Nightstick")
elseif item == taserItem then
giveWeapon("WEAPON_STUNGUN")
notify("Equiped ~g~Taser")
elseif item == pistolItem then
giveWeapon("WEAPON_PISTOL")
notify("Equiped ~g~Pistol")
elseif item == cpistolItem then
giveWeapon("WEAPON_COMBATPISTOL")
notify("Equiped ~g~Combat Pistol")
elseif item == smgItem then
giveWeapon("WEAPON_SMG")
notify("Equiped ~g~SMG")
elseif item == assualtrifleItem then
giveWeapon("WEAPON_CARBINERIFLE")
notify("Equiped ~g~Assault Rifle")
elseif item == shotgunItem then
giveWeapon("WEAPON_PUMPSHOTGUN")
notify("Equiped ~g~Shotgun")
elseif item == sniperItem then
giveWeapon("WEAPON_SNIPERRIFLE")
notify("Equiped ~g~Sniper Rifle")
end
end
end
Citizen.CreateThread(function()
local ply = GetPlayerPed(-1)
local plyloc = GetEntityCoords(ply)
local textloc = vector3(452.65, -980.02, 31.43)
while true do
Citizen.Wait(0)
_menuPool:MouseControlsEnabled (false);
_menuPool:MouseEdgeEnabled (false);
_menuPool:ControlDisablingEnabled(false);
_menuPool:ProcessMenus()
if Vdist2(GetEntityCoords(PlayerPedId(), false), textloc) < 15 then
Draw3DText(textloc.x, textloc.y, textloc.z, "[E] - Armory", 0.4)
if IsControlJustReleased(0, 38) and Vdist2(GetEntityCoords(PlayerPedId()), textloc) < 5 then
sasparmoryMenu:Visible(not sasparmoryMenu:Visible())
end
end
end
end)
sasparmoryItems(sasparmoryMenu)
Keep in mind that I get no console errors when I run and interact with the script.