How to add an Entity to an Map?

Well, here’s an other question:
How I can add Entities to an Map, like an ATM-thing and a Locker? Do I just need to add an command, add the Model, Frame, … and put the Position for it, or do I need something more?

I would really thank you! :slight_smile:

Sounds like you want to fake the BDB Roleplay Server

Because, y’know, no one else has ever spawned entities for their server, have they.

But only BDB calls them ATM & lockbox, and yes, ive never seen a lockbox anywhere else…

In any case. Spawn your entity with ents.Create(), set it’s position, angles and model and then spawn it. You shouldn’t need to do any more to it.

[editline]01:48PM[/editline]

He said Locker, which I have seen on several servers.

[editline]01:49PM[/editline]

Also I’ll thank you not to break my automerge while I’m trying not to get banned by Manhalis. >:

Well, I saw also Locks and ATM things in Kuro’s EvoCity RP Server :stuck_out_tongue:
Well, so I want to make my own.

To be concrete what you need is this :



NewEnt = ents.Create("prop_physics") // If you want to spawn a scripted entity, put it's class name here instead.
NewEnt:SetModel("path/to/model.mdl")
NewEnt:SetPos(Vector(0, 0, 0 ))
NewEnt:SetAngles(Angle(0, 0, 0 ))
NewEnt:Spawn() // Spawns it.


To find the position and angles that you want to input to place your entity use cl_showpos in console.

I believe he actually wants a banking system for his RP server.

Oh my god! Thank you very much, but how to add something like when you are on that Entitie that you press F2 and then a VGUI pops up with these functions… :confused:

I haven’t touched DarkRP in a while but from what I remember you’ll need to modify the function that enables using F2 on it, make the VGUI yourself and modify the code that shows up “Press F2 to do stuff” on the entity.

A simpler way would be making a scripted entity that pops the VGUI open when used.

Yes, lets not use logical names because someone else used them.

Well, I’ve tried something. Here’s my script:
[lua]
function PlayerPressedF2()
if ents.FindByClass(“ATM”) or ply:GetClass(“ATM”) then
//Show some VGUI here!
end
end
concommand.Add( “gm_showteam”, PlayerPressedF2 )
[/lua]

Whitch one of these commands is right? Or do I need to put something else in?

Neither, they don’t make any sense at all. The first command will always be interpreted as true as long as there’s at least a single “ATM” entity in the map and the second will always be interpreted as true, since player:GetClass( ) returns “player”. Now, for the correct way to do this:

[lua]function PlayerPressedF2( )
local ent = LocalPlayer( ):GetEyeTrace( ).Entity
if ( input.IsKeyDown( KEY_F2 ) and ( !window or !window:IsVisible( ) ) and ValidEntity( ent ) and ( ent:GetClass( ) == “ATM” or ent:GetClass( ) == “Locker” ) ) then
// do vgui shizzle
end
end
hook.Add( “Think”, “sdasd”, PlayerPressedF2 )[/lua]

Thank you, Overv. You really helped me!

EDIT:

So, here is it:
[lua]
function PlayerPressedF2( )
local ent = LocalPlayer( ):GetEyeTrace( ).Entity
if ( input.IsKeyDown( KEY_F2 ) and ( !window or !window:IsVisible( ) ) and ValidEntity( ent ) ) then
if ( ent:GetClass( ) == “ATM” ) then
//VGUI blabla here
elseif ( ent:GetClass( ) == “Locker” ) then
//VGUI blabla here
else
Msg(“There’s neither a Door nor an Entity!”)
end
end
end
hook.Add( “Think”, “sdasd”, PlayerPressedF2 )
[/lua]

The “Door”-Thing will be added later.