Jump to content

Changing direction slow when aiming


Recommended Posts

Hello, I am trying to remove the movement slowing that happens when you're aiming a weapon, walking in one direction and then changing it to the opposite direciton.

The reason for which I'm trying to do this is because I have played a lot of SA-MP on deathmatch servers  and this movement slow feels very unconfortable when coming from there (for various reasons).

I am aware that the movement is supposed to be like this, as it is in the single player game, but I'm just wondering if there's a way to skip/cancel that slowing animation and turn into the opposite direction directly.

I've looked all over the wikipedia and forums and couldn't find any function that does this or anybody even asking about this.

Here is what I have done on clientside:

 

-- clientside script
function weaponMovementFix(key, press)
	local forwardkeys = getBoundKeys("forwards")
	local backwardkeys = getBoundKeys("backwards")
	local leftkeys = getBoundKeys("left")
	local rightkeys = getBoundKeys("right")
	local myweapon = getPedWeapon(localPlayer)
	local mycurrentammo = getPedAmmoInClip(localPlayer)
	if myweapon == 24 then -- only for the deagle
		if mycurrentammo ~= 0 then -- don't do it when reloading cause it cancels the reloading
			if getControlState("aim_weapon") then -- only do it when aiming
				if not isPedDucked(getLocalPlayer()) then -- don't do it when crouching/ducking
					for rightkey, rightstate in pairs(rightkeys) do
						if key == rightkey and press then
							setPedAnimation(getLocalPlayer(), "python", "python_fire", 0, false, false, true, false, 0)
							break
						end
					end
					for leftkey, leftstate in pairs(leftkeys) do
						if key == leftkey and press then
							setPedAnimation(getLocalPlayer(), "python", "python_fire", 0, false, false, true, false, 0)
							break
						end
					end
					for fwdkey, fwdstate in pairs(forwardkeys) do
						if key == fwdkey and press then
							setPedAnimation(getLocalPlayer(), "python", "python_fire", 0, false, false, true, false, 0)
							break
						end
					end
					for bkwdkey, bkwdstate in pairs(backwardkeys) do
						if key == bkwdkey and press then
							setPedAnimation(getLocalPlayer(), "python", "python_fire", 0, false, false, true, false, 0)
							break
						end
					end
				end
			end
		end
	end
end

addEventHandler("onClientKey", getRootElement(), weaponMovementFix)

 

 

It kind of works, but it is still not instant, it still stops for a very short moment before changing the direction. So if let's say I keep pressing left-right-left-right, I won't move at all.

I have tried changing all the arguments for setPedAnimation, or even use another animation, but this is the closes I've got to what I want.

And before you ask, I have already tried using all setWeaponProperty on serverside, but none of them affect this "slowing" thing.

Also, even with all glitches enabled, still no luck.

 

Is there any better way to do this?

P.S. if needed, I can upload a video with side to side aiming to show it if I haven't explained it well enough.

 

Thank you for your help.

Edited by UnchiuDawg
Link to comment
1 hour ago, IIYAMA said:

If this is not what you mean, then I did like to see that (not created yet) video.

Here's the video, I tried to synchronize them as much as possible, please note that on the MTA side I sometimes stop, that's the thing I'm talking about, I'm changing direction but it gets stuck for a second before walking in the other direction which is slow and weird.

 

 

I am not talking about the time needed to break out of this animation and walk freely, nor the speed at which you can walk in one direction, I'm talking about it getting stuck when trying to switch directions like from left to right or from forward to backward.

Edited by UnchiuDawg
Link to comment
  • Moderators

Almost as if SA-MP is missing some animations.

 

Checked if it maybe had to do with the glitches. https://wiki.multitheftauto.com/wiki/SetGlitchEnabled
But it seems that is not it.

 

I also checked if it had to do with the FPS. (Which often causes animation/movement changes when it is higher than 30 fps)
But it seems that is it not the cause either.

 

Checked: setPedWalkStyle, which is also not responsible for it.

 

 

If GTA san doesn't have this slowdown effect, then I guess it has something to do with improving the synchronization. If you do not slow down the animation, it might cause a small (visible) teleportation for other players because the direction velocity changes too quick.

 

 

 

 

 

 

 

 

  • Like 1
Link to comment
1 hour ago, IIYAMA said:

If GTA san doesn't have this slowdown effect, then I guess it has something to do with improving the synchronization.

That's the thing, GTA San Andreas does have this slowdown effect and MTA does it the way it is supposed to be. It's 100% the same as it is in single player without any mods.

I was just wondering if there was any possible way to just skip that slowing animation in order to make players harder to hit and to give them more mobility, but I guess it's impossible :(

I've done some research but couldn't find any SA-MP setting or scripting function that would affect this, I guess it was unintentionally hardcoded like that lol

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...