AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [CS GO] Bug with glowing (https://forums.alliedmods.net/showthread.php?t=298965)

ElectricStalin 06-28-2017 01:48

[CS GO] Bug with glowing
 
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.)

Lord_SAmMY 06-28-2017 09:24

Re: [CS GO] Bug with glowing
 
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]); ?

ElectricStalin 06-28-2017 10:33

Re: [CS GO] Bug with glowing
 
Quote:

Originally Posted by Lord_SAmMY (Post 2532215)
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.

Lord_SAmMY 06-28-2017 11:02

Re: [CS GO] Bug with glowing
 
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 


ElectricStalin 06-28-2017 12:06

Re: [CS GO] Bug with glowing
 
Quote:

Originally Posted by Lord_SAmMY (Post 2532240)
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

andi67 06-28-2017 12:57

Re: [CS GO] Bug with glowing
 
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......

ElectricStalin 06-30-2017 16:32

Re: [CS GO] Bug with glowing
 
Btw, i have solved the problem. I delete this: RemoveSkin(entity); and add deleting of the glow object to event ItemPickup

emialcaraz 08-05-2017 11:26

Re: [CS GO] Bug with glowing
 
Can you share the code?


All times are GMT -4. The time now is 22:32.

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