Pick Random Car (or entity) Color

Meant to be used with the stock car instances. Mainly the benefit is losing two entities (logic_auto and the logic_switch) for each instance. Plus you can edit colors without a recompile.

To use it, remove those two entities from your car instance, and on your prop_physics car, turn off smartedit and add a key "vscripts" with a value of "carscript", *note - do NOT type the quotes.

Save this script under scripts/vscripts

Update: 2012.06.20 I modified it to work on unnamed entities. Also note this can't work on prop_static's as they have no IO.

/*
carscript.nut
author: Lee Pumphret
http://www.leeland.info

A simple script to pick a random color when a car (or other entity) spawns
*/


/* add additional colors below */
CarColors <- [
 "153 65 29",
 "52 46 46",
 "253 241 203",
 "84 101 144",
 "212 158 70",

];

local Color = RandomInt(1,CarColors.len());

//printl("Color is " + CarColors[Color-1]);

DoEntFire("!self", "Color", CarColors[Color-1],0,null,self);

Scroll to top