Member
|
06-28-2017
, 01:48
[CS GO] Bug with glowing
|
#1
|
Hello! I try to make weapons entities on the ground glowing. This code works, but for some reason, there is a shift in coordinates and the weapon will spawn high in the sky. (See screenshot).
Code:
void CreateWeapon(int i) //here i create weapon on the map
{
new index;
char buffer[64];
weapons.GetString(i,buffer,sizeof(buffer));
TrimString(buffer);
index=CreateEntityByName(buffer);
allWeapons[i][ind]=index;
if (index < 1)
{
LogError("Error during creating '%s'",buffer);
return;
}
SetEntProp(index, Prop_Send, "m_iItemDefinitionIndex", GetWeaponIndex(i));
DispatchKeyValueVector(index, "origin", spawnWeaponPositions[i]);
DispatchKeyValue(index, "spawnflags", "1");
entList[i]=index;
SetEntProp(index, Prop_Data, "m_iClip1", weaponClip(buffer));
SetEntProp(index, Prop_Send, "m_iPrimaryReserveAmmoCount",weaponReserve(buffer));
DispatchSpawn(index);
SDKHook(index, SDKHook_StartTouchPost, OnEntityTouch);
TeleportEntity(index, spawnWeaponPositions[i], NULL_VECTOR, NULL_VECTOR);
LogError("Create weapon ",i);
if(g_iGameState!=STATE_WARMUP)
{
SetSkin(i);
}
SetGlowing(index);
}
void SetGlowing(int entityIndex)
{
char model[128];
GetEntPropString(entityIndex, Prop_Data, "m_ModelName", model, 128)
int skin = CreateEntModelProp(entityIndex, model);
SetEntProp(skin, Prop_Send, "m_bShouldGlow", true, true);
SetEntProp(skin, Prop_Send, "m_nGlowStyle", 0);
SetEntPropFloat(skin, Prop_Send, "m_flGlowMaxDist", 10000000.0);
// So now setup given glow colors for the skin
SetEntData(skin, GetEntSendPropOffs(skin, "m_clrGlow"), 192, _, true); // Red
SetEntData(skin, GetEntSendPropOffs(skin, "m_clrGlow") + 1, 160, _, true); // Green
SetEntData(skin, GetEntSendPropOffs(skin, "m_clrGlow") + 2, 96, _, true); // Blue
SetEntData(skin, GetEntSendPropOffs(skin, "m_clrGlow") + 3, 64, _, true); // Alpha
}
int CreateEntModelProp(int entity, char[] sModel)
{
RemoveSkin(entity);
int Ent = CreateEntityByName("prop_dynamic_override");
DispatchKeyValue(Ent, "model", sModel);
DispatchKeyValue(Ent, "disablereceiveshadows", "1");
DispatchKeyValue(Ent, "disableshadows", "1");
DispatchKeyValue(Ent, "solid", "0");
DispatchKeyValue(Ent, "spawnflags", "256");
SetEntProp(Ent, Prop_Send, "m_CollisionGroup", 11);
DispatchSpawn(Ent);
SetEntProp(Ent, Prop_Send, "m_fEffects", EF_BONEMERGE|EF_NOSHADOW|EF_NORECEIVESHADOW|EF_PARENT_ANIMATES);
SetVariantString("!activator");
AcceptEntityInput(Ent, "SetParent", entity, Ent, 0);
SetVariantString("primary");
AcceptEntityInput(Ent, "SetParentAttachment", Ent, Ent, 0);
return Ent;
}
void RemoveSkin(entity)
{
if(IsValidEntity(entity))
{
AcceptEntityInput(entity, "Kill");
}
SetEntityRenderMode(entity, RENDER_NORMAL);
}
spawnWeaponPositions[i] i recieve from file.
Why can this happen? I just need to get the weapons' entities to shine through the walls.)
Last edited by ElectricStalin; 06-30-2017 at 16:32.
|
|