How to get usergroup on client?

Hello,

I´m looking for a option how to get the usergroup of someone in the client. I tried it with a Callback but I dont get it to work.

This is the Callback:

> ESX.RegisterServerCallback("menu:checkAdmin", function(source, cb)
>     local xPlayer = ESX.GetPlayerFromId(source)
>              
>     if xPlayer.getGroup() == 'admin' or 'mod' then
>         cb(true)
>     else
>         cb(false)
>     end
> end)

This is the client:

> ESX.TriggerServerCallback('menu:checkAdmin', function(group)
>         RageUI.Button("Admin-Menu", "Select action", {}, true, {}, admin2Menu)
> end)

Have someone an idea?

I don’t know exactly what you want to script, but that’s how I do it:

Client:

RegisterCommand("spawnAdminCar", function()
   TriggerServerEvent("spawnVehicle")
end)



RegisterNetEvent("client_spawnVehicle")
AddEventHandler("client_spawnVehicle", function()
	local playerPed = PlayerPedId()

	ESX.Game.SpawnVehicle("adder", 0,0,0, 90, function(vehicle) 
		TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
	end)
end)

and this in Server script:

RegisterNetEvent("spawnVehicle")
AddEventHandler("spawnVehicle", function()
    local _source = source
    local xPlayer  = ESX.GetPlayerFromId(_source)
    local xPlayerGroup = xPlayer.getGroup()

    if xPlayer ~= nil then

        if xPlayerGroup == "superadmin" then
            TriggerClientEvent("client_spawnVehicle", source)
        end
    end
end)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.