Im trying to make a discord donator car menu, using ace perms to spawn cars.
Code:
local SAHPVehicles = _MenuPool:AddSubMenu(MainMenu, Config.SAHPName, "Choose a pack!", true)
SAHPVehicles:SetMenuWidthOffset(Config.MenuWidth)
if SAHPVehicle1() then
local SAHP1 = NativeUI.CreateItem(Config.SAHPVehicleName1, "")
SAHPVehicles:AddItem(SAHP1)
if IsAceAllowed(source, "donatorone") then
SAHP1.Activated = function(ParentMenu, SelectedItem)
spawnCar(Config.SAHPSpawnCode1)
notify(Config.SAHPVehicleNotifcatoin1)
end
else
notify("~y~Error: ~w~You don't have the required permission to spawn this vehicle.")
end
end
I get the error:
SCRIPT ERROR: Execution of native 000000007ebb9929 in script host failed: Argument at index 0 was null.
I think the reason your code is throwing that error is because “source” isn’t defined. So in the last forum post I linked this comment:
“You’d have to query all users from the db who has the job ems and cop and then check when executing the commands if the user is actually in there, if he is execute, if not then ignore.”
you would have to replace what they’re talking about with the “job ems and cop” with your donator.
IsPlayerAceAllowed is a server side native and you’re attempting to call it from the client, you can use IsAceAllowed instead. Alternatively (assuming you’re using OneSync) create an event and have the server spawn the vehicle for the player if they pass your check, having the server spawn entities instead of the client is considered a better practice anyway.