So I am trying to use this function.
Unfortunately the wiki has no page for it and nothing to help me. Every time I try to use it returns as a nil value to me. Anybody know how to properly use this type of function?
[b]Basic Example line[/b]
[lua]if ply:GetMouseX() < 0 then[/lua]
Anybody can help on this weird function?
Ok I see, I'll try ny hand at making the hook, I am worried tho, since I don't know if it works with SetupMove event.
[QUOTE=iRzilla;19783971]Well does the SetupMove hook give you a CUserCmd argument?[/QUOTE]
No, I just realised that it dosen't, ah, that sucks. I need to use GetMouseX() but it seems like it only works with CreateMove ans some others.
How would I go about to put it into SetupMove?
Move dosen't seem to have any usercmd either. Thats why. I'll try it tho.
[Editline]15:23[/Editline]
Nope, it dosen't work.
I will show you my code.
Here goes:[lua]function AirAccelerate( ply, cmd, cmd )
local Momentum = ply:GetForward()
local Air = ply:OnGround()
local AirMovementLeft = ply:KeyDown( IN_MOVELEFT )
local AirMovementRight = ply:KeyDown( IN_MOVERIGHT )
local AirJumped = ply:KeyPressed( IN_JUMP )
local AirJump = ply:KeyDown( IN_JUMP )
if !Air and AirMovementLeft then
ply:SetVelocity( Momentum * 1.5 + ply:GetRight() * -1.2 )
elseif !Air and AirMovementRight then
ply:SetVelocity( Momentum * 1.5 + ply:GetRight() * 1.2 )
else return
end
end
hook.Add( "SetupMove", "AirAccelerate", AirAccelerate )[/lua]
It is a huge WIP for now, but its coming along. I am trying to mimic the CSS's straffing code.
GetMouseX() would be perfect to know if the player moved its mouse to one way.
But it seems like it just won't work out.
Mmh, maybe, when Jinto responded from my previous thread about IN_MOVELEFT differences, he said it was, when the mouse is idle it'll get its X position, then once moved to the Left it'll be a negative value, and if moved to the right right, it'll be a positive value, but this dosen't seem to be the case.
[QUOTE=iRzilla;19785450]IN_MOVELEFT is your best hope. It's pretty much detecting if "+left" is active.[/QUOTE]
Yah but the problem is I need to get which way the player moved his mouse.
[QUOTE=iRzilla;19785782]IN_MOVELEFT & IN_MOVERIGHT
Obvious enough?[/QUOTE]
Those cannot be used to know which way the mouse has been moved, it can only work with the keyboard.
And those are for when you move to the left with A, and move to the right with D.
[QUOTE=iRzilla;19786548]IN_LEFT & IN_RIGHT
They detect if a player looks left and right. Work fine with the mouse.[/QUOTE]
How would you go about to make it work.
I would need to use:
[lua] ply:KeyDown( IN_LEFT ) [/lua]
And key down will only work with the keyboard.
[Editline]17:13[/Editline]
I guess no one knows how...
[lua]local cmd = pl:GetCurrentCommand();
if( cmd:GetMouseX() < 0 ) then
elseif( cmd:GetMouseX() > 0 ) then
end[/lua]
[QUOTE=iRzilla;19786548]IN_LEFT & IN_RIGHT
They detect if a player looks left and right. Work fine with the mouse.[/QUOTE]
No, IN_LEFT and IN_RIGHT is only if you have a key binded to look left or right. It doesnt detect if the player looks left or right, it detects if the player presses a KEY to look left or right...That is why IN_LEFT and IN_RIGHT are considered IN_KEY identifiers.
[editline]12:42AM[/editline]
Sylph, possibly look into
[url]http://wiki.garrysmod.com/?title=G.EyeAngles[/url]
[QUOTE=Jinto;19789974][lua]local cmd = pl:GetCurrentCommand();
if( cmd:GetMouseX() < 0 ) then
elseif( cmd:GetMouseX() > 0 ) then
end[/lua][/QUOTE]
I see, Thanks alot, seems to be working.
Sorry, you need to Log In to post a reply to this thread.