AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   A bug with Shields in NoSil.amxx (https://forums.alliedmods.net/showthread.php?t=332814)

SoulWeaver16 06-02-2021 12:56

A bug with Shields in NoSil.amxx
 
I clarify, it is my first post here, sorry if I break any rules, I will fix it if I do.
First of all, the code

Code:

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

new lastWeapon[33];

public plugin_init()
{
        register_plugin("NoSil","1.00","Avalanche");
        register_cvar("nosil","1.00",FCVAR_SERVER);
       
        register_forward(FM_SetModel,"fw_setmodel",0);
        register_event("CurWeapon","event_curweapon","b","1=1");
        RegisterHam(Ham_Weapon_SecondaryAttack,"weapon_m4a1","ham_m4a1_secondary",1);
        RegisterHam(Ham_Weapon_SecondaryAttack,"weapon_usp","ham_usp_secondary",1);
       
        // fix armoury_entitys, they are never silenced
        new ent, model[18];
        while((ent = engfunc(EngFunc_FindEntityByString,ent,"classname","armoury_entity")) != 0)
        {
                pev(ent,pev_model,model,17);
                if(equal(model,"models/w_m4a1.mdl")) engfunc(EngFunc_SetModel,ent,"models/w_m4a1_nosil.mdl");
                else if(equal(model,"models/w_usp.mdl")) engfunc(EngFunc_SetModel,ent,"models/w_usp_nosil.mdl");
        }
}

public plugin_precache()
{
        precache_model("models/p_usp_nosil.mdl");
        precache_model("models/p_m4a1_nosil.mdl");
        precache_model("models/w_usp_nosil.mdl");
        precache_model("models/w_m4a1_nosil.mdl");
}

public client_putinserver(id)
{
        lastWeapon[id] = 0;
}

public fw_setmodel(wbox,model[])
{
        if(!pev_valid(wbox)) return FMRES_IGNORED;
       
        // definitely not "models/w_usp.mdl" or "models/w_m4a1.mdl"
        new len = strlen(model);
        if((len != 16 && len != 17) || model[6] != '/' || model[7] != 'w' || model[8] != '_')
                return FMRES_IGNORED;

        static classname[8];
        pev(wbox,pev_classname,classname,7);
        if(!equal(classname,"weaponb")) return FMRES_IGNORED;
       
        // m4a1
        if(model[10] == '4')
        {
                // get the weapon_* entity that is linked to this weaponbox
                new weapon;
                while((weapon = engfunc(EngFunc_FindEntityByString,weapon,"classname","weapon_m4a1")) && pev(weapon,pev_owner) != wbox) {}
                if(pev_valid(weapon) && !cs_get_weapon_silen(weapon))
                {
                        engfunc(EngFunc_SetModel,wbox,"models/w_m4a1_nosil.mdl");
                        return FMRES_SUPERCEDE;
                }
        }
       
        // usp
        else if(model[9] == 'u')
        {
                // get the weapon_* entity that is linked to this weaponbox
                new weapon;
                while((weapon = engfunc(EngFunc_FindEntityByString,weapon,"classname","weapon_usp")) && pev(weapon,pev_owner) != wbox) {}
                if(pev_valid(weapon) && !cs_get_weapon_silen(weapon))
                {
                        engfunc(EngFunc_SetModel,wbox,"models/w_usp_nosil.mdl");
                        return FMRES_SUPERCEDE;
                }
        }
       
        return FMRES_IGNORED;
}

public event_curweapon(id)
{
        new weapon = read_data(2);
        if(weapon != lastWeapon[id])
        {
                if(weapon == CSW_M4A1)
                {
                        // find player's weapon_* entity
                        new weapon;
                        while((weapon = engfunc(EngFunc_FindEntityByString,weapon,"classname","weapon_m4a1")) && pev(weapon,pev_owner) != id) {}
                        if(pev_valid(weapon)) check_pmodel(weapon,"m4a1");
                }
                else if(weapon == CSW_USP)
                {
                        // find player's weapon_* entity
                        new weapon;
                        while((weapon = engfunc(EngFunc_FindEntityByString,weapon,"classname","weapon_usp")) && pev(weapon,pev_owner) != id) {}
                        if(pev_valid(weapon)) check_pmodel(weapon,"usp");
                }
        }

        lastWeapon[id] = weapon;
}

public ham_m4a1_secondary(weapon)
{
        check_pmodel(weapon,"m4a1");
        return HAM_IGNORED;
}

public ham_usp_secondary(weapon)
{
        check_pmodel(weapon,"usp");
        return HAM_IGNORED;
}

check_pmodel(weapon,name[])
{
        new owner = pev(weapon,pev_owner);
        if(!is_user_alive(owner)) return;
       
        static model[32];
        formatex(model,31,"models/p_%s%s.mdl",name,cs_get_weapon_silen(weapon) ? "" : "_nosil");
       
        set_pev(owner,pev_weaponmodel,engfunc(EngFunc_AllocString,model));
}

One bug that I came across is that it seems that when the USP is without a silencer, the shield disappears.

Is there a way that there is a p_shield_usp_nosil.mdl in the code?
User Claude360 made a model for CSCZ
Quote:

Originally Posted by Claude360 (Post 2704926)
i got models for cscz for the plugin users

One reason for the bug, could be that having the USP without a silencer, having the shield makes it invisible (but functional)
When using any other pistol or knife/grenade it does not happen.

Pictures about error:
https://i.imgur.com/8Plvnmz.jpeg
https://i.imgur.com/Mi3sZF6.jpeg
https://i.imgur.com/izMAiYE.jpeg

thanks in advance :)


All times are GMT -4. The time now is 02:31.

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