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

Ring Backpack


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MayroN
Senior Member
Join Date: Aug 2017
Location: Kyiv
Old 03-30-2022 , 18:24   Ring Backpack
Reply With Quote #1

One person added a code so that the ring would be displayed on a thrown bomb

Here is his screenshot



The fact is that if I throw a bomb, it will immediately disappear along with the ring without touching the ground ....

There is also a smoke option. - but oddly enough - it works fine for me

Tell me what could be wrong in the code

Tested with this plugin

thanks for the help

PHP Code:
#pragma semicolon 1

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <engine>

new g_Backpack_SmokeSprite;

#define BOMB_PACK_ICON        "sprites/backpack_smoke/backpack_ring.spr"
#define BRINGHTNEES            255.0

new Float:fColor[][3] = {
    {
255.00.00.0},
    {
0.00.0255.0},
    {
0.0255.00.0},
    {
255.0255.06.0},
    {
255.00.0255.0}
};

public 
plugin_init()
{
    
register_plugin("C4 Smoke""1.0""fl0wer");

    
register_forward(FM_SetModel"@FM_SetModel_Post"true);

    
RegisterHam(Ham_Think"weaponbox""@CWeaponBox_Think_Pre"false);
    
    
register_think("C4_Ring""@C4_Ring_Think");
}

public 
plugin_precache()
{
    
g_Backpack_SmokeSprite precache_model("sprites/backpack_smoke/backpack_smoke.spr");
    
precache_model(BOMB_PACK_ICON);
}

@
FM_SetModel_Post(entmodel[])
{
    if (
containi(model"w_backpack") == -1)
        return;
    
    
set_pev(entpev_iuser11);
    
set_pev(entpev_iuser3random_num(01));
    
set_pev(entpev_nextthinkget_gametime() + 0.2);
}

@
CWeaponBox_Think_Pre(id)
{
    new 
Float:time get_gametime();
    
    if (!
pev(idpev_iuser1))
        return 
HAM_IGNORED;
        
    
set_pev(idpev_nextthinktime 0.2);

    new 
Float:vecOrigin[3];    pev(idpev_originvecOrigin);
    
    switch(
pev(idpev_iuser3))    {
        case 
0:    {
            
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYvecOrigin0);
            
write_byte(TE_FIREFIELD);
            
engfunc(EngFunc_WriteCoordvecOrigin[0]);
            
engfunc(EngFunc_WriteCoordvecOrigin[1]);
            
engfunc(EngFunc_WriteCoordvecOrigin[2] += 15.0);
            
write_short(2);
            
write_short(g_Backpack_SmokeSprite);
            
write_byte(1);
            
write_byte(TEFIRE_FLAG_ALLFLOAT TEFIRE_FLAG_ALPHA);
            
write_byte(10);
            
message_end();
        }
        case 
1:    {
            if (
pev(idpev_iuser2))
                return 
HAM_IGNORED;
            
            
vecOrigin[2] += 30.0;
            
engfunc(EngFunc_SetOriginidvecOrigin);
            
            new 
iEnt create_entity("env_sprite");
            
set_pev(iEntpev_classname"C4_Ring");
            
engfunc(EngFunc_SetOriginiEntvecOrigin);
            
engfunc(EngFunc_SetModeliEntBOMB_PACK_ICON);
            
set_pev(iEntpev_solidSOLID_NOT);
            
set_pev(iEntpev_movetypeMOVETYPE_FLY);
            
set_pev(iEntpev_iuser1id);
            
set_pev(iEntpev_nextthinktime 0.1);
            
            
set_pev(iEntpev_renderamtBRINGHTNEES);
        
//    set_pev(iEnt, pev_rendermode, kRenderTransAdd);            //    Раскоментируй если нужна прозрачность
            
set_pev(iEntpev_rendercolorfColor[random_num(0charsmax(fColor))]);
            
            
set_pev(idpev_iuser2iEnt);
        }
    }
    
    return 
HAM_SUPERCEDE;
}

@
C4_Ring_Think(ent)    {
    if (!
pev_valid(ent))
        return;
    
    if (!
pev_valid(pev(entpev_iuser1)))    {
        
remove_entity(ent);
        return;
    }
    
    
set_pev(entpev_nextthinkget_gametime() + 0.1);

__________________
МультиМод CS 83.222.97.124:27015

MayroN is offline
Send a message via ICQ to MayroN Send a message via Skype™ to MayroN
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 03-30-2022 , 19:33   Re: Ring Backpack
Reply With Quote #2

PHP Code:
set_pev(iEntpev_nextthinktime 0.1
It seems that when removing that part, the model is set and not removed.
Edit: I edited some parts of the code, I know it's not the right section but I had free time to do so. I've named the changes so it's easier for you to understand 'em.
By my perspective, your code was doing some weird things besides that issue. Let me know if that code I'm providing is what you wanted, it doesn't conflict with the Weapon Physics and also skips the wall.

PHP Code:
#pragma semicolon 1

#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <xs>

new g_Backpack_SmokeSprite;

#define BOMB_PACK_ICON        "sprites/backpack_smoke/backpack_ring.spr"
#define RING_CLASSNAME        "Bomb_Ring"

#define RING_BOMB_ENTITY    pev_iuser1

new Float:fColor[][3] = 
{
    {
255.00.00.0},
    {
0.00.0255.0},
    {
0.0255.00.0},
    {
255.0255.06.0},
    {
255.00.0255.0}
};

public 
plugin_init()
{
    
register_plugin("C4 Smoke""1.0""fl0wer");
    
    
register_touch("worldspawn""weaponbox""weaponboxTouch");
    
register_think(RING_CLASSNAME"ringThink");
}

public 
plugin_precache()
{
    
g_Backpack_SmokeSprite precache_model("sprites/backpack_smoke/backpack_smoke.spr");
    
precache_model(BOMB_PACK_ICON);
}

public 
weaponboxTouch(iWorldSpawniBombEntity)
{
    if(!
pev_valid(iBombEntity))
        return 
PLUGIN_HANDLED;
        
    static 
szBombModel[32];
    
pev(iBombEntitypev_modelszBombModelcharsmax(szBombModel));
    if(
containi(szBombModel"w_backpack") == -1)
        return 
PLUGIN_HANDLED;
        
    if(
pev(iBombEntitypev_flags) & ~FL_ONGROUND
        return 
PLUGIN_HANDLED;
        
    static 
Float:vecOrigin[3];
    
pev(iBombEntitypev_originvecOrigin);
        
    
// lie flat code ^^
    
static Float:fTraceTo[3], Float:fFraction;
    
xs_vec_sub(vecOriginFloat:{0.00.010.0}, fTraceTo);
    
    
engfunc(EngFunc_TraceLinevecOriginfTraceToIGNORE_MONSTERSiBombEntity0);
    
get_tr2(0TR_flFractionfFraction);
    if(
fFraction == 1.0
        return 
PLUGIN_HANDLED;
        
    static 
bombEntity;bombEntity pev(iBombEntityRING_BOMB_ENTITY);
    if(
bombEntity)
    {
        if(
bombEntity get_maxplayers())
        {
            
remove_task(iBombEntity);
            
set_task(0.5"makeBombFloat"iBombEntity);
        }
        return 
PLUGIN_HANDLED;
    }
    switch(
random_num(01))    
    {
        case 
0:  
        {
            
remove_task(iBombEntity);
            
            
set_pev(iBombEntityRING_BOMB_ENTITYpev(iBombEntitypev_owner));
            
smokeEffect(iBombEntity);
        }
        case 
1:    
        {        
            new 
iEnt create_entity("env_sprite");
            if(
pev_valid(iEnt))
            {
                
set_pev(iBombEntityRING_BOMB_ENTITYiEnt);
                
                
remove_task(iBombEntity);
                
set_task(0.5"makeBombFloat"iBombEntity);
            }
        }
    }
    return 
PLUGIN_HANDLED;
}

public 
makeBombFloat(iBombEntity)
{
    if(!
pev_valid(iBombEntity))
        return;
        
    static 
Float:vecOrigin[3], iRingEntity;iRingEntity pev(iBombEntityRING_BOMB_ENTITY);
    
pev(iBombEntitypev_originvecOrigin);
    
vecOrigin[2] += 30.0;
    
engfunc(EngFunc_SetOriginiBombEntityvecOrigin);
    
    
// use this to change the ring origin, so you can make the bomb be right in the middle
    
vecOrigin[2] += 0.0;
    
engfunc(EngFunc_SetOriginiRingEntityvecOrigin);

    
set_pev(iRingEntitypev_classnameRING_CLASSNAME);
    
engfunc(EngFunc_SetOriginiRingEntityvecOrigin);
    
engfunc(EngFunc_SetModeliRingEntityBOMB_PACK_ICON);
    
set_pev(iRingEntitypev_solidSOLID_NOT);
    
set_pev(iRingEntitypev_movetypeMOVETYPE_FLY);
    
set_pev(iRingEntitypev_nextthinkget_gametime());
    
set_pev(iRingEntityRING_BOMB_ENTITYiBombEntity);
    
set_pev(iRingEntitypev_rendercolorfColor[random_num(0charsmax(fColor))]);
}

public 
smokeEffect(iBombEntity)
{
    if(!
pev_valid(iBombEntity))
        return;
    
    static 
Float:vecOrigin[3];
    
pev(iBombEntitypev_originvecOrigin);
    
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYvecOrigin0);
    
write_byte(TE_FIREFIELD);
    
engfunc(EngFunc_WriteCoordvecOrigin[0]);
    
engfunc(EngFunc_WriteCoordvecOrigin[1]);
    
engfunc(EngFunc_WriteCoordvecOrigin[2] += 15.0);
    
write_short(2);
    
write_short(g_Backpack_SmokeSprite);
    
write_byte(1);
    
write_byte(TEFIRE_FLAG_ALLFLOAT TEFIRE_FLAG_ALPHA);
    
write_byte(10);
    
message_end();
    
    
set_task(0.3"smokeEffect"iBombEntity);
}

public 
ringThink(ent)    
{
    if(!
pev_valid(ent))
        return;
    
    if(!
pev_valid(pev(entRING_BOMB_ENTITY)))    
    {
        
remove_entity(ent);
        return;
    }
    
    
set_pev(entpev_nextthinkget_gametime() + 0.5);

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 04-02-2022 at 16:35.
EFFx is offline
Old 03-31-2022, 02:15
Natsheh
This message has been deleted by Natsheh. Reason: Nvm
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 04-01-2022 , 09:32   Re: Ring Backpack
Reply With Quote #3

offtop: what's the point of @ in the function name?
PHP Code:
@FM_SetModel_Post(entmodel[]) {...} 
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951

Last edited by kww; 04-01-2022 at 09:33.
kww is offline
MayroN
Senior Member
Join Date: Aug 2017
Location: Kyiv
Old 04-02-2022 , 14:27   Re: Ring Backpack
Reply With Quote #4

Quote:
Originally Posted by kww View Post
offtop: what's the point of @ in the function name?
PHP Code:
@FM_SetModel_Post(entmodel[]) {...} 
@ this is used instead of public
__________________
МультиМод CS 83.222.97.124:27015

MayroN is offline
Send a message via ICQ to MayroN Send a message via Skype™ to MayroN
MayroN
Senior Member
Join Date: Aug 2017
Location: Kyiv
Old 04-02-2022 , 14:29   Re: Ring Backpack
Reply With Quote #5

This Code is the most accurate and working version without any bugs and nuances
We have been moving towards this for a long time - and now we can proudly say this

https://forums.alliedmods.net/showpo...71&postcount=2
__________________
МультиМод CS 83.222.97.124:27015

MayroN is offline
Send a message via ICQ to MayroN Send a message via Skype™ to MayroN
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 04-02-2022 , 18:06   Re: Ring Backpack
Reply With Quote #6

Quote:
Originally Posted by MayroN View Post
@ this is used instead of public
Understood, ty
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951
kww is offline
SHIELD755
Veteran Member
Join Date: Feb 2018
Location: FROM MARVEL STUDIO
Old 04-03-2022 , 13:05   Re: Ring Backpack
Reply With Quote #7

Non steam cs :

Sus
__________________
SED LYF !!!
SHIELD755 is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 04-04-2022 , 08:57   Re: Ring Backpack
Reply With Quote #8

Quote:
Originally Posted by SHIELD755 View Post
Non steam cs :

Sus
*Non steam cs was not an impostor...*
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951
kww 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:31.


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