Developer
Overview
ML Recoil exposes hooks in two escrow-ignored files, client/main_open.lua and server/server_open.lua, plus two client exports for a staff menu.
Client Hooks
Located in client/main_open.lua.
client/main_open.lua
1function OnWeaponEquipped(weaponHash, profile)
2 return true
3end
4
5function OnShotFired(weaponHash, totalMultiplier)
6end
7
8function OnAimStateChanged(weaponHash, isAiming)
9endOnWeaponEquipped: runs when a weapon with a profile is equipped. Returnfalseto skip recoil for itOnShotFired: runs after every shot with the stance and progressive multiplier, without the skill rules. It also fires during drive-bys, when the camera kick is skippedOnAimStateChanged: runs when the player starts or stops aiming
Server Hooks
Located in server/server_open.lua.
server/server_open.lua
1function OnBeforePublish(source, weaponName, profile)
2 return true
3end
4
5function OnProfilePublished(source, weaponName, profile)
6end
7
8function OnBeforeTestRange(source, weaponName)
9 return true
10endOnBeforePublish: runs before a profile saved in the panel goes live. Returnfalseto refuse it. Adding or resetting a weapon does not call itOnProfilePublished: runs after a profile is saved and sent to every player. Adding or resetting a weapon does not call itOnBeforeTestRange: runs before an admin enters the test range. Returnfalseto refuse it
Client Exports
MLAdminOpen(): opens the admin panel, permission checkedMLAdminPanel(): label and icon of the panel, for a staff menu that lists admin tools
Examples
client/main_open.lua
1function OnShotFired(weaponHash, totalMultiplier)
2 exports.ml_skills:RequestXp('personal', 2, 'recoil_shot')
3endAdd a recoil_shot entry to Config.XpListeners of ml_skills with the same category and XP and no interval or condition. The shipped shooting listener already grants XP on its own.
client/main_open.lua
1function OnWeaponEquipped(weaponHash, profile)
2 if weaponHash == `WEAPON_REVOLVER` then return false end
3 return true
4endserver/server_open.lua
1function OnProfilePublished(source, weaponName, profile)
2 print(('%s updated %s'):format(GetPlayerName(source), weaponName))
3end