Maybe I am just stupid but I have another problem I can't fix...

Ok well I really hate to keep bothering you wonderful people but…

I have a command that just won’t work… Simply put I have checked the wiki and the syntax IS correct but it just won’t work… I have re-written it, I have moved it, I have double checked the file IS getting executed… I just can’t figure out what is wrong…

Here is a copy of the entire file as it stands now


lastspawn = CurTime()
itemsactive = 0
concommand.Add("pdrop_spawn", spawnitem)
function spawnitem(ply, command, 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.
		print("You spawned a ")
		print(prop[1])
		ent:SetModel(prop[1]) -- Set model of entity
		ent:Spawn() -- This method spawns the prop
		ent:Activate()
	else
	print("You can't do that yet! Try again in "..CurTime()-lastspawn.." seconds.")
	end
end

I am very, very sorry that I have to keep coming to ask soo many simple questions but this one has me dumbfounded… It worked until I added the () to ent:Activate()

I have tryed running this in single player, and on a dedicated testing server. But for some reason it just will not work… Please guys this is my first attempt at writing a game mode if anyone can help me I will be greatly, greatly appreciative!

[editline]09:12PM[/editline]

I have manually ran the function with lua_run_cl and it shows an attempted execution, it just has bugs I still have to work out but that will be later lol…

I dont see you defining “prop” anywhere.

Prop is the command argument. It is defined when the command is ran by the player. I am using the command in the spawn menu function as well currently, but most likely I will change it to a direct function call later. But for now it is easier to test the command every time and change it to a function call later. This way it tells me when there is a problem like it is giving me now.

Are you sure that works? Try setting the model manually, cause I see “prop” in the arguments, but not what is actually is.

[sp]A string, apparently, but not defined?[/sp]

Yes I have tested it. It worked before I added the ent:Activate() just fine and would spawn the item, the physics just would not activate.

Well, that’s rather odd.

Yes… I do not see why the command is not working any more. It comes back unknown command. Like it is not creating it at all. Though the code is initialized for the function.


ent:Fire("Activate", true)

Worth a try?

Hmm I will try that but I do not understand why ent:Activate() would break the command lol.

[editline]10:01PM[/editline]

Ah it probably broke it because It is serverside and not clientside… I will try moving the spawning function to serverside, using a serverside hook…

Also you may want to change the CurTime()-lastspawn maths in your print message around otherwise it will return a negative value like “-8” or so.
Also yes Activate is serverside clientside doesn’t have proper physics.

**[Entity.Activate

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.Activate)**
Check the wiki, it’s shared. And physics work client-side, they just won’t interact with server-side physics.

[lua]
…CurTime()-lastspawn…
[/lua]
Should be
[lua]
…(CurTime()-lastspawn)…
[/lua]

Are you getting any errors what so ever?

Right now I am working on changing it over to a server side function I am just trying to figure out the best way to do that. I am looking at possibly using a hook and/or datastream. Does anyone have any suggestions?

[editline]11:38PM[/editline]

I have attempted adding a command to the server and calling it by the player but it returns invalid command just like it does client side. Any suggestions?

The code i gave you in the last thread should work serverside.