Well I am back again...

Ok so… I got the spawn menu working, again thanks… But now when I go to spawn a prop it breaks… Lol

Here is the code for the spawn:

lastspawn = CurTime()
itemsactive = 0
local ply = LocalPlayer()
function spawnitem(prop)
	if CurTime() > lastspawn then
		lastspawn = CurTime()+10
		itemsactive = itemsactive+1
		local tr = ply:GetEyeTrace() -- tr now contains a trace object
		local ent = ents.Create("prop_physics") -- This creates our entity
		ent:SetPos(tr.HitPos) -- This positions the zombie at the place our trace hit.
		ent:SetModel(prop) -- Set model of entity
		print("You spawned a "..prop..".")
		ent:Spawn() -- This method spawns the prop
	print("You can't do that yet! Try again in "..CurTime()-lastspawn.." seconds.")

concommand.Add("pdrop_spawn", spawnitem)

And here is the code calling to the spawn function

	icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("pdrop_spawn",v) end

Now… when I try to spawn a prop it gives me

gamemodes\propfall\gamemode\cl_spawnitem.lua:8: attempt to call method 'GetEyeTrace' (a nil value)

But it had been giving me a print of “You have spawned a pdrop_spawn.” I changed how ply was passed in hoping to fix it and it started giving the different error. If there is anyone that can help I will be greatly appreciative.


I have also changed the variable ply to be global, and changed the name to me so it would not effect the rest of the game mode

Console commands have 3 arguments player, command, args.

local lSpawn = 0;
local numProps = 0
local trace
concommand.Add(“pdrop_spawn”, function( p, c, a)
if( lSpawn < CurTime() ) then
lSpawn = CurTime() + 10;
numProps = numProps + 1;
trace = p:GetEyeTrace();
local prop = ents.Create(“prop_physics”);
p:PrintMessage(3, "Please wait: “…lSpawn - CurTime()… " before trying to create another prop.”);

Thank you very much!

Now I am only missing one thing and I can’t find anything on it in the wiki… using this method is there any way to activate physics on the entity?

You didnt search for very long, did you? :wink:



I just don’t know what to look for I guess… thank you :stuck_out_tongue: