Moderators IIYAMA Posted May 17, 2015 Moderators Posted May 17, 2015 This is not a request!!! Custom onClientPlayerWeaponSwitch event which will now trigger for all players, instead only for the localPlayer. Use it like you want... So: [b]Source[/b] The source of this event is the player who changed his weapon. [strike](Local player only)[/strike] Example: addEventHandler ( "onClientPlayerWeaponSwitch",root, function ( prevSlot, newSlot, custom) outputDebugString (prevSlot .. ", " .. newSlot .. " " .. tostring(custom)) end) Source code. local playerDataBase = {} addEventHandler("onClientResourceStart",resourceRoot, function () local allPlayers = getElementsByType("player") for i=1,#allPlayers do local player = allPlayers[i] if player ~= localPlayer then local slot = getPedWeaponSlot ( player ) playerDataBase[player] = slot end end end) addEventHandler("onClientPlayerJoin",root, function () playerDataBase[source] = getPedWeaponSlot (source) end) addEventHandler("onClientRender",root, function () for player,oldSlot in pairs(playerDataBase) do if isElement(player) then local newSlot = getPedWeaponSlot ( player ) if oldSlot ~= newSlot then triggerEvent("onClientPlayerWeaponSwitch",player,oldSlot,newSlot,true) playerDataBase[player] = newSlot end else playerDataBase[player] = nil end end end) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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