Actually this is might be useful for someone. You can modulate players color, weapon, viewmodel.
But, one thing you need to know, the model should be with specific flag to make this work even in dark areas, where light is not exists. Without model editing, this will only work where the skybox illuminates the surface of the map.
So, you can decompile model and add into .qc file line with:
$flags 1024
Example of .qc file after editing:
This flag forces lights the model directly from light_environment, no matter where it is in the map.
Also this flag makes model always with maximum light level (lambert).
Spoiler
Code:
#include <amxmodx>
#include <fakemeta>
#define NULL 0
#define NULLENT -1
new c_light_environment
//Force skyvector to fix shape shadows from player models.
new const c_world_skylight[][] =
{
"sv_skyvec_x 0.0",
"sv_skyvec_y 0.0",
"sv_skyvec_z -0.5"
}
public plugin_init()
{
Function_WorldSkylight();
#define LIGHT_ENVIRONMENT_SPAWN_TIMER 1.0
set_task(LIGHT_ENVIRONMENT_SPAWN_TIMER, "Function_ColorModulation")
}
public Function_ColorModulation()
{
#define COLOR_MODULATION_TIMER 0.1
new iLightEnvironment = NULLENT;
//Not found.
while((iLightEnvironment = engfunc(EngFunc_FindEntityByString, iLightEnvironment, "classname", "light_environment")) == NULL)
{
Function_LightEnvironment("255 255 255 255");
server_print("light_environment created");
}
//Randomize selection.
#define iRandom_R random_num(0, 255)
#define iRandom_G random_num(0, 255)
#define iRandom_B random_num(0, 255)
new iKeyValue[64], iAllocMessage[64];
iAllocMessage= "%d %d %d 255";
formatex(iKeyValue, charsmax(iKeyValue), iAllocMessage, iRandom_R, iRandom_G, iRandom_B);
//Set keys.
Set_Kvd(c_light_environment, "_light", iKeyValue, "light_environment");
//Repeat.
set_task(COLOR_MODULATION_TIMER, "Function_ColorModulation");
}
stock Function_LightEnvironment(const iKeyValue[])
{
//Create the light environment, will be spawned automatically.
c_light_environment = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "light_environment"));
//Set attributes.
Set_Kvd(c_light_environment, "_light", iKeyValue, "light_environment");
}
stock Set_Kvd(iEntity, const key[], const value[], const classname[])
{
set_kvd(NULL, KV_ClassName, classname);
set_kvd(NULL, KV_KeyName, key);
set_kvd(NULL, KV_Value, value);
set_kvd(NULL, KV_fHandled, NULL);
dllfunc(DLLFunc_KeyValue, iEntity, NULL);
}
stock Function_WorldSkylight()
{
for(new i = NULL; i < sizeof c_world_skylight; i ++)
server_cmd(c_world_skylight[i]);
}