Spawning Ent From Derma Menu In Front Of Player

Title really says it all…

Step 1. Make a concommand serverside that spawn an entity in front of the player.
Step 2. Make a derma menu.
Step 3. Put a button inside this derma menu with an DoClick of RunConsoleCommand(“your_command”), with “your_command” being the command that spawns the entity.
Step 4. Close the office and go out for a few beers to celebrate

I know the setup <_< i just need to find the actual code for like the position of the ent to spawn at cause right now it spawns at the center of the map

ply:GetEyeTrace().HitPos

Try spawning it there

That snippet, will obviously spawn it where the player is looking.


entity:SetPos(ply:GetPos() + Vector(x,y,z)

Well infront can be twisted to be where theyre looking, which is basically infont of them.

Yea, well - HitPos.

[lua]function createEntityAtPlayerFront(pl,class,dist)
local e = ents.Create(class)
e:SetPos(pl:GetShootPos() + pl:GetForward() * dist)
return e
end[/lua]

That’s a basic example.

Entoros wouldn’t you want to use p1:GetPos() and then multiply it by the second part?
So like:
e:SetPos(pl:GetPos() * (pl:GetForward() * dist) )

No, it’s just vector math. Plus, I don’t think there’s multiplier support for vectors. You start at the player’s shoot pos (so it’s not stuck in the ground), and then you add their forward vector times however far forward it should be.