Commands Just for Admins/Gods

Hi,

I have a simple Quesetion

RegisterCommand('npc', function(source, args)
    local ped = PlayerPedId()
    local model = GetHashKey(args[1])
    SetEntityInvincible(ped, true)
    if IsModelInCdimage(model) and IsModelValid(model) then
        LoadPlayerModel(model)
        SetPlayerModel(PlayerId(), model)
        if isPedAllowedRandom(args[1]) then
            SetPedRandomComponentVariation(ped, true)
        end
        SetModelAsNoLongerNeeded(model)
    end
    SetEntityInvincible(ped, false)
end)

I have this little code and it works fine it changes me into a Ped model i wish and if i relog i change back again so my question is
is it possible to make this Command just für authorized person Like admin or gods and how can i do it

Hey there,

Check our documentation below for more information on your question.

1 Like
--NPC--
QBCore.Commands.Add('npc','change npc model', {}, false, function(source)
	RegisterCommand('npc', function(source, args)
		local ped = PlayerPedId()
		local model = GetHashKey(args[1])
		SetEntityInvincible(ped, true)
		if IsModelInCdimage(model) and IsModelValid(model) then
			LoadPlayerModel(model)
			SetPlayerModel(PlayerId(), model)
			if isPedAllowedRandom(args[1]) then
				SetPedRandomComponentVariation(ped, true)
			end
			SetModelAsNoLongerNeeded(model)
		end
		SetEntityInvincible(ped, false)
	end)
		end, 'wl')

is it correct like this?

qb-adminmenu has this already using /setmodel and using /reloadskin or /refreshskin whatever clothing script you use, will reset it back to normal.

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