So I recently started my own dedicated server to play with friends and there are one or two small problems.
Problem 1) Props cannot use doors at any point. I think this is due to a line in the init.lua which says props can't use any items. The Code will be down below and I was hoping somebody could write in an exception to make it so that doors are the exception for the Use function on the props team.
Problem 2) Whenever somebody dies in a team with 2 or more people, they have the option to respawn by left clicking and i don't know what's causing it or how to solve it. Any help would be appreciated.
Code for Problem 1)
-- Called when a player tries to use an object.
function GM:PlayerUse(pl, ent)
-- Prevent dead or spectating players from being able to use stuff.
if !pl:Alive() || pl:Team() == TEAM_SPECTATOR then
return false
end
-- Props should never be able to pickup or use stuff
if pl:Team() == TEAM_PROPS then
-- If player is a Prop, set their prop entity to whatever they are looking at.
if pl:IsOnGround() && !pl:Crouching() && table.HasValue(USABLE_PROP_ENTITIES, ent:GetClass()) && ent:GetModel() then
-- Make sure the prop hasn't been banned by the server.
if table.HasValue(BANNED_PROP_MODELS, ent:GetModel()) then
pl:ChatPrint("That prop has been banned by the server.")
return false
end
-- Check for valid entity.
if ent:GetPhysicsObject():IsValid() && pl.ph_prop:GetModel() != ent:GetModel() then
-- Calculate tne entity's max health based on size. Then calculate the players's new health based on existing health percentage.
local ent_health = math.Clamp(ent:GetPhysicsObject():GetVolume() / 250, 1, 200)
local new_health = math.Clamp((pl.ph_prop.health / pl.ph_prop.max_health) * ent_health, 1, 200)
-- Set prop entity health and max health.
pl.ph_prop.health = new_health
pl.ph_prop.max_health = ent_health
-- Setup new model/texture/new collision bounds.
pl.ph_prop:SetModel(ent:GetModel())
pl.ph_prop:SetSkin(ent:GetSkin())
pl.ph_prop:SetSolid(SOLID_BSP)
-- Calculate new player hull based on prop size.
local hull_xy_max = math.Round(math.Max(ent:OBBMaxs().x, ent:OBBMaxs().y))
local hull_xy_min = hull_xy_max * -1
local hull_z = math.Round(ent:OBBMaxs().z)
-- Set player hull server side.
pl:SetHull(Vector(hull_xy_min, hull_xy_min, 0), Vector(hull_xy_max, hull_xy_max, hull_z))
pl:SetHullDuck(Vector(hull_xy_min, hull_xy_min, 0), Vector(hull_xy_max, hull_xy_max, hull_z))
pl:SetHealth(new_health)
-- Set the player hull client side so movement predictions work correctly.
umsg.Start("SetHull", pl)
umsg.Long(hull_xy_max)
umsg.Long(hull_z)
umsg.Short(new_health)
umsg.End()
end
end
return false;
end
-- Prevent the door exploit (players spamming use key).
if table.HasValue(EXPLOITABLE_DOORS, ent:GetClass()) && pl.last_door_time && pl.last_door_time + 1 > CurTime() then
return false
end
pl.last_door_time = CurTime()
return true
end
Thanks for any help
-SnowReap
Sorry, you need to Log In to post a reply to this thread.