Raised This Month: $12 Target: $400
 3% 

Solved [CS GO] Bug with glowing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ElectricStalin
Member
Join Date: Apr 2017
Old 06-28-2017 , 01:48   [CS GO] Bug with glowing
Reply With Quote #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).

Spoiler

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.
ElectricStalin is offline
Lord_SAmMY
Junior Member
Join Date: Jun 2017
Old 06-28-2017 , 09:24   Re: [CS GO] Bug with glowing
Reply With Quote #2

I think it would be interesting to see the source of your coordinates.
  • How they got written
  • How they got loaded

Btw did you try to comment out DispatchKeyValueVector(index, "origin", spawnWeaponPositions[i]); ?
Lord_SAmMY is offline
ElectricStalin
Member
Join Date: Apr 2017
Old 06-28-2017 , 10:33   Re: [CS GO] Bug with glowing
Reply With Quote #3

Quote:
Originally Posted by Lord_SAmMY View Post
I think it would be interesting to see the source of your coordinates.
  • How they got written
  • How they got loaded

Btw did you try to comment out DispatchKeyValueVector(index, "origin", spawnWeaponPositions[i]); ?
I read they from file. It is no so interesting.
Code:
	while (!IsEndOfFile(file) && ReadFileLine(file, buffer, sizeof(buffer)))
	{
		ExplodeString(buffer, " ", parts, 6, 16);
		spawnWeaponPositions[spawnWeaponPointCount][0] = StringToFloat(parts[0]);
		spawnWeaponPositions[spawnWeaponPointCount][1] = StringToFloat(parts[1]);
		spawnWeaponPositions[spawnWeaponPointCount][2] = StringToFloat(parts[2])-50.0;
		spawnWeaponAngles[spawnWeaponPointCount][0] = StringToFloat(parts[3])+0.25;
		spawnWeaponAngles[spawnWeaponPointCount][1] = StringToFloat(parts[4])+0.25;
		spawnWeaponAngles[spawnWeaponPointCount][2] = StringToFloat(parts[5])+0.25;
		spawnWeaponPointCount++;
	}
Also, it work perfect, if i dont use SetGlowing(index); all weapons spawn in right coords.
ElectricStalin is offline
Lord_SAmMY
Junior Member
Join Date: Jun 2017
Old 06-28-2017 , 11:02   Re: [CS GO] Bug with glowing
Reply With Quote #4

Quote:
Also, it work perfect, if i dont use SetGlowing(index); all weapons spawn in right coords.
This information was missing

Did you try this:
PHP Code:
LogError("Create weapon ",i); 
if(
g_iGameState!=STATE_WARMUP)
{
    
SetSkin(i);
}
SetGlowing(index);
TeleportEntity(indexspawnWeaponPositions[i], NULL_VECTORNULL_VECTOR); // at last 
Lord_SAmMY is offline
ElectricStalin
Member
Join Date: Apr 2017
Old 06-28-2017 , 12:06   Re: [CS GO] Bug with glowing
Reply With Quote #5

Quote:
Originally Posted by Lord_SAmMY View Post
This information was missing

Did you try this:
PHP Code:
LogError("Create weapon ",i); 
if(
g_iGameState!=STATE_WARMUP)
{
    
SetSkin(i);
}
SetGlowing(index);
TeleportEntity(indexspawnWeaponPositions[i], NULL_VECTORNULL_VECTOR); // at last 
I tried this. Weapons didnt appear on the map, but in logs i see, that they were created and spawned
ElectricStalin is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 06-28-2017 , 12:57   Re: [CS GO] Bug with glowing
Reply With Quote #6

Well with your code no one can see from where you get the positions to spawn your entitys, from GetClientAbsOrigin or Eyeangels or from what , so if you do this "spawnWeaponPositions[spawnWeaponPointCount][2] = StringToFloat(parts[2])-50.0;"
it could be that the entity is spawned under the ground so you will not see it......
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
ElectricStalin
Member
Join Date: Apr 2017
Old 06-30-2017 , 16:32   Re: [CS GO] Bug with glowing
Reply With Quote #7

Btw, i have solved the problem. I delete this: RemoveSkin(entity); and add deleting of the glow object to event ItemPickup
ElectricStalin is offline
emialcaraz
Member
Join Date: Oct 2016
Location: Argentina
Old 08-05-2017 , 11:26   Re: [CS GO] Bug with glowing
Reply With Quote #8

Can you share the code?
emialcaraz is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode