Jump to content

color player


mr.Extreme

Recommended Posts

Posted

hello i want help

what the problem here

  
  
local lowerBound,upperBound = unpack(get"color_range") 
g_Root = getRootElement () 
g_ResourceRoot = getResourceRootElement ( getThisResource () ) 
  
addEventHandler ( "onResourceStart", g_ResourceRoot, 
    function() 
        for i,player in ipairs(getElementsByType"player") do 
            processPlayer ( player ) 
        end 
    end 
) 
  
function processPlayer ( player ) 
        if not isElement(blip) then 
            blip = createBlipAttachedTo(source) 
        end 
        local theTeam = getPlayerTeam(source) 
        if theTeam then 
            local r, g, b = getTeamColor(theTeam) 
            setPlayerNametagColor(source, r, g, b) 
            setBlipColor(blip, r, g, b, 255) 
        else 
        --[[if not isElement(blip1[source]) then 
            blip1[source] = createBlipAttachedTo(source) 
        end]] 
            player = player or source 
            local rr, gg, bb = math.random(lowerBound, upperBound), math.random(lowerBound, upperBound), math.random(lowerBound, upperBound) 
            setPlayerNametagColor(player, rr, gg, bb) 
            --setBlipColor(blip1[source], rr, gg, bb, 255) 
            --destroyElement(blip[source]) 
    end 
end 
addEventHandler ( "onPlayerLogin", getRootElement(), processPlayer ) 
  
function setColorPlayer() 
    if not isElement(blips) then 
        blips = createBlipAttachedTo(source) 
    end 
    player = player or source 
    local rr, gg, bb = math.random(lowerBound, upperBound), math.random(lowerBound, upperBound), math.random(lowerBound, upperBound) 
    setPlayerNametagColor(player, rr, gg, bb) 
    setBlipColor(blips, rr, gg, bb, 255) 
end 
addEventHandler("onPlayerJoin", getRootElement(), setColorPlayer) 
  
function ifnottheteam() 
    local theTeams = getPlayerTeam(source) 
    if not theTeams then 
        destroyElement(blip) 
    end 
    if theTeams then 
    destroyElement(blips) 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), ifnottheteam) 
  
  
addEventHandler("onPlayerQuit", root, 
function() 
    if isElement(blip) then 
         destroyElement(blip) 
         destroyElement(blips) 
    end 
end 
) 
  
  
  
--[[ 
addEventHandler('onPlayerChat', g_Root, 
    function(msg, type) 
        if type == 0 then 
            cancelEvent() 
            local r, g, b = getPlayerColor(source) 
            local name = getPlayerName(source) 
            local msg = msg:gsub('#%x%x%x%x%x%x', '') 
            outputChatBox( name.. ': #FFFFFF' .. msg, g_Root, r, g, b, true) 
            outputServerLog( "CHAT: " .. name .. ": " .. msg ) 
        end 
    end 
) 
]] 
getPlayerColor = getPlayerNametagColor 
getPlayerColour = getPlayerNametagColor 
  

:(

Posted
local lowerBound,upperBound = unpack(get"color_range") 

(get"color_range")

It's wrong.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
local lowerBound,upperBound = unpack(get"color_range") 

(get"color_range")

It's wrong.

How exactly is it wrong? because he forgot about the parentheses before " and after "? if so, then you are wrong, because that'll work anyway.

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 lowerBound,upperBound = unpack(get"color_range") 

(get"color_range")

It's wrong.

  
local lowerBound,upperBound = unpack(get"color_range") 
  

lol.

xD

what about meta.xml

        "color_range" value="[ [ 50, 255 ] ]" /> 
    

Posted
local lowerBound,upperBound = unpack(get"color_range") 

(get"color_range")

It's wrong.

How exactly is it wrong? because he forgot about the parentheses before " and after "? if so, then you are wrong, because that'll work anyway.

My bad, I never used the get function, thought it was needed parentheses.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

Is not about that function only, you can do it with other functions, example:

for _, player in ipairs ( getElementsByType "player" ) do 
-- Code here 
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 (edited)

Oh, and it work only for strings? I really didn't know that...

Sorry for Offtopic.

Edited by Guest

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

Yes, I think it only works with strings.

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