Jump to content

Changing player blip color?


Recommended Posts

Hi all :)

I have a little question, how can i change the blip icon color from the source - the player?

I tried this, but not work:

  
local r, g, b 
      r, g, b = getTeamColor ( teamtest ) 
  
destroyBlipsAttachedTo ( source ) 
createBlipAttachedTo ( source, 0, 2, r, g, b ) 
  

I think thats a good idea to change the blip color, right? But i get this error and the color don´t changes:

attempt to call global ´destroyBlipsAttachedTo´

I would be very happy when someone can help me, its required urgently

Link to comment

i think u are pretty close ( im no expert either mind )

there is a function. here it is

http://development.mtasa.com/index.php?title=SetBlipColor

but im unsure as to how to attach it to the blip of the player you want to change. i will have a play with it and see what happens

will post any progress :D

what do u want to change the blip color for ( player / checkpoint )

if its for a player you probably need getPlayerFromNick or getPlayerTeam

which are here

http://development.mtasa.com/index.php?title=GetPlayerFromNick

http://development.mtasa.com/index.php?title=GetPlayerTeam

Link to comment

Hi and thanks for help! I want to change the blip color for a player

I also tried

setBlipColor ( source, r, g, b, 255 ) 

- but nothing happens, and this time there a no errors, warnings etc.

After that, it tried this:

  
  local r, g, b 
        r, g, b = getTeamColor ( teamtest ) 
  
local targetPlayer = getPlayerFromNick ( source ) 
setBlipColor ( targetPlayer, r, g, b, 255 ) 
  

... and get Bad Argument warnings:

Bad argument @ 'getPlayerFromNick'

Bad argument @ 'setBlipColor'

Any ideas?

Link to comment

this is almost there i think but i dont know ive only got me in my server so no one to check if color is changed :lol:

im not sure if u need something that puts the blip attached to the player into a field or variable thingy :lol:

here u go

function blipchange ( player, command, name )

local theplayer = getPlayerFromNick ( name )

setBlipColor ( theplayer, 0, 0, 0, 0 )

outputChatBox ( "Blip color reset" )

end

addCommandHandler ( "changeblip", blipchange )

i am very noob at scripting so no guarantees sorry :lol:

Link to comment

bool setBlipColor ( blip theBlip, int red, int green, int blue, int alpha )

local theplayer = getPlayerFromNick ( name ) 
setBlipColor ( theplayer, 0, 0, 0, 0 ), 

your example won't work because you've got "theplayer" which isn't a blip, its a player.

You might want this:

function getBlipAttachedTo( thePlayer ) 
        local blips = getElementsByType( "blip" ) 
        for k, theBlip in ipairs( blips ) do 
                if getElementAttachedTo( theBlip ) == thePlayer then 
                        return theBlip 
                end 
        end 
        return false 
end 
  

and then do:

local theplayer = getPlayerFromNick ( name ) 
local theplayerblip = getBlipAttachedTo(theplayer) 
setBlipColor ( theplayerblip, 0, 0, 0, 0 ) 
  

the example on this page might be useful: http://development.mtasa.com/index.php?title=GetColorFromString

Link to comment

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...