ConCommand blocked

I was adding a menu that could spawn props then, when I started up GMod to test it, the “ConCommand Blocked” label appeared. It happened a lot of times in the past, and I’ve fixed it some times, but I can’t fix this one.
Does anyone know how to fix this?

Use usermessages to run commands on clients using RunConsoleCommand, or SendLua them the commands - preferably the first.

Uhm, thanks. But I think I’m gonna use runconsolecommand.

[editline]06:05PM[/editline]

Nothing. I still get a Lua Error.
Tell me if I did right:


ico.DoClick = function( ico ) 
LocalPlayer():ConCommand("ent_create "..v.NAME.." "..v.PRICE.."
")
RunConsoleCommand("ent_create "..v.NAME.." "..v.PRICE.."
")

Obviusly this is not the entire code. This is just the “Bad” part.

Get rid of LocalPlayer():ConCommand.

Anything containing:

Record, screenshot, rcon, exit , quit, and probably dump are all blocked by RunConsoleCommand. It seems ent* is as well.

I tried making only LocalPlayer():RunConsoleCommand,
But I guess that’s the wrong way, I’m trying with only RunConsoleCommand.

Note: RunConsoleCommand is not a method of the player class so that is why it didn’t work.

Indeed:


runconsolecommand: command has invalid characters! (ent_create ent_blastdoor 7 (' '))    The first parameter of this function should contain only a command, the second parameter should contain arguments.

Now I’m trying to use the other method, the problem is that I searched on the Wiki and I found a function for the other method wich is totally out contest! I can’t put a function there. Anyway, I’m just modifying “GoFish 2”


for k,v in pairs( FISH ) do
		local ent = ents.Create("prop_physics") -- lol ailias filthy hack
		ent:SetAngles(Angle(0,0,0))
		ent:SetPos(Vector(0,0,0))
		ent:SetModel(k)
		ent:Spawn()
		ent:Activate()
		ent:PhysicsInit( SOLID_VPHYSICS )   
		local ico = vgui.Create( "DModelPanel", self )
		ico:SetModel(k)
		ico.Skin = math.random(0,util.GetModelInfo(k).SkinCount-1)
		ico.Entity:SetSkin(ico.Skin)
		ico.DoClick = function( ico ) 
		RunConsoleCommand("ent_create "..v.NAME.." "..v.PRICE.."
")
		surface.PlaySound( "ui/buttonclick.wav" )		
		end

		ico:SetSize(55,55)

		local center = ent:OBBCenter()
		local dist = ent:BoundingRadius()*v.VIEW
		ico:SetToolTip( Format( "%s", v.DESCRIPTION.."  -  Cost: $"..v.PRICE ) ) 
		ico:SetLookAt( center )
		ico:SetCamPos( center+Vector(dist,dist,dist) )

		ico:InvalidateLayout( true ) 
		if v.GROUP then
			self.IconList[v.GROUP]:AddItem( ico )
		end
		ent:Remove()
	end
end

All I need now is to learn how to use usermessage…
Do I just need to put Msg("ent_create “…v.NAME…” “…v.PRICE…”
")?

[editline]06:38PM[/editline]

What the hell? It just writes it on the Console, it doesn’t send it!

Can’t you just gm_spawn it or create a command that only allows certain models to be spawned? Also that is not how you use usermessages, try reading this.

what the fuck are you doing?
local ent = ents.Create(v.NAME)
:hurr:

I already read it… and I said it is a function and I asked if a function would go well on that script.

Thanks, I’m gonna check it out.

[editline]AAASSSSS[/editline]


Can't find factory for entity: ent_blastdoor

:v:

RunConsoleCommand("ent_create “, v.NAME, v.PRICE …”
")

You did make a scripted entity called ent_blastdoor first, right?

[editline]09:19PM[/editline]

Failure. :v:

Of course it is a function.

[lua]usermessage.Hook(Handler , function_callback)[/lua]

It’s simply the “Hook” function of the usermessage library, with the first parameter being the handler of the usermessage, and the second being the function to deal with the received usermessage in

Can you make me an example? I failed trying it. Maybe I’m on the wrong way, please, make me an example.

Has anyone else noticed he’s trying to spawn a serverside prop on the client?

How about you put this serverside:

[lua]function MakeProp(user,com,arg)
local mdl = arg[1]
local e = ents.Create(“prop_physics”)
e:SetModel(mdl)
e:SetPos(user:GetShootPos() + (user:GetAimVector() * 64))
e:Spawn()
end
concommand.Add(“spawnprop”,MakeProp)[/lua]

and then make your button do this:

[lua]RunConsoleCommand(“spawnprop”,<whatever it is that has the model>)[/lua]

Change shit as necessary.

Does not work.

your entity is probably not being loaded. Check console for errors.

I already did. I found nothing useful.
May anyone make me an example since it is the only one thing I need so I can see where I’m wrong?

type lua_reloadents in console, then paste here everything that prints afterwards.