Hey! I coded a car spawning scipt for a server. Now I wanted to add a permission check so not everyone can spawn a car. Only the ones with the “easyadmin” permission should be allowed to. When I tested the script on my localhost server, it said: attempt to call a nil value (global ‘IsPlayerAceAllowed’). Of course Neither the car spawns or it shows the error message that i have no perms.
This is my client.lua:
RegisterCommand('car', function(source, args, rawCommand)
local car = args[1]
local player = PlayerPedId()
local x,y,z = table.unpack(GetOffsetFromEntityInWorldCoords(player, 0.0, 2.5, 0.5))
local playerHead = GetEntityHeading(player)
if IsPlayerAceAllowed(source, "easyadmin") then --permission check
if car == nil then car = "adder" --default car (adder) when no car model is given
end
carhash = GetHashKey(car)
RequestModel(carhash)
Citizen.Wait(200)
if not HasModelLoaded(carhash) then
Notify("Fahrzeug konnte nicht geladen werden. Crash verhindert.") --Error message (Car couldn't load / wrong model name.)
else
local spawnedcar = CreateVehicle(carhash, x, y, z, playerHead)
SetVehicleNumberPlateText(spawnedcar, "MoonLife") --car plate text
SetVehicleCustomPrimaryColour(spawnedcar, 118, 32, 216) --car primary color (violette)
SetVehicleCustomSecondaryColour(spawnedcar, 118, 32, 216) --car sec color (violette)
SetVehicleNeonLightEnabled(spawnedcar, 0, true)
SetVehicleNeonLightEnabled(spawnedcar, 1, true)
SetVehicleNeonLightEnabled(spawnedcar, 2, true)
SetVehicleNeonLightEnabled(spawnedcar, 3, true)
SetVehicleNeonLightsColour(spawnedcar, 118, 32, 216) --car neon color (violette)
SetVehicleEngineOn(spawnedcar, true, true) --car spawns with turned on engine
SetPedIntoVehicle(player, spawnedcar, -1) --player automatically drives the car after spawning it
Notify(car)
Notify("Erfolgreich gespawnt!") --notification text after spawning the car
end
else
Notify("Keine Rechte!") --Error Message (Player has o permissions!)
end
end)
function Notify(msg) --Notification settings (DO NOT CHANGE!)
SetNotificationTextEntry("STRING")
AddTextComponentSubstringPlayerName(msg)
DrawNotification(false, false)
end
my fxmanifest.lua:
fx_version 'cerulean'
game 'gta5'
author 'Tonay'
description 'Car Spawner'
version '1.0.0'
client_script 'client.lua'
Please help me with that thing… I really need it. Also I really wanna use the easyadmin ace-permission and not a new one.