im helping dev a CWRP and cant figure out how to disable users from spawning props ive tried putting several different segments of code in several different places someone please help!
Use these hooks:
SANDBOX/PlayerSpawnedEffect
SANDBOX/PlayerSpawnedNPC
SANDBOX/PlayerSpawnedProp
SANDBOX/PlayerSpawnedRagdoll
SANDBOX/PlayerSpawnedSENT
SANDBOX/PlayerSpawnedSWEP
SANDBOX/PlayerSpawnedVehicle
Then try to return false and see if that stops the entity from spawning. If it doesn't, use Entity/Remove to remove the entity directly after it has been spawned.
local allowedGroups = {
["admin"] = true,
["superadmin"] = true,
}
local allowedJobs = {
["job1"] = true,
["job2"] = true,
}
local propLimit = 5
if SERVER then
hook.Add("PlayerSpawnProp", "Disallow_user_props", function(ply)
if not (allowedGroups[ply:GetUserGroup()] or allowedJobs[RPExtraTeams[ply:Team()].command]) then
ply:ChatPrint("You can't do that!")
return false
end
end)
hook.Add("PlayerSpawnEffect", "Disallow_user_effects", function(ply, model)
if not (allowedGroups[ply:GetUserGroup()] or allowedJobs[RPExtraTeams[ply:Team()].command]) then
ply:ChatPrint("You can't do that!")
return false
end
end)
hook.Add("PlayerSpawnedProp" , "Remove60sec", function( ply, model, ent )
if not allowedJobs[RPExtraTeams[ply:Team()].command] then return end
table.insert(ply.props, ent)
ply:ChatPrint("That prop will be removed in 15 minutes.")
timer.Simple(900, function()
if IsValid(ent) then ent:Remove() end
end)
end)
hook.Add("PlayerSpawnProp" , "PropLimit", function( ply, model )
if not allowedJobs[RPExtraTeams[ply:Team()].command] then return end
ply.props = ply.props or {}
local count = 0
for k,v in pairs(ply.props) do
if IsValid(v) then count = count+1 end
end
if count>= propLimit then
ply:ChatPrint("You've reached the prop limit!")
return false
end
end)
end
if CLIENT then
hook.Add("ContextMenuOpen", "allowedjobsrestriction", function()
if not allowedGroups[LocalPlayer():GetUserGroup()] and not table.HasValue({"moderator"}, LocalPlayer():GetUserGroup()) then return false end
end)
hook.Add("SpawnMenuOpen", "Disallow_q_menu", function()
if not (allowedGroups[LocalPlayer():GetUserGroup()] or allowedJobs[RPExtraTeams[LocalPlayer():Team()].command]) then
return false
end
end)
end
Sorry, you need to Log In to post a reply to this thread.