Jump to content

Nametagcolor


Recommended Posts

Posted

Hello all,

I want a little script, if player was in team Test he's nametagcolor and blip must be same as team color, i want to make a script like that.

Well, i tried this using this but need some functions,

r, g, b = getTeamColor(teamElement) 
setPlayerNametagColor(playerElement, r, g ,b) 

Can somebody help me with a code or someting elser thanks :)

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

didn't test, but should work:

  
blip = {} 
  
function spawn(posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension) 
    if(not isElement(blip[getPlayerName(source)])) then blip[getPlayerName(source)] = createBlipAttachedTo(source) end 
    if(getTeamName(theTeam) == 'test') then 
        local r, g, b = getTeamColor(theTeam) 
        setPlayerNametagColor(source, r, g, b) 
        setBlipColor(blip[getPlayerName(source)], r, g, b, 255) 
    end 
end 
  
addEventHandler('onPlayerSpawn', getRootElement(), spawn) 
  

this is server-side script !

5acec1ecbc.png
Posted

Okay

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted (edited)

What if the player changes their name?

The table wont free it until the resource is restarted/stopped.

Anyways, try this:

local blip = {} 
  
addEventHandler('onPlayerSpawn',root, function(_, _, _, _, theTeam) 
    if (not isElement(blip[source])) then blip[source] = createBlipAttachedTo(source) end 
    if(getTeamName(theTeam) == 'test') then 
        local r, g, b = getTeamColor(theTeam) 
        setPlayerNametagColor(source, r, g, b) 
        setBlipColor(blip[source], r, g, b, 255) 
    end 
end) 
setTimer(function() 
    for source,b in pairs(blip)do 
        if not isElement(source) then 
            destroyElement(b) 
            blip[source] = false 
        end 
    end 
end,10000,0) 

Edited by Guest

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

Not only for Test team i want it for every team because i have 4 and i want when player login he's nametagcolor and blip be the same as Team color.

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

ok, try this:

local blip = {} 
  
addEventHandler('onPlayerSpawn',root, function(_, _, _, _, theTeam) 
    if (not isElement(blip[source])) then blip[source] = createBlipAttachedTo(source) end 
    local r, g, b = getTeamColor(theTeam) 
    setPlayerNametagColor(source, r, g, b) 
    setBlipColor(blip[source], r, g, b, 255) 
end) 
setTimer(function() 
    for source,b in pairs(blip)do 
        if not isElement(source) then 
            destroyElement(b) 
            blip[source] = false 
        end 
    end 
end,10000,0) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

Thanks for youre help.....i will try

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Wont work i tried debugscript 3 it show nothing.

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
ok, try this:
local blip = {} 
  
addEventHandler('onPlayerSpawn',root, function(_, _, _, _, theTeam) 
    if (not isElement(blip[source])) then blip[source] = createBlipAttachedTo(source) end 
    local r, g, b = getTeamColor(theTeam) 
    setPlayerNametagColor(source, r, g, b) 
    setBlipColor(blip[source], r, g, b, 255) 
end) 
setTimer(function() 
    for source,b in pairs(blip)do 
        if not isElement(source) then 
            destroyElement(b) 
            blip[source] = false 
        end 
    end 
end,10000,0) 

Where is the 2nd argument of the function createBlipAttachedTo.

To Visit Us

Press Here: mtasa://5.9.206.180:22002

b648040241b8f01.png

0d0a7bb38ca13e5.png

Posted
ok, try this:

<...>

Where is the 2nd argument of the function createBlipAttachedTo.

only 1 argument is required, others are optional

Nah, I've set a timer for it to run every 10secs to see if every player is still in the server so there's no lose ends of the script.

You can use onPlayerQuit for that, you dont need timer.

5acec1ecbc.png
Posted

Won't work help guys.

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
local blip = { } 
  
addEventHandler ( "onPlayerLogin", root, 
    function ( ) 
        if ( not isElement ( blip [ source ] ) ) then 
            blip [ source ] = createBlipAttachedTo ( source ) 
        end 
  
        local theTeam = getPlayerTeam ( source ) 
        if ( not theTeam ) then 
            return 
        end 
  
        local r, g, b = getTeamColor ( theTeam ) 
        setPlayerNametagColor ( source, r, g, b ) 
        setBlipColor ( blip [ source ], r, g, b, 255 ) 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if isElement ( blip [ source ] ) then 
            destroyElement ( blip [ source ] ) 
        end 
    end 
) 

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
local blip = { } 
  
addEventHandler ( "onPlayerLogin", root, 
    function ( ) 
        if ( not isElement ( blip [ source ] ) ) then 
            blip [ source ] = createBlipAttachedTo ( source ) 
        end 
  
        local theTeam = getPlayerTeam ( source ) 
        if ( not theTeam ) then 
            outputChatBox ( "YOU HAVE NO TEAM", source ) 
            return 
        end 
  
        local r, g, b = getTeamColor ( theTeam ) 
        setPlayerNametagColor ( source, r, g, b ) 
        setBlipColor ( blip [ source ], r, g, b, 255 ) 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if isElement ( blip [ source ] ) then 
            destroyElement ( blip [ source ] ) 
        end 
    end 
) 

Try that and see what it says when you login.

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

Okay gonna try.

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

You should combine the blip script with your team loader system.

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 can't understand.

I'm using autoteams.

I will send you code of it in Private message.

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
local blip = { } 
  
addEvent ( "onPlayerTeamChanged", true ) 
addEventHandler ( "onPlayerTeamChanged", root, 
    function ( theTeam ) 
        if ( not theTeam ) then 
            return 
        end 
  
        if ( not isElement ( blip [ source ] ) ) then 
            blip [ source ] = createBlipAttachedTo ( source ) 
        end 
  
        local r, g, b = getTeamColor ( theTeam ) 
        setPlayerNametagColor ( source, r, g, b ) 
        setBlipColor ( blip [ source ], r, g, b, 255 ) 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if isElement ( blip [ source ] ) then 
            destroyElement ( blip [ source ] ) 
        end 
    end 
) 

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

Gonna try

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Working perfect Thank you, youre the best :D :D :D

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

You're welcome.

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.

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