Jump to content

Random Team Color (setTimer)


Overkillz

Recommended Posts

Hey dear community, I hope u are fine ^^

Well, Im here again, to post my question,

Im trying to do put a Random Color Team every x time, but, I get the random color just restarting the resource.

function idkname () 
    local r = math.random(0,255) 
    local g = math.random(0,255) 
    local b = math.random(0,255) 
    team = createTeam ( "Team Name" ) 
    setTeamColor ( team, r, g, b )   
end 
addEventHandler("onResourceStart", resourceRoot, idkname) 
setTimer(r,1000,1,idkname) 
setTimer(g,1000,1,idkname) 
setTimer(b,1000,1,idkname) 

I will like that it change the color of the teamname every 1 second

I hope u can help me, thanks ^^

Regards.

Link to comment
  
function idkname () 
    local r = math.random(0,255) 
    local g = math.random(0,255) 
    local b = math.random(0,255) 
    team = createTeam ( "Team Name" ) 
    setTeamColor ( team, r, g, b )   
end 
addEventHandler("onResourceStart", resourceRoot, idkname) 
setTimer(r,1000,0,idkname) 
setTimer(g,1000,0,idkname) 
setTimer(b,1000,0,idkname) 
  

setTimer @ Arguement 3 was 1. It will only be executed 1 time if it was 1. 0 for unlimited times

Link to comment
  
  
function idkname () 
    local r = math.random(0,255) 
    local g = math.random(0,255) 
    local b = math.random(0,255) 
    team = createTeam ( "Team Name" ) 
    setTeamColor ( team, r, g, b )   
end 
addEventHandler("onResourceStart", resourceRoot, idkname) 
setTimer(idkname ,1000,0) 
  
  
  

Link to comment

wait

  
  
  
function idkname () 
    local r = math.random(0,255) 
    local g = math.random(0,255) 
    local b = math.random(0,255) 
    team = createTeam ( "Team Name" ) 
    setTeamColor ( team, r, g, b )   
end 
addEventHandler("onResourceStart", resourceRoot, idkname) 
setTimer(idkname,1000,0) 
   
  

This should work :#

Link to comment

Try this

function teams () 
  team = createTeam("YourTeam") 
  setTimer(randomCOLOR, 200, 0) 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), teams) 
  
function randomCOLOR () 
local R3 = math.random( 0, 255 ) 
local G3 = math.random( 0, 255 ) 
local B3 = math.random( 0, 255 ) 
  setTeamColor(team, R3, G3, B3) 
end 

Link to comment
  
    team = createTeam ( "Team Name" ) 
function idkname () 
    local r = math.random(0,255) 
    local g = math.random(0,255) 
    local b = math.random(0,255) 
    setTeamColor ( team, r, g, b )   
end 
setTimer(idkname ,1000,0) 
  

A lot of thanks, to the rest of person too ^^, Now I will like use "else"

For example, a color will be 255,0,0

and the other a random color, I will like to change it every second to a random, and after a second back to the red color, after a second a new random color and after a second back to the red color ....etc

It is possible ?

Link to comment
  
  
    team = createTeam ( "Team Name" ) 
function idkname () 
    local r = math.random(0,255) 
    local g = math.random(0,255) 
    local b = math.random(0,255) 
           if r == 255 then 
                setTeamColor ( team, r, g, b )   
           else 
                setTeamColor(team, r, g, b ) 
end 
end 
setTimer(idkname ,1000,0) 
  

Link to comment
  
  
    team = createTeam ( "Team Name" ) 
function idkname () 
    local r = math.random(0,255) 
    local g = math.random(0,255) 
    local b = math.random(0,255) 
           if r == 255 then 
                setTeamColor ( team, r, g, b )   
           else 
                setTeamColor(team, r, g, b ) 
end 
end 
setTimer(idkname ,1000,0) 
  

It doesnt work, It still giving a random color.

Link to comment

If the value of r is 255 then it will set r to 255.

  
local colors = { 
      {r=255,g=0,b=0}, -- SYNTAX: {r=rValue, g=gValue, b=bValue}, 
} 
    team = createTeam ( "Team Name" ) 
function idkname () 
      for k,v in ipairs(colors) 
          setTeamColor(team, v.r, v.g, v.b)  
    end 
end 
setTimer(idkname ,1000,0) 
  
  

Link to comment
If the value of r is 255 then it will set r to 255.
  
local colors = { 
      {r=255,g=0,b=0}, -- SYNTAX: {r=rValue, g=gValue, b=bValue}, 
} 
    team = createTeam ( "Team Name" ) 
function idkname () 
      for k,v in ipairs(colors) 
          setTeamColor(team, v.r, v.g, v.b)  
    end 
end 
setTimer(idkname ,1000,0) 
  
  

But I wont if R get 255 set that color,

I want

First color : 255,0,0

Second Color: random

First color, after a second random color, after a second red color, after a second a new random color.... Infinite times

Did u understand me ?

Link to comment

Oh

  
  
local colors = { 
      {r=255,g=0,b=0}, -- SYNTAX: {r=rValue, g=gValue, b=bValue}, 
} 
times = nil 
team = createTeam ( "Team Name" ) 
function idkname () 
      for k,v in ipairs(colors) 
          if times == "random" then 
               setTeamColor(team, math.random(0,255), math.random(0,255), math.random(0,255)) 
               times = "rgbcolor" 
               return  
          end 
          times = "random" 
          setTeamColor(team, v.r, v.g, v.b) 
    end 
end 
setTimer(idkname ,1000,0)  
  

Link to comment
Oh
  
  
local colors = { 
      {r=255,g=0,b=0}, -- SYNTAX: {r=rValue, g=gValue, b=bValue}, 
} 
times = nil 
team = createTeam ( "Team Name" ) 
function idkname () 
      for k,v in ipairs(colors) 
          if times == "random" then 
               setTeamColor(team, math.random(0,255), math.random(0,255), math.random(0,255)) 
               times = "rgbcolor" 
               return  
          end 
          times = "random" 
          setTeamColor(team, v.r, v.g, v.b) 
    end 
end 
setTimer(idkname ,1000,0)  
  

Huston, we have a problem line: 10

abc6ecbb7d.png

Link to comment
  
  
  
local colors = { 
      {r=255,g=0,b=0}, -- SYNTAX: {r=rValue, g=gValue, b=bValue}, 
} 
times = nil 
team = createTeam ( "Team Name" ) 
function idkname () 
      for k,v in ipairs(colors) do 
          if times == "random" then 
               setTeamColor(team, math.random(0,255), math.random(0,255), math.random(0,255)) 
               times = "rgbcolor" 
               return 
          end 
          times = "random" 
          setTeamColor(team, v.r, v.g, v.b) 
    end 
end 
setTimer(idkname ,1000,0) 
  
  

Link to comment
  
  
  
local colors = { 
      {r=255,g=0,b=0}, -- SYNTAX: {r=rValue, g=gValue, b=bValue}, 
} 
times = nil 
team = createTeam ( "Team Name" ) 
function idkname () 
      for k,v in ipairs(colors) do 
          if times == "random" then 
               setTeamColor(team, math.random(0,255), math.random(0,255), math.random(0,255)) 
               times = "rgbcolor" 
               return 
          end 
          times = "random" 
          setTeamColor(team, v.r, v.g, v.b) 
    end 
end 
setTimer(idkname ,1000,0) 
  
  

It is working perfectly, a lot of thanks, now u can do the last thing, Con u set 2 setTimer, for example, for

Primary Color: 255,0,0 (When we are on this color, take 5 seconds to change)

Second Color : Random (When we are on this, take 2 seconds to change)

Thanks newly ^^ <3

Link to comment

Thats pretty simple to do.

  
  
  
  
local colors = { 
      {r=255,g=0,b=0}, -- SYNTAX: {r=rValue, g=gValue, b=bValue}, 
} 
times = nil 
team = createTeam ( "Team Name" ) 
function idkname () 
      for k,v in ipairs(colors) do 
          if times == "random" then 
               setTeamColor(team, math.random(0,255), math.random(0,255), math.random(0,255)) 
               times = "rgbcolor" 
               return 
          end 
          if isTimer(timer) then 
              killTimer(timer) 
              timer = setTimer(idkname, 2000, 1) 
         end 
          times = "random" 
          setTeamColor(team, v.r, v.g, v.b) 
    end 
end 
timer = setTimer(idkname , 5000, 1) 
  
  
  

Link to comment
Thats pretty simple to do.
  
  
  
  
local colors = { 
      {r=255,g=0,b=0}, -- SYNTAX: {r=rValue, g=gValue, b=bValue}, 
} 
times = nil 
team = createTeam ( "Team Name" ) 
function idkname () 
      for k,v in ipairs(colors) do 
          if times == "random" then 
               setTeamColor(team, math.random(0,255), math.random(0,255), math.random(0,255)) 
               times = "rgbcolor" 
               return 
          end 
          if isTimer(timer) then 
              killTimer(timer) 
              timer = setTimer(idkname, 2000, 1) 
         end 
          times = "random" 
          setTeamColor(team, v.r, v.g, v.b) 
    end 
end 
timer = setTimer(idkname , 5000, 1) 
  
  
  

Thanks so much, I made a modification of seconds

local colors = { 
      {r=255,g=0,b=0}, -- SYNTAX: {r=rValue, g=gValue, b=bValue}, 
} 
times = nil 
team = createTeam ( "Team Name" ) 
function idkname () 
      for k,v in ipairs(colors) do 
          if times == "random" then 
               setTeamColor(team, math.random(0,255), math.random(0,255), math.random(0,255)) 
               times = "rgbcolor" 
               return 
          end 
          if isTimer(timer) then 
              killTimer(timer) 
              timer = setTimer(idkname, 1000, 0) 
         end 
          times = "random" 
          setTeamColor(team, v.r, v.g, v.b) 
    end 
end 
timer = setTimer(idkname , 5000, 0) 

But it doesn't work, for example, every seconds is changin of color, doesnt take 5 seconds in red, always is 1 second

Link to comment
  
local colors = { 
      {r=255,g=0,b=0}, -- SYNTAX: {r=rValue, g=gValue, b=bValue}, 
} 
times = nil 
team = createTeam ( "Team Name" ) 
function idkname () 
      for k,v in ipairs(colors) do 
          if times == "random" then 
               setTeamColor(team, math.random(0,255), math.random(0,255), math.random(0,255)) 
               times = "rgbcolor" 
               return 
          end 
          if isTimer(timer) then 
              killTimer(timer) 
              timer = setTimer(idkname, 1000, 1) 
         end 
          times = "random" 
          setTeamColor(team, v.r, v.g, v.b) 
    end 
end 
timer = setTimer(idkname , 5000, 1) 
  

Link to comment
  
local colors = { 
      {r=255,g=0,b=0}, -- SYNTAX: {r=rValue, g=gValue, b=bValue}, 
} 
times = nil 
team = createTeam ( "Team Name" ) 
function idkname () 
      for k,v in ipairs(colors) do 
          if times == "random" then 
               setTeamColor(team, math.random(0,255), math.random(0,255), math.random(0,255)) 
               times = "rgbcolor" 
               return 
          end 
          if isTimer(timer) then 
              killTimer(timer) 
              timer = setTimer(idkname, 1000, 1) 
         end 
          times = "random" 
          setTeamColor(team, v.r, v.g, v.b) 
    end 
end 
timer = setTimer(idkname , 5000, 1) 
  

Thanks newly, but as I told u, it doesnt take the right seconds on x color

Red color : 5 seconds being

Random Color: 1 second being and change to red again (5 seconds in red) and 1 second in random color for infinite times.

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