towarzyszbroni Posted July 4, 2019 Share Posted July 4, 2019 Hello, I am looking for solution to fix default player reload script. When player reload then there is an animation of reloading and when animation stops weapon is reloaded. The problem is when player change weapon during reloading and then back to it the animation is repeated so player can't shoot quickly. He must wait for stop animation and in most cases he dead in treat. I am looking for function in which i can check if player changed weapon and cancel event of reloading. Client local blockedTasks = { "TASK_SIMPLE_IN_AIR", -- We're falling or in a jump. "TASK_SIMPLE_JUMP", -- We're beginning a jump "TASK_SIMPLE_LAND", -- We're landing from a jump "TASK_SIMPLE_GO_TO_POINT", -- In MTA, this is the player probably walking to a car to enter it "TASK_SIMPLE_NAMED_ANIM", -- We're performing a setPedAnimation "TASK_SIMPLE_CAR_OPEN_DOOR_FROM_OUTSIDE", -- Opening a car door "TASK_SIMPLE_CAR_GET_IN", -- Entering a car "TASK_SIMPLE_CLIMB", -- We're climbing or holding on to something "TASK_SIMPLE_SWIM", "TASK_SIMPLE_HIT_HEAD", -- When we try to jump but something hits us on the head "TASK_SIMPLE_FALL", -- We fell "TASK_SIMPLE_GET_UP", -- We're getting up from a fall "TASK_COMPLEX_GO_TO_POINT_AIMING" } local function reloadWeapon() -- Usually, getting the simplest task is enough to suffice local task = getPedSimplestTask (localPlayer) -- Iterate through our list of blocked tasks for idx, badTask in ipairs(blockedTasks) do -- If the player is performing any unwanted tasks, do not fire an event to reload if (task == badTask) then return end end triggerServerEvent("relWep", resourceRoot) end -- The jump task is not instantly detectable and bindKey works quicker than getControlState -- If you try to reload and jump at the same time, you will be able to instant reload. -- We work around this by adding an unnoticable delay to foil this exploit. addCommandHandler("Reload weapon", function() setTimer(reloadWeapon, 50, 1) end) bindKey("r", "down", "Reload weapon") Server function reloadWeapon() reloadPedWeapon(client) return true end addEvent("relWep", true) addEventHandler("relWep", resourceRoot, reloadWeapon) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now