• /drop command?
    3 replies, posted
I'm currently working on a /drop command for my server. I don't like how the default player:DropWeapon() works, so that's why. How would I go about doing this? Here's what I think [QUOTE]1) Get the players weapon 2) If it's not in the list of weapons not to be dropped then continue 3) Remove the players current weapon (forget to mention it's stored in a var from the begining) 4) Use that stored weapon class to then create an entity using ents.Create on the ground in front of the player[/QUOTE] Is this a good way to do it, or am I overthinking this? [B]EDIT:[/B] Also, if this is the right way, how would I get the vector on the ground 1ish meters in front of the player, taking which way they're looking into account?
How about using that. [url]https://wiki.garrysmod.com/page/Player/DropWeapon[/url]
[QUOTE=deinemudda32;49864659]How about using that. [url]https://wiki.garrysmod.com/page/Player/DropWeapon[/url][/QUOTE] [QUOTE=Austin1346;49864597] I don't like how the default player:DropWeapon() works, so that's why. [/QUOTE]
[lua] hook.Add("PlayerSay", "DropWeaponAMK", function(ply, text, public) if (string.lower(text) == "/getaway") then if IsValid(ply:GetActiveWeapon()) then local shit = {} shit.start = ply:GetShootPos() shit.endpos = ply:GetShootPos() + (ply:GetAimVector() * 90) shit.filter = ply shit.mins = Vector(-15, -5, 0) shit.maxs = Vector(15, 5, 5) local shittrace = util.TraceHull(shit) local shitent = ents.Create("prop_physics") if shittrace.Hit then shitent:SetPos(shittrace.HitPos) else shitent:SetPos(shit.endpos) end if !shitent:IsInWorld() then shitent:SetPos(ply:GetPos()) end shitent:SetAngles(ply:GetAngles()) shitent:SetModel(ply:GetActiveWeapon().WorldModel) shitent.Classy1abitch = ply:GetActiveWeapon().ClassName shitent:Spawn() ply:StripWeapon(ply:GetActiveWeapon().ClassName) end return "" end end) hook.Add("PlayerUse", "TakeWeaponAMK", function(ply, ent) if ent.Classy1abitch and !ent.nextUsage then if !ply.nextSexyWeapon or ply.nextSexyWeapon < CurTime() then ent.nextUsage = true ply.nextSexyWeapon = CurTime() + 0.5 ply:Give(ent.Classy1abitch) ent:Remove() end end end) [/lua]
Sorry, you need to Log In to post a reply to this thread.