Aiming with Mouse's position

I’m trying to create an entity from a point to where I aim with the mouse, gui.ScreenToVector(gui.MousePos()).
Of course, I know this is just client-side, that’s why I decided to do this as a test:
[lua]function GM:Think()
local x = gui.ScreenToVector(gui.MousePos()).x
local y = gui.ScreenToVector(gui.MousePos()).y
local z = gui.ScreenToVector(gui.MousePos()).z
for k, v in pairs (player.GetAll()) do v:SetNWInt(“x”, x) v:SetNWInt(“y”, y) v:SetNWInt(“z”, z) end – Yeah NWInts, I’ll delete 'em later.
end[/lua]
and in CalcView:
[lua]
local Vec1 = Vector(0, 0, MousePosition.yaw)
local Vec2 = gui.ScreenToVector( gui.MousePos() )*(-1)
local Ang = (Vec1 - Vec2):Angle()
ply:SetEyeAngles( Ang )[/lua]

Now, this is the part where I create the entity server-side:
[lua]
local ent = ents.Create(“prop_physics”)
ent:SetPos(Vector(0,0,0))
ent:SetModel(“models/items/combine_rifle_ammo01.mdl”)
ent:Spawn()
ent:SetColor(0,0,0,255)
ent:Activate()
local phys = ent:GetPhysicsObject()
local shot_length = 350
if phys:IsValid() then phys:ApplyForceCenter(pl:GetAimVector():GetNormalized() * math.pow(shot_length, 2)) end[/lua]

Since the AimVector doesn’t follow the mouse position I tried some other tests but they all failed, that’s why I need some help… any ideas?

You can’t set NWVars clientside

Ah right.
Come on I need some help, anyone got an idea?

What the fuck?

-snip-

Nope. The change only stays until server re-sends it (a short time)

Yeah, yeah, just tested… sorry :X
Anyway I’m just getting crazy at trying to make this working…

[editline]10:44PM[/editline]

[lua]local MousePosition = gui.ScreenToVector( gui.MousePos() )
local Ang = Vector(MousePosition.x, MousePosition.y, 0)
ply:SetEyeAngles( Ang )[/lua]
This works but it’s like if the main point is the center of the map so it’s like if my player is there and it points where I aim.

Nothing uh? Too bad :confused:

Well, Player:GetEyeTrace() traces in the direction of the mouse (atleast client-side it does) maybe you could do something with that?
I must say though that after reading that code, I still don’t have a clue on what you are trying to do:confused: