Xwad Posted August 28, 2015 Share Posted August 28, 2015 hi i have a script that makes possible when i shoot with a gun then the players will see my blip on the map but its not working:/ function applyBlips() for k, player in pairs( getElementsByType( "player" ) ) do local r, g, b = getPlayerNametagColor( player ) if isPedDead( player ) then return end if not blip[player] then blip[player] = createBlipAttachedTo( player, 0, 2, r, g, b, 255, 0, blipViewDistance ) else setBlipColor( blip[player], r, g, b, 255 ) end end end addEventHandler( "onWeaponFire", resourceRoot, applyBlips ) setTimer( applyBlips, 500, 0 ) -- This is to account for name tag colour changes, especially in RPG servers. function createBlips() if ( source ) then player = source end local r, g, b = getPlayerNametagColor( player ) if not blip[player] then blip[player] = createBlipAttachedTo( player, 0, 2, r, g, b, 255, 0, blipViewDistance ) else setBlipColor( blip[player], r, g, b, 255 ) end end addEventHandler( "onWeaponFire", root, createBlips ) Link to comment
JR10 Posted August 28, 2015 Share Posted August 28, 2015 The code is illogical. You're creating a blip for each player instead of only creating one for the player that used his weapon. The timer is also not needed. local blip = {} addEventHandler('onWeaponFire', root, function() if (not isElement(source) or isPedDead(source)) then return end local r, g, b = getPlayerNametagColor(source) if (isElement(blip[source])) then setBlipColor(blip[source], r, g, b) else blip[source] = createBlipAttachedTo(source, 0, 2, r, g, b) end end) 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