Skip to content

Conversation

@Nico8340
Copy link
Member

@Nico8340 Nico8340 commented Jan 9, 2025

Description

This pull request enhances the synchronization of weapon reloading for both peds and player with making it server sided. Refactors existing functions, introduces a new one, and adds two new events as well. Closes #1525.

Function

POP:

bool isPedReloadingWeapon(element ped)

OOP:
Method: ped:isReloadingWeapon()
Variable ped.reloadingWeapon

Events

"onPedWeaponReload"
"onPlayerWeaponReload"

Example

reloadtest.zip

@Nico8340 Nico8340 requested a review from botder January 10, 2025 05:23
@Nico8340 Nico8340 requested a review from tederis January 10, 2025 07:06
@botder botder merged commit e71f482 into multitheftauto:master Jan 10, 2025
6 checks passed
@botder botder added the enhancement New feature or request label Jan 10, 2025
@botder botder added this to the 1.6.1 milestone Jan 10, 2025
@Nico8340 Nico8340 deleted the reloading branch January 10, 2025 20:22
MTABot pushed a commit that referenced this pull request Jan 10, 2025
e71f482 Add server side weapon reloading (PR #3936, Fixes #1525)
@Nico8340 Nico8340 mentioned this pull request Jan 18, 2025
@PlatinMTA PlatinMTA mentioned this pull request Mar 30, 2025
1 task
@lopezloo
Copy link
Member

lopezloo commented May 5, 2025

Resolves #2747

@lopezloo lopezloo linked an issue May 5, 2025 that may be closed by this pull request
1 task
@lopezloo lopezloo mentioned this pull request May 5, 2025
1 task
@blonter
Copy link

blonter commented Aug 4, 2025

I was just checking on a few things with peds when I saw this PR that an event called onPedWeaponReload exists but it has no wiki page. I just tested this event with this little code and it doesn't work for me. Maybe I'm doing something wrong but I couldn't make it to work.

--server:
local ped = createPed(0, 0, 0, 3)
setElementID(ped, "ped")

addEventHandler("onPedWeaponReload", ped, function(weapon, clip, ammo) -- changing ped to root also not work
    iprint("foo")
end)

--client:
local ped = getElementByID("ped")

givePedWeapon(ped, 22, 1000, true)
setPedControlState(ped, "aim_weapon", true)
setPedAimTarget(ped, 0, 10, 5)
setPedControlState(ped, "fire", true)

Version: Multi Theft Auto v1.7-untested-25351

EDIT* when calling reloadPedWeapon it will fire the event, but when the ped shoots all bullets out of his clip it won't be fired even though the ped automatically reloades the weapon.
EDIT2* Same goes for onPlayerWeaponReload it will only be fired when you manually reload the weapon but if you shoot all your bullet it won't be called. You can spam pressing R even if you have full clip and by doing this you can spam call the event on serverside.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Synchronize weapon reload task Serverside for isPedReloadingWeapon

5 participants