Jump to content

.


DarkByte

Recommended Posts

This is what you're looking for:

local maxPoints = 75 
  
function onCmd(cmd, myPoints) 
    local color = (255 / maxPoints) * myPoints 
    local r,g,b = 255-color, 255, 255-color 
     
    outputChatBox("You have "..myPoints.." points.", r, g, b) 
end 
addCommandHandler("setPoints", onCmd, false) 
  

It goes from white to green. You can easily modify it and take the math to use it in your code.

I suppose it'll get a little more difficult if you want to go from say, purple to orange, but this is all I can do for you.

Why just don't you use the cases.

Because math.

Link to comment
Ok so whats wrong with your code?

When the points are 0, the color is white &when the points are 75 the color is fully green.

You just need to change tocolor(0,calc,0,255)

Right? Or what?

Nope it's not what i want when it's 0 it's green and when it's 75 it's white.

Link to comment
Ok so whats wrong with your code?

When the points are 0, the color is white &when the points are 75 the color is fully green.

You just need to change tocolor(0,calc,0,255)

Right? Or what?

Nope it's not what i want when it's 0 it's green and when it's 75 it's white.

@Tails - Thanks it's working now. :D

Link to comment

You're welcome. But like I said, it gets a bit more difficult with other colors than red, green and blue. It may involve different kind of maths if you want to keep everything short and simple. I can't really help you with it, because I know very little about maths. Hopefully you'll figure it out or someone is able to help you. Good luck. :)

Link to comment

Admin - Purple - R,G,B - 183,0,255

Admin - White - R,G,B - 255,255,255

So at start, G should be 255 as well as R; to be white.

MaxPoints are 375;

The G should be 0 by the end and the R should be 183.

colorG = (255/maxPoints) * reputation

colorR = ((255 - 183) / maxPoints ) * reputation

tocolor(255 - colorR, 255 - colorG,255)

That would probably work.

It will start with white and end up with purple.

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