client to server communication entity

I need a way to communicate to the server from the client, networked variables don’t work because they can set variables on the server and ussermessage’s are server to client only.

Use a Datastream.

Only use datastream if you need to network tables (which you shouldn’t do anyway). Console commands are the way to go (datastream actually uses console commands).

Another question : I remade it so I don’t need the client to server communication only now I send a usermessage to the client and then spawn a prop :

this is called when a user presses E on the entity

[lua]
function UseClient( um )

local self = um:ReadEntity()
local upVector = self:GetAngles():Up()

local ent = ents.Create( "prop_physics" )
ent:SetModel(ammo[propIndex])
ent:SetAngles( self:GetAngles() )
ent:SetPos( self:GetPos() + (upVector * 15) )
ent:Spawn()
ent:GetPhysicsObject():ApplyForceCenter( upVector * 5000 * ent:GetPhysicsObject():GetMass() )

return

end
[/lua]

the entity being send through the ussermessage is self.Entity

errors :

Tried to use invalid object (type IPhysicsObject) (Object was NULL or not of the right type)

[editline]03:04PM[/editline]

This is client side btw

Props don’t have physics clientside. You’re better off making it on the server.

I have a little problem, I have this menu that is clientside (derma) and it has some variables that I need for creating the prop (propIndex) how can I combine this, as you can see sending a usmg to the client whenever someone presses use on the prop didn’t work

Use a console command.

How would that work, I have a on use event on the server and variables on the client, how would a console command get the variables to the server ?

A console command is the only way to get variables to the server. You would use it to trigger the entity creation with the arguments you supplied it.