Added GetEntityRenderColor

This commit is contained in:
Bara 2015-04-04 01:38:30 +02:00
parent 88c4618230
commit 1748a411e1

View File

@ -370,6 +370,49 @@ stock SetEntityRenderFx(entity, RenderFx:fx)
SetEntProp(entity, Prop_Send, prop, fx, 1);
}
/**
* Gets an entity's color.
*
* @param entity Entity index.
* @param r Amount of red (0-255)
* @param g Amount of green (0-255)
* @param b Amount of blue (0-255)
* @param a Amount of alpha (0-255)
* @noreturn
* @error Invalid entity index, or lack of mod compliance.
*/
stock GetEntityRenderColor(entity, &r, &g, &b, &a)
{
static bool:gotconfig = false;
static String:prop[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_clrRender", prop, sizeof(prop));
CloseHandle(gc);
if (!exists)
{
strcopy(prop, sizeof(prop), "m_clrRender");
}
gotconfig = true;
}
new offset = GetEntSendPropOffs(entity, prop);
if (offset <= 0)
{
ThrowError("GetEntityRenderColor not supported by this mod");
}
r = GetEntData(entity, offset, 1);
g = GetEntData(entity, offset + 1, 1);
b = GetEntData(entity, offset + 2, 1);
a = GetEntData(entity, offset + 3, 1);
}
/**
* Sets an entity's color.
*