Jump to content

Blip not displaying proper colour


Noki

Recommended Posts

Posted
local blip = {} 
  
function destroyBlipsAttachedTo( player ) -- Keep this just in case 
    local attached = getAttachedElements( player ) 
    if ( attached ) then 
        for k, element in pairs ( attached ) do 
            if getElementType( element ) == "blip" then 
                destroyElement( element ) 
            end 
        end 
    end 
end 
  
function applyBlips() 
    for k, player in pairs ( getElementsByType( "player" ) ) do 
        tR, tG, tB = getTeamColor( getPlayerTeam( player ) ) 
        tR = tonumber( tR ) 
        tR = tonumber( tG ) 
        tR = tonumber( tB ) 
        if not blip[player] then 
            blip[player] = createBlipAttachedTo( player, 0, 2, tR, tG, tB, 255 ) 
        else 
            setBlipColor( blip[player], tR, tG, tB, 255 ) 
        end 
    end 
end 
addEventHandler( "onResourceStart", resourceRoot, applyBlips ) 
setTimer( applyBlips, 500, 0 ) 
  
function createBlips() 
    if ( source ) then player = source end 
    tR, tG, tB = getTeamColor( getPlayerTeam( player ) ) 
    tR = tonumber( tR ) 
    tR = tonumber( tG ) 
    tR = tonumber( tB ) 
    if not blip[player] then 
        blip[player] = createBlipAttachedTo( player, 0, 2, tR, tG, tB, 255 ) 
    else 
        setBlipColor( blip[player], tR, tG, tB, 255 ) 
    end 
end 
addEventHandler( "onPlayerSpawn", root, createBlips ) 
  
function destroyBlip() 
    if ( source ) then player = source end 
    if ( blip[player] and isElement( blip[player] ) ) then 
        destroyElement( blip[player] ) 
        blip[player] = nil 
    end 
end 
addEventHandler( "onPlayerQuit", root, destroyBlip ) 
addEventHandler( "onPlayerWasted", root, destroyBlip ) 

Hello,

For some reason, when my team is a greyscale colour (white, black, grey, silver etc) the blip displays correctly. But when my team is a colourful colour (like red, blue or green etc) the player blips display wrong. I'm not sure why it's doing this. My debug is completely clear and I honestly don't know what I'm doing wrong. The colour changes on team change (the 500ms timer and all) but the colour is incorrect. When I switch to a team (RGB: 255, 255, 0) it wouldn't display yellow, but green for some reason. Changing to a (RGB: 255, 0, 0) team makes my blip change to black.

I don't have any conflicting resources (playerblips or customblips). Any help would be appreciated.

Posted

You must remove these lines, since getTeamColor already returns numbers, so there's no need to convert numbers to numbers.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I put them in there before when the function always returned 0. The tonumber seemed to fix it then. But I removed them and it works fine now.

Thank you once again.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...