AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Muzzle in rehlds not work. (https://forums.alliedmods.net/showthread.php?t=335706)

krisztian2 12-26-2021 15:37

Muzzle in rehlds not work.
 
Dear Scripters!

This plugin in rehlds engine not work. But in default engine this work.
What's the problem with this?
The entity is not equal with iEnt.
Code:

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

#define PLUGIN_NAME                    "New MuzzleFlash"
#define PLUGIN_VERSION                "Alpha"
#define PLUGIN_AUTHOR                "WPMG Team"

// ?????? ? ??????
#define get_bit(%1,%2)        (%1 & (1 << (%2 & 31)))
#define set_bit(%1,%2)        %1 |= (1 << (%2 & 31))
#define reset_bit(%1,%2)    %1 &= ~(1 << (%2 & 31))

new g_bitsMuzzleFlash;

new g_iEntity;

new const spriteok[][] = {
{"sprites/Red/muzzleflash1.spr" },
};

public plugin_precache()
{
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
   
        for(new i=0;i< sizeof(spriteok);i++)
        {
    precache_model(spriteok[i]);
    }
   
}

public plugin_init()
{
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ak47", "WEAPON__PrimaryAttack_Post", 1);
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_m4a1", "WEAPON__PrimaryAttack_Post", 1);
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_awp", "WEAPON__PrimaryAttack_Post", 1);
    RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "WEAPON__PrimaryAttack_Post", 1);
   
    register_forward(FM_AddToFullPack, "CPlayer__AddToFullPack_post", 1);
   
    register_forward(FM_CheckVisibility, "CEntity__CheckVisibility");
        g_iEntity = create_entity("info_target");
       
}

public CEntity__CheckVisibility(iEntity, pSet)
{
    if (iEntity != g_iEntity)
        return FMRES_IGNORED;
   
    forward_return(FMV_CELL, 1);
   
    return FMRES_SUPERCEDE;
}

public WEAPON__PrimaryAttack_Post(iEntity)
{
    new iPlayerID = get_pdata_cbase(iEntity, 41, 4);

    if(!cs_get_weapon_silen(iEntity)){
    set_bit(g_bitsMuzzleFlash, iPlayerID);
        }
        else{
        return;
        }
}

public CPlayer__AddToFullPack_post(esState, iE, iEnt, iHost, iHostFlags, iPlayer, pSet)
{
    if (iEnt != g_iEntity){ //The problem is different entity.
        return;
        }
   
    if (get_bit(g_bitsMuzzleFlash, iHost))
    {
        set_es(esState, ES_Frame, float(random_num(0, 2)));
           
        set_es(esState, ES_RenderMode, kRenderTransAdd);
        set_es(esState, ES_RenderAmt, 255.0);
       
        reset_bit(g_bitsMuzzleFlash, iHost);
    }
        new fgy[32];
        fgy[iHost] = get_user_weapon(iHost);
        if(fgy[iHost] == CSW_AK47 || fgy[iHost] == CSW_M4A1 || fgy[iHost] == CSW_AWP || fgy[iHost] == CSW_FAMAS || fgy[iHost] == CSW_M4A1){
    entity_set_model(g_iEntity, spriteok[0]);
        }
        entity_set_float(g_iEntity, EV_FL_scale, 0.2);
    entity_set_int(g_iEntity, EV_INT_rendermode, kRenderTransTexture);
    entity_set_float(g_iEntity, EV_FL_renderamt, 0.0);
    set_es(esState, ES_Skin, iHost);
    set_es(esState, ES_Body, 1);
    set_es(esState, ES_AimEnt, iHost);
    set_es(esState, ES_MoveType, MOVETYPE_FOLLOW);
}


Shadows Adi 12-26-2021 17:40

Re: Muzzle in rehlds not work.
 
In CPlayer__AddToFullPack_post try to verifiy the "iE" because that is an entity too, maybe it's what you want.

PHP Code:

public CPlayer__AddToFullPack_post(esStateiEiEntiHostiHostFlagsiPlayerpSet)
{
    
server_print("iE: %d; iEnt: %d; g_iEntity: %d"iEiEntg_iEntity);
    if (
iEnt != g_iEntity){ //The problem is different entity.
        
return;
    }
    
    if (
get_bit(g_bitsMuzzleFlashiHost))
    {
        
set_es(esStateES_Framefloat(random_num(02)));
            
        
set_es(esStateES_RenderModekRenderTransAdd);
        
set_es(esStateES_RenderAmt255.0);
        
        
reset_bit(g_bitsMuzzleFlashiHost);
    }
    new 
fgy[32];
    
fgy[iHost] = get_user_weapon(iHost);
    if(
fgy[iHost] == CSW_AK47 || fgy[iHost] == CSW_M4A1 || fgy[iHost] == CSW_AWP || fgy[iHost] == CSW_FAMAS || fgy[iHost] == CSW_M4A1){
    
entity_set_model(g_iEntityspriteok[0]);
    }
    
entity_set_float(g_iEntityEV_FL_scale0.2);
    
entity_set_int(g_iEntityEV_INT_rendermodekRenderTransTexture);
    
entity_set_float(g_iEntityEV_FL_renderamt0.0);
    
set_es(esStateES_SkiniHost);
    
set_es(esStateES_Body1);
    
set_es(esStateES_AimEntiHost);
    
set_es(esStateES_MoveTypeMOVETYPE_FOLLOW);


And post the messages printed out in your console.

krisztian2 12-26-2021 17:44

Re: Muzzle in rehlds not work.
 
Here the results:
Code:

iE: 60; iEnt: 60; g_iEntity: 33
iE: 61; iEnt: 61; g_iEntity: 33
iE: 64; iEnt: 64; g_iEntity: 33
iE: 65; iEnt: 65; g_iEntity: 33
iE: 66; iEnt: 66; g_iEntity: 33



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

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