This is the full code. It's the last line of code that sets the rendering. The plugin is basically the original plugin which you can find
here:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fun>
#define PLUGIN "Glowing Color By Speed"
#define VERSION "1.0"
#define AUTHOR "Garey"
#define FREQ 0.1
new bool:plrGlow[33] = { true, ... };
new TaskEnt,g_glowamount,g_minspeed,g_maxspeed, maxplayers
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("Garey", "Glowing Color By Speed", FCVAR_SERVER)
register_forward(FM_Think, "Think")
TaskEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
set_pev(TaskEnt, pev_classname, "speedometer_think")
set_pev(TaskEnt, pev_nextthink, get_gametime() + 1.01)
g_glowamount=register_cvar("gbs_amount", "25")
g_minspeed=register_cvar("gbs_glow_min_speed", "250")
g_maxspeed=register_cvar("gbs_glow_max_speed", "1500")
maxplayers = get_maxplayers()
}
public Think(ent)
{
if(ent == TaskEnt)
{
SpeedTask()
set_pev(ent, pev_nextthink, get_gametime() + FREQ)
}
}
public client_putinserver(id)
{
plrGlow[id] = true
}
stock dynamicColor(min,max,Float:value,&red,&green,&blue)
{ //Don`t launch with max ~= min
#define MaxC 255
#define MinC 0
#define DtC 255
if (value>=max)
{
red=MaxC;
green=MinC;
blue=MinC;
return;
}
else if (value<=min)
{
red=MinC;
green=MinC;
blue=MaxC;
return;
}
new Float:step = (max-min)/4.0;
new Float:dt = value-min;
if (dt <= step)
{
red = MinC;
green = floatround(dt*(DtC/step));
blue = MaxC;
}
else if (dt-=step, dt <= step)
{
red = MinC;
green = MaxC;
blue = floatround((step-dt)*(DtC/step));
}
else if (dt-=step, dt <= step)
{
red = floatround(dt*(DtC/step));
green = MaxC;
blue = MinC;
}
else
{
dt-=step;
red = MaxC;
green = floatround((step-dt)*(DtC/step));
blue = MinC;
}
return;
}
SpeedTask()
{
static i, target
static Float:velocity[3]
static Float:speedh
for(i=1; i<=maxplayers; i++)
{
if(!is_user_alive(i)) continue
if(!plrGlow[i]) continue
target = pev(i, pev_iuser1) == 4 ? pev(i, pev_iuser2) : i
pev(target, pev_velocity, velocity)
speedh = floatsqroot(floatpower(velocity[0], 2.0) + floatpower(velocity[1], 2.0))
static r, g, b
dynamicColor(get_pcvar_num(g_minspeed),get_pcvar_num(g_maxspeed),speedh,r,g,b)
set_user_rendering(i, kRenderFxGlowShell, r, g ,b ,kRenderNormal, get_pcvar_num(g_glowamount))
}
}
Edit: While if I look at the player, the glow is very thick, if I look at myself I get the wanted result (it's a very thin glow). I am using a 3rd person view plugin to see myself.
Picture:
__________________
We all live under the same sky but we have different horizons.