[Request] Cam shaking effect for realistic first person (For gamemode)

Hello !

I am searching, But i don’t found anything for do a screen shaking, Like in a earthquake for a realistic movement
until that :

But there no anything exemple, Or anything for explain me how to use it
This is my request, How can I do a cam shaking when a player walk?
Like Open Aura?

(I have search a lot of google)

I believe this works:
[lua]
local shake = ents.Create(“env_shake”)
shake:SetKeyValue(“amplitude”, “20”)
shake:SetKeyValue(“duration”,10)
shake:SetKeyValue(“radius”, 10000)
shake:SetKeyValue(“frequency”, 200)
shake:SetPos(0,0,0)
shake:Spawn()

	shake:Fire("StartShake","","1")

[/lua]
Untested. Probably won’t work.


util.ScreenShake( Vector Pos, Float amp, Float Freq, Float Duration, Float Radius )


function GM:PlayerLoadout( ply )

	local shake = ents.Create("env_shake")
	shake:SetKeyValue("amplitude", "20")
	shake:SetKeyValue("duration",10)
	shake:SetKeyValue("radius", 10000)
	shake:SetKeyValue("frequency", 200)
	shake:SetPos(0,0,0)
	shake:Spawn()
 
	shake:Fire("StartShake","","1")

	if ply:Team() == 1 then
	
		ply:SetModel( "models/Humans/Group01/Male_07.mdl" )
		ply:Give( "weapon_crowbar" )
		ply:Give( "weapon_pistol" )
	
	end
end

Like that?

[editline]18th July 2012[/editline]

I have test it and it work ! Thanks

RE-EDIT

I ve try the movement on camera when he walk, And stop when i don’t walk


unction KeyPressed (P, IN_FORWARD)
		
util.ScreenShake( Vector(0,0,0), 5, 5, 999, 5000 )	
	
end
 
 	

local function printKeyReleased( ply, IN_FORWARD)

util.ScreenShake( Vector(0,0,0), 5, 5, 1, 5000 )
	

end
 

That isn’t how the second argument works, it is a variable for what key. You also didn’t even hook the function. You’ll need to do:

[lua]
function keyPressed(ply, key)
if (key == IN_FORWARD) then
– Your stuff
end
end

hook.Add(“KeyPressed”, “Special Unique ID”, keyPressed)
[/lua]