Welcome to Open Carnage

A resource for modders and technology enthusiasts; have a wander to see why we're worth the time! EST. 2012

Sign in to follow this  
Followers 0
Corrupt

Help with custom team colors script

I have a modified version of the custom team colors which has been working pretty well, but I'd like to optimize it. I assign players either shades of red or blue based on team and player index, but I would like to ensure there are no duplicate colors until necessary. Right now it works assuming players do not switch teams, but if they do, there might be more than one player of a certain color before hitting all options.

 

I could use some help understanding what I can do. Can I set variables as arrays of integers? I tried these but it didn't seem to work:

redColors = [2,11,17,14]

redColors[4] = [2,11,17,14]

 

I would then set the player color to redColors[$reds % 4]. Also, can I use the modulus command?


rpXOaLY.png

...

Share this post


Link to post
Share on other sites

Members of Open Carnage never see off-site ads.

You use curly braces to initialize arrays.

the_array = { 0, 1, 2, 3, 4 }

You can use square brackets to specify keys, such as if you're trying to make a hash map.

the_array = { ["a"] = 0, ["b"] = "hi", ["c"] = 5 }

You do not specify the size of the array before initializing it, as they aren't being statically allocated.

 

You can use the modulus operator.

Corrupt and WaeV like this

Share this post


Link to post
Share on other sites

Awesome, thanks 002. I was able to get it working pretty much as desired. It also threw me off that arrays start with 1 instead of 0. Apologies for my terminology, its been forever since I've actually coded.


rpXOaLY.png

...

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0
  • Recently Browsing   0 members

    No registered users viewing this page.