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

Solved Problem with env_explosion


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FrAgOrDiE
AlliedModders Donor
Join Date: May 2018
Location: Italy
Old 02-02-2021 , 06:51   Problem with env_explosion
Reply With Quote #1

Hello, I'm trying to create an explosion effect on an entity after hit, then I kill the entity.
Here's the code, the problem with this is that the shooter can't see the explosion, any other player can.
Why is this happening?
PHP Code:
void SpawnCrate()
{
    ...
    
SDKHook(crateSDKHook_TraceAttackPostSDKCB_Hit);
    ...
}

public 
void SDKCB_Hit(int victimint attackerint inflictorfloat damageint damagetypeint ammotypeint hitboxint hitgroup)
{    
    
float fPos[3];
    
GetEntPropVector(g_CrateProp_Send"m_vecOrigin"fPos);
    
    
CreateExplosion(fPos);
    
AcceptEntityInput(g_Crate"Kill");
    
//CratePickup(attacker);
    
    
g_Crate INVALID_ENT_REFERENCE;
}

void CreateExplosion(float pos[3])
{
    
int explode CreateEntityByName("env_explosion");
    if (
explode == -1)
        return;
    
DispatchKeyValue(explode"iMagnitude""0");
    
DispatchKeyValue(explode"rendermode""5");
    
DispatchKeyValue(explode"classname""weapon_c4");
    
DispatchSpawn(explode);
    
TeleportEntity(explodeposNULL_VECTORNULL_VECTOR);
    
AcceptEntityInput(explode"Explode");

Edit: fixed with tempents.
__________________
Add me on discord: FrAgOrDiE#5182
Add me on steam: https://steamcommunity.com/id/fragordie002/
Join my discord server: http://discord.gg/JpAUXMn

Last edited by FrAgOrDiE; 02-03-2021 at 07:46.
FrAgOrDiE is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 02-02-2021 , 12:33   Re: Problem with env_explosion
Reply With Quote #2

PHP Code:
void CreateExplosion(float pos[3])
{
    
int explode CreateEntityByName("env_explosion");
    if (
explode == -1)
        return;

    
DispatchKeyValue(explode"fireballsprite""sprites/zerogxplode.spr");
    
DispatchKeyValue(explode"iMagnitude""0");
    
DispatchKeyValue(explode"iRadiusOverride""0");
    
DispatchKeyValue(explode"rendermode""5");
    
DispatchKeyValue(explode"spawnflags""1"); // no damage
    
DispatchKeyValue(explode"classname""weapon_c4");
    
DispatchSpawn(explode);
    
TeleportEntity(explodeposNULL_VECTORNULL_VECTOR);
    
AcceptEntityInput(explode"Explode");


__________________
Ilusion9 is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 02-02-2021 , 14:05   Re: Problem with env_explosion
Reply With Quote #3

Ever thought about using a TempEffect?
https://sm.alliedmods.net/new-api/sd...SetupExplosion

And what is the goal, just simply create an Explosion if Player is Hit?
__________________
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
Reply



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 16:52.


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