AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   New Plugin Submissions (https://forums.alliedmods.net/forumdisplay.php?f=26)
-   -   Extended Arm Weapon Skin 2.1 [CS/CZ] {16 Apr 2023} (https://forums.alliedmods.net/showthread.php?t=338882)

SoulWeaver16 08-01-2022 07:25

Extended Arm Weapon Skin 2.1 [CS/CZ] {16 Apr 2023}
 
10 Attachment(s)
https://i.imgur.com/3kLi6v7.png
Description:
Detect which class is chosen, be it Arctic, Leet, GIGN, Urban, etc, including VIP.
And associate it with the corresponding arms like CSGO does.

[It does not have support for Zombie Mod yet, when turning into a Zombie, human hands will remain.]
https://i.imgur.com/qE60XUE.png

Video Preview

Requirements:
  • AmxModX 1.8.3+
  • The SetViewEntityBody2 from the post
  • Models - Preview here


Instructions:
  1. Download the required files:[CS Models][CZ Models]
  2. Compile plugins locally.
  3. Put the models in: "models/extended/"
    Ex: models/extended/v_ak47.mdl
    models/extended/v_shield_deagle.mdl
  4. Put in plugin.ini:
    SetViewEntityBody2_edit.amxx
    EAWSv2.1.amxx
    [CZ] (Optional) CZ_Bot_Skin_on_Expert.amxx


Future things:
- Cvar command to disable it on the client side.
Spoiler

- Functions to be associated with cl_minmodels
Spoiler

If set to 1, use the values cl_min_ct */cl_min_t * as input
Spoiler


Change-Log:
  • * 2.1 - 4/16/23
    - Minor optimizations.
    - Thanks lexzor
  • * 2.0 - 8/22/22
    - Support for shields.
    - Admin support added.
    (Downloaded 118 times)
  • * 1.1 - 8/7/22
    - Compatibility for CZ Militia/Spetsnaz.
  • * 1.0 - 8/1/22
    - First release. Waiting for feedback.

Cvars:
  • eaws_admin_flag <#> // Which admin flag is needed, for admin arms.
    Default: ""
  • eaws_admin_skin <#> // Which arms should be applied to admin.
    Default: 8 (VIP)
    Spoiler
  • eaws_default_skin <#> // Which arms should be seen when using a custom player model.
    Default: 3 (Guerilla, bare hands) looks the most like standard model.
    Spoiler

Notes:
  • The bots supported, and seen from spectator mode.
  • Compatible VIP, in case you use VIP Objective Balance.
  • Shield support can be disabled by changing the code:
    #define SHIELD_SUPPORT -> //#define SHIELD_SUPPORT

Credits:
Any contribution of code or ideas that you want to contribute, is welcome.

deprale 08-01-2022 08:28

Re: Extended Arm Weapon Skin
 
Very interesting :)
I think it will be an interesting plugin for a lot of custom guns made specifically for zombie plague.

SoulWeaver16 08-01-2022 14:35

Re: Extended Arm Weapon Skin
 
Quote:

Originally Posted by deprale (Post 2785323)
Very interesting :)
I think it will be an interesting plugin for a lot of custom guns made specifically for zombie plague.

Yes, it is incredible, there will be many possibilities, either for weapon skins or other things that you can think of, I would be needing help with the code for CZ, the reason for this is that the CZ models are heavier, and it is not possible to do it by submodel like CS1.6, it exceeds the limit of .mdl, but doing it by skins instead of submodels is feasible, not only that it would make the model less heavy, if not, it would not put as much load on the server.

WesT_007 08-07-2022 15:14

Re: Extended Arm Weapon Skin
 
Nice plugin, thx, I was looking for a plugin like this for a while <3
If you want I can work with the CZ skins, but it will take some time...

SoulWeaver16 08-07-2022 15:36

Re: Extended Arm Weapon Skin
 
1 Attachment(s)
Quote:

Originally Posted by WesT_007 (Post 2785801)
Nice plugin, thx, I was looking for a plugin like this for a while <3
If you want I can work with the CZ skins, but it will take some time...

Thanks, I'm glad I served you.
I already worked on the CZ skins, I have them practically finished, I still need some fixes

SoulWeaver16 08-07-2022 19:07

Re: Extended Arm Weapon Skin
 
* 1.1 - 8/7/22
- Compatibility for CZ Militia/Spetsnaz.

1xAero 08-09-2022 00:48

Re: Extended Arm Weapon Skin
 
Good job

MayroN 08-09-2022 07:40

Re: Extended Arm Weapon Skin
 
One thing is not clear...
Why did they make body models, if we change the skin textures of the hands and that's it

SoulWeaver16 08-09-2022 10:22

Re: Extended Arm Weapon Skin
 
Quote:

Originally Posted by MayroN (Post 2785969)
One thing is not clear...
Why did they make body models, if we change the skin textures of the hands and that's it

Believe me I tried and we worked on it
https://forums.alliedmods.net/showpo...7&postcount=31

Celena Luna 08-10-2022 23:50

Re: Extended Arm Weapon Skin
 
You should add description on what the plugin does
It is kind of hard to understand without watching the video

SoulWeaver16 08-10-2022 23:56

Re: Extended Arm Weapon Skin
 
Quote:

Originally Posted by Celena Luna (Post 2786161)
You should add description on what the plugin does
It is kind of hard to understand without watching the video

You're right, I will fix the description, it is that I took for granted that they saw the previous post that asked for help regarding the creation of the plugin, which I show the models.

deprale 08-15-2022 08:28

Re: Extended Arm Weapon Skin CS/CZ
 
Nice updated post it looks very nice, plus the actual plugin is a veeery good idea I didn't get it at first, will be using in my next project for sure my guy! Congratulations on amazing work again!

SoulWeaver16 08-15-2022 18:51

Re: Extended Arm Weapon Skin CS/CZ
 
Quote:

Originally Posted by deprale (Post 2786493)
Nice updated post it looks very nice, plus the actual plugin is a veeery good idea I didn't get it at first, will be using in my next project for sure my guy! Congratulations on amazing work again!

Thanks, when we can find a way to use skins instead of submodels, it will open the door to more customization, at the moment I'm happy with how the project is going, any input or suggestion you want to say is welcome :)

kww 08-21-2022 18:19

Re: Extended Arm Weapon Skin CS/CZ
 
sadly we can't just have separate MDLs for hands, weapon and animations.

SoulWeaver16 08-21-2022 18:41

Re: Extended Arm Weapon Skin CS/CZ
 
Quote:

Originally Posted by kww (Post 2787135)
sadly we can't just have separate MDLs for hands, weapon and animations.

In fact if it is possible, what is impossible is to use those multiple models in the first person

bibu 08-22-2022 09:26

Re: Extended Arm Weapon Skin CS/CZ
 
Just wanted to let plugin approvers know, that this plugin was made upon request by the submitter. He helped by providing models, by testing and giving me very useful information regarding model animation number. I do intend to keep the plugin updated.

The plugin itself is quite simple in my opinion. I had to rewrite the base plugin "SetViewEntityBody 2" in order to make this work. I contacted the author to make his plugin more as an API, which would be much more useful for the community: https://forums.alliedmods.net/showpo...2&postcount=34

The way the plugin is right now, it might need optimization. First thing I was thinking of is allocating the models. But I don't know if this is still needed. I was inactive for awhile. The shield support is coming very soon and I couldn't make that as a cvar, since it needs precaching/unprecaching. So this support would need recompiling.

For everyone using the plugin, we are open for feedback and possible future ideas.
For plugin approves, I am open to some feedback.

SoulWeaver16 08-22-2022 11:20

Re: Extended Arm Weapon Skin CS/CZ
 
* 2.0 - 8/22/22
- Support for shields.
- Admin support added.

More information in the main post.

kww 08-24-2022 08:06

Re: Extended Arm Weapon Skin CS/CZ
 
Quote:

Originally Posted by SoulWeaver16 (Post 2787136)
use those multiple models in the first person

This is what I meant

georgik57 11-09-2022 18:28

Re: Extended Arm Weapon Skin 2.0 [CS/CZ]
 
Solid work, congrats.

Siska1 11-10-2022 19:44

Re: Extended Arm Weapon Skin 2.0 [CS/CZ]
 
I have Segmentation fault (core dumped) every time when i join to server !

ChillerX 01-27-2023 23:03

Re: Extended Arm Weapon Skin 2.0 [CS/CZ]
 
Would you mind adding an option for the models to be off by default so players can turn them on manually? A menu to switch them manually would be cool too.

SoulWeaver16 01-31-2023 17:43

Re: Extended Arm Weapon Skin 2.0 [CS/CZ]
 
Quote:

Originally Posted by ChillerX (Post 2798111)
Would you mind adding an option for the models to be off by default so players can turn them on manually? A menu to switch them manually would be cool too.

It could be done, only that it would require the help of the code editor, I don't know if he's pending the post.

lexzor 03-25-2023 09:53

Re: Extended Arm Weapon Skin 2.0 [CS/CZ]
 
Quote:

Originally Posted by ChillerX (Post 2798111)
Would you mind adding an option for the models to be off by default so players can turn them on manually? A menu to switch them manually would be cool too.

PHP Code:

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

#define SHIELD_SUPPORT
//Shield can be disabled by changing code: //#define SHIELD_SUPPORT

#define DEFAULT_MODE
//This add the ability of the players to toggle if the plugin is active for them or not

#if defined DEFAULT_MODE
    #include <amxconst>
    #include <nvault>

    
new const CHAT_TAG[] = "^4[ARM SKIN]^1" //Tag chat when toggle the weapon skinn view
    
new const PRUNE_DAYS 30 //After how many days the inactive entries will be deleted
    
new const bool:DEFAULT_VALUE true //Default value for players that never toggled model changer. True means that players skin will be changed by default until they disable it
#endif

//Linux diff
const XO_WEAPON 4

// CBasePlayerItem
const m_pPlayer 41 // CBasePlayer *

native cs_set_viewmodel_body(iPlayeriValue);    //This will set v_ .mdl body (PlayerIndex, Bodygroup number)

enum _:BodyID
{
    
Arctic,
    
Gign,
    
GSG9,
    
Guerilla,
    
Leet,
    
SAS,
    
Terror,
    
Urban,
    
VIP,
    
Militia,
    
Spetsnaz
}

new const 
g_szModelName[BodyID][] =
{
    
"arctic",
    
"gign",
    
"gsg9",
    
"guerilla",
    
"leet",
    
"sas",
    
"terror",
    
"urban",
    
"vip",
    
"militia",
    
"spetsnaz"
}

new const 
g_szUserInfoModel[] = "model"
new const g_szWeaponNameMp5Navy[] = "weapon_mp5navy"
new const g_szNewWeaponDirectoryMp5Navy[] = "models/extended/v_mp5.mdl"

new const g_szWeaponNamePrefix[] = "weapon_"
new const g_szNewWeaponDirectory[] = "models/extended/v_"
new const g_szModelNameExtension[] = ".mdl"

new Trie:g_tModels

#if defined DEFAULT_MODE
    
new const g_szVaultName[] = "extended_arm_weapon_skin"
    
new g_iVault
    
new bool:g_bActive[MAX_PLAYERS+1]
    new 
g_szAuthID[MAX_PLAYERS+1][MAX_AUTHID_LENGTH]
#endif

//Weapon ents
new g_szWeaponNames[][] = {"weapon_knife""weapon_glock18""weapon_ak47""weapon_aug""weapon_awp""weapon_c4""weapon_deagle""weapon_elite""weapon_famas"
    
"weapon_fiveseven""weapon_flashbang""weapon_g3sg1""weapon_galil""weapon_hegrenade""weapon_m3""weapon_xm1014""weapon_m4a1""weapon_m249""weapon_mac10"
    
"weapon_mp5navy""weapon_p90""weapon_p228""weapon_scout""weapon_sg550""weapon_sg552""weapon_smokegrenade""weapon_tmp""weapon_ump45""weapon_usp" }

//Old models to unprecache
new g_szOldModels[][] = {"models/v_knife.mdl""models/v_glock18.mdl""models/v_ak47.mdl""models/v_aug.mdl""models/v_awp.mdl""models/v_c4.mdl" "models/v_deagle.mdl"
    
"models/v_elite.mdl""models/v_famas.mdl""models/v_fiveseven.mdl""models/v_flashbang.mdl""models/v_g3sg1.mdl""models/v_galil.mdl""models/v_hegrenade.mdl"
    
"models/v_m3.mdl""models/v_xm1014.mdl""models/v_m4a1.mdl""models/v_m249.mdl""models/v_mac10.mdl""models/v_mp5.mdl""models/v_p90.mdl""models/v_p228.mdl"
    
"models/v_scout.mdl""models/v_sg550.mdl""models/v_sg552.mdl""models/v_smokegrenade.mdl""models/v_tmp.mdl""models/v_ump45.mdl""models/v_usp.mdl" }

//New models to precache
new g_szNewModels[][] = {"models/extended/v_knife.mdl""models/extended/v_glock18.mdl""models/extended/v_ak47.mdl""models/extended/v_aug.mdl""models/extended/v_awp.mdl"
    
"models/extended/v_c4.mdl" "models/extended/v_deagle.mdl""models/extended/v_elite.mdl""models/extended/v_famas.mdl""models/extended/v_fiveseven.mdl"
    
"models/extended/v_flashbang.mdl""models/extended/v_g3sg1.mdl""models/extended/v_galil.mdl""models/extended/v_hegrenade.mdl""models/extended/v_m3.mdl"
    
"models/extended/v_xm1014.mdl""models/extended/v_m4a1.mdl""models/extended/v_m249.mdl""models/extended/v_mac10.mdl""models/extended/v_mp5.mdl""models/extended/v_p90.mdl"
    
"models/extended/v_p228.mdl""models/extended/v_scout.mdl""models/extended/v_sg550.mdl""models/extended/v_sg552.mdl""models/extended/v_smokegrenade.mdl""models/extended/v_tmp.mdl"
    
"models/extended/v_ump45.mdl""models/extended/v_usp.mdl"}

#if defined SHIELD_SUPPORT
// Old shield models to unprecache:
new g_szOldShieldModels[][] = {"models/shield/v_shield_usp.mdl""models/shield/v_shield_fiveseven.mdl""models/shield/v_shield_deagle.mdl",
    
"models/shield/v_shield_p228.mdl""models/shield/v_shield_knife.mdl""models/shield/v_shield_glock18.mdl",
    
"models/shield/v_shield_flashbang.mdl""models/shield/v_shield_hegrenade.mdl""models/shield/v_shield_smokegrenade.mdl"}

//New shield models to precache
new g_szNewShieldModels[][] = {"models/extended/v_shield_knife.mdl""models/extended/v_shield_glock18.mdl""models/extended/v_shield_deagle.mdl",
    
"models/extended/v_shield_fiveseven.mdl""models/extended/v_shield_flashbang.mdl""models/extended/v_shield_hegrenade.mdl",
    
"models/extended/v_shield_p228.mdl""models/extended/v_shield_smokegrenade.mdl""models/extended/v_shield_usp.mdl"}
    
new const 
g_szNewWeaponDirectoryShield[] = "models/extended/v_shield_"
#endif

new bool:IsUserAdmin[MAX_PLAYERS+1], g_pcvAdminFlagg_pcvAdminSking_pcvDefaultSkin

public plugin_init()
{
    
register_plugin("Extended Arm Weapon Skin""2.0""KayDee")
    
    
g_pcvAdminFlag register_cvar("eaws_admin_flag""")
    
g_pcvAdminSkin register_cvar("eaws_admin_skin""8")
    
g_pcvDefaultSkin register_cvar("eaws_default_skin""3")
    
    for(new 
isizeof g_szWeaponNamesi++)
    {
        
RegisterHam(Ham_Item_Deployg_szWeaponNames[i], "ItemDeployPost"1)
    }

    
g_tModels TrieCreate()
    
    for(new 
0BodyIDi++)
    {
        
TrieSetCell(g_tModelsg_szModelName[i], i)
    }

    
#if defined DEFAULT_MODE
    
if((g_iVault nvault_open(g_szVaultName)) == INVALID_HANDLE)
    {
        
set_fail_state("Vault file ^"%s^" coudln't be opened!"g_szVaultName)
    }

    
nvault_prune(g_iVault0get_systime() - (PRUNE_DAYS 86400))

    
register_clcmd("say /armskin""toggleCmd")
    
register_clcmd("say_team /armskin""toggleCmd")
    
register_clcmd("amx_armskin""toggleCmd")
    
#endif
}

#if defined DEFAULT_MODE
public plugin_end()
{
    
nvault_close(g_iVault)
}

public 
toggleCmd(id)
{
    
g_bActive[id] = !g_bActive[id]

    
client_print_color(idprint_team_default"%s You^4 %s^1 arm skin!"CHAT_TAGg_bActive[id] ? "enabled" "disabled")

    
nvault_set(g_iVaultg_szAuthID[id], fmt("%i"g_bActive[id] ? "1" "0"))
}
#endif

public plugin_precache()
{
    
register_forward(FM_PrecacheModel"Forward_PrecacheModel"0)    //Unprecache old viewmodels

    
for(new isizeof g_szNewModelsi++)
    {
        
precache_model(g_szNewModels[i])    //Precache now new viewmodels
    
}

    
#if defined SHIELD_SUPPORT
    
for(new isizeof g_szNewShieldModelsi++)
    {
        
precache_model(g_szNewShieldModels[i])    //Precache now new shield viewmodels
    
}
    
#endif
}

public 
Forward_PrecacheModel(const szModel[])
{
    for(new 
isizeof g_szOldModelsi++) 
    { 
        if(
equal(szModelg_szOldModels[i]))  
        {  
            
forward_return(FMV_CELL0)
            return 
FMRES_SUPERCEDE
        
}  
    }
    
#if defined SHIELD_SUPPORT
    
for(new isizeof g_szOldShieldModelsi++) 
    { 
        if(
equal(szModelg_szOldShieldModels[i]))  
        {
            
forward_return(FMV_CELL0)
            return 
FMRES_SUPERCEDE
        
}  
    }
    
#endif
    
return FMRES_IGNORED
}

public 
client_authorized(id)
{
    static 
szAdminFlags[16]
    if(
get_user_flags(id) & get_pcvar_string(g_pcvAdminFlagszAdminFlagscharsmax(szAdminFlags)))
        
IsUserAdmin[id] = true
    
else
        
IsUserAdmin[id] = false

    
#if defined DEFAULT_MODE
    
static szData[8], iTs
    get_user_authid
(idg_szAuthID[id], charsmax(g_szAuthID[]))

    if(
nvault_lookup(g_iVaultg_szAuthID[id], szDatacharsmax(szData), iTs))
    {
        
g_bActive[id] = bool:str_to_num(szData)
    }
    else
    {
        
g_bActive[id] = DEFAULT_VALUE
    
}
    
#endif
}  

public 
ItemDeployPost(iWeapon)
{    
    static 
id
    id 
get_pdata_cbase(iWeaponm_pPlayerXO_WEAPON)

    if(!
is_user_alive(id))
    {
        return 
HAM_IGNORED
    
}

    
#if defined DEFAULT_MODE
    
if(!g_bActive[id])
    {
        return 
HAM_IGNORED
    
}
    
#endif

    
static szModelInfo[9]
    
get_user_info(idg_szUserInfoModelszModelInfocharsmax(szModelInfo))
   
    new 
iNum;
    
// Admin Model
    
if(IsUserAdmin[id])
    {
        
cs_set_viewmodel_body(idget_pcvar_num(g_pcvAdminSkin))
    }
    
// Real Model
    
else if(TrieGetCell(g_tModelsszModelInfoiNum))
    {
        
cs_set_viewmodel_body(idiNum)
    }
    
// Custom Model
    
else
    {
        
cs_set_viewmodel_body(idget_pcvar_num(g_pcvDefaultSkin))
    }

    
set_task(0.1"SetSkin"id//this task is needed

    
return HAM_IGNORED
}

const 
m_bOwnsShield 2043
new const ShieldPossible = (<< CSW_HEGRENADE) | (<< CSW_SMOKEGRENADE) | (<< CSW_FLASHBANG) | (<< CSW_KNIFE) |(<< CSW_USP) | (<< CSW_P228) | (<< CSW_GLOCK18) | (<< CSW_FIVESEVEN) | (<< CSW_DEAGLE)

public 
SetSkin(id)
{
    if(!
is_user_alive(id))
        return
    
    new 
iWeapon get_user_weapon(id)
        
    if(!
iWeapon)
        return
        
    static 
szWeapon[64]
    
get_weaponname(iWeaponszWeaponcharsmax(szWeapon))
    
    if(
equal(szWeapong_szWeaponNameMp5Navy))
    {
        
replace(szWeaponcharsmax(szWeapon), szWeapong_szNewWeaponDirectoryMp5Navy)
    }
    
#if defined SHIELD_SUPPORT
    
else if(ShieldPossible & (<< iWeapon) && get_pdata_bool(idm_bOwnsShield))
    {
        
replace(szWeaponcharsmax(szWeapon), g_szWeaponNamePrefixg_szNewWeaponDirectoryShield)
        
formatex(szWeaponcharsmax(szWeapon), "%s%s"szWeapong_szModelNameExtension)
    }
    
#endif
    
else
    {
        
replace(szWeaponcharsmax(szWeapon), g_szWeaponNamePrefixg_szNewWeaponDirectory)
        
formatex(szWeaponcharsmax(szWeapon), "%s%s"szWeapong_szModelNameExtension)
    }    
    
set_pev(idpev_viewmodel2szWeapon)


don't tested , i think it s working. if not let me know

for players:
normal/team chat command: /armskin
console command: amx_armskin

SoulWeaver16 03-26-2023 18:43

Re: Extended Arm Weapon Skin 2.0 [CS/CZ]
 
Quote:

Originally Posted by lexzor (Post 2801765)
Code:

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

#define SHIELD_SUPPORT
//Shield can be disabled by changing code: //#define SHIELD_SUPPORT

#define DEFAULT_MODE
//This add the ability of the players to toggle if the plugin is active for them or not

#if defined DEFAULT_MODE
    #include <amxconst>
    #include <nvault>

    new const CHAT_TAG[] = "^4[ARM SKIN]^1" //Tag chat when toggle the weapon skinn view
    new const PRUNE_DAYS = 30 //After how many days the inactive entries will be deleted
    new const bool:DEFAULT_VALUE = true //Default value for players that never toggled model changer. True means that players skin will be changed by default until they disable it
#endif

//Linux diff
const XO_WEAPON = 4

// CBasePlayerItem
const m_pPlayer = 41 // CBasePlayer *

native cs_set_viewmodel_body(iPlayer, iValue);    //This will set v_ .mdl body (PlayerIndex, Bodygroup number)

enum _:BodyID
{
    Arctic,
    Gign,
    GSG9,
    Guerilla,
    Leet,
    SAS,
    Terror,
    Urban,
    VIP,
    Militia,
    Spetsnaz
}

new const g_szModelName[BodyID][] =
{
    "arctic",
    "gign",
    "gsg9",
    "guerilla",
    "leet",
    "sas",
    "terror",
    "urban",
    "vip",
    "militia",
    "spetsnaz"
}

new const g_szUserInfoModel[] = "model"
new const g_szWeaponNameMp5Navy[] = "weapon_mp5navy"
new const g_szNewWeaponDirectoryMp5Navy[] = "models/extended/v_mp5.mdl"

new const g_szWeaponNamePrefix[] = "weapon_"
new const g_szNewWeaponDirectory[] = "models/extended/v_"
new const g_szModelNameExtension[] = ".mdl"

new Trie:g_tModels

#if defined DEFAULT_MODE
    new const g_szVaultName[] = "extended_arm_weapon_skin"
    new g_iVault
    new bool:g_bActive[MAX_PLAYERS+1]
    new g_szAuthID[MAX_PLAYERS+1][MAX_AUTHID_LENGTH]
#endif

//Weapon ents
new g_szWeaponNames[][] = {"weapon_knife", "weapon_glock18", "weapon_ak47", "weapon_aug", "weapon_awp", "weapon_c4", "weapon_deagle", "weapon_elite", "weapon_famas",
    "weapon_fiveseven", "weapon_flashbang", "weapon_g3sg1", "weapon_galil", "weapon_hegrenade", "weapon_m3", "weapon_xm1014", "weapon_m4a1", "weapon_m249", "weapon_mac10",
    "weapon_mp5navy", "weapon_p90", "weapon_p228", "weapon_scout", "weapon_sg550", "weapon_sg552", "weapon_smokegrenade", "weapon_tmp", "weapon_ump45", "weapon_usp" }

//Old models to unprecache
new g_szOldModels[][] = {"models/v_knife.mdl", "models/v_glock18.mdl", "models/v_ak47.mdl", "models/v_aug.mdl", "models/v_awp.mdl", "models/v_c4.mdl" , "models/v_deagle.mdl",
    "models/v_elite.mdl", "models/v_famas.mdl", "models/v_fiveseven.mdl", "models/v_flashbang.mdl", "models/v_g3sg1.mdl", "models/v_galil.mdl", "models/v_hegrenade.mdl",
    "models/v_m3.mdl", "models/v_xm1014.mdl", "models/v_m4a1.mdl", "models/v_m249.mdl", "models/v_mac10.mdl", "models/v_mp5.mdl", "models/v_p90.mdl", "models/v_p228.mdl",
    "models/v_scout.mdl", "models/v_sg550.mdl", "models/v_sg552.mdl", "models/v_smokegrenade.mdl", "models/v_tmp.mdl", "models/v_ump45.mdl", "models/v_usp.mdl" }

//New models to precache
new g_szNewModels[][] = {"models/extended/v_knife.mdl", "models/extended/v_glock18.mdl", "models/extended/v_ak47.mdl", "models/extended/v_aug.mdl", "models/extended/v_awp.mdl",
    "models/extended/v_c4.mdl" , "models/extended/v_deagle.mdl", "models/extended/v_elite.mdl", "models/extended/v_famas.mdl", "models/extended/v_fiveseven.mdl",
    "models/extended/v_flashbang.mdl", "models/extended/v_g3sg1.mdl", "models/extended/v_galil.mdl", "models/extended/v_hegrenade.mdl", "models/extended/v_m3.mdl",
    "models/extended/v_xm1014.mdl", "models/extended/v_m4a1.mdl", "models/extended/v_m249.mdl", "models/extended/v_mac10.mdl", "models/extended/v_mp5.mdl", "models/extended/v_p90.mdl",
    "models/extended/v_p228.mdl", "models/extended/v_scout.mdl", "models/extended/v_sg550.mdl", "models/extended/v_sg552.mdl", "models/extended/v_smokegrenade.mdl", "models/extended/v_tmp.mdl",
    "models/extended/v_ump45.mdl", "models/extended/v_usp.mdl"}

#if defined SHIELD_SUPPORT
// Old shield models to unprecache:
new g_szOldShieldModels[][] = {"models/shield/v_shield_usp.mdl", "models/shield/v_shield_fiveseven.mdl", "models/shield/v_shield_deagle.mdl",
    "models/shield/v_shield_p228.mdl", "models/shield/v_shield_knife.mdl", "models/shield/v_shield_glock18.mdl",
    "models/shield/v_shield_flashbang.mdl", "models/shield/v_shield_hegrenade.mdl", "models/shield/v_shield_smokegrenade.mdl"}

//New shield models to precache
new g_szNewShieldModels[][] = {"models/extended/v_shield_knife.mdl", "models/extended/v_shield_glock18.mdl", "models/extended/v_shield_deagle.mdl",
    "models/extended/v_shield_fiveseven.mdl", "models/extended/v_shield_flashbang.mdl", "models/extended/v_shield_hegrenade.mdl",
    "models/extended/v_shield_p228.mdl", "models/extended/v_shield_smokegrenade.mdl", "models/extended/v_shield_usp.mdl"}
   
new const g_szNewWeaponDirectoryShield[] = "models/extended/v_shield_"
#endif

new bool:IsUserAdmin[MAX_PLAYERS+1], g_pcvAdminFlag, g_pcvAdminSkin, g_pcvDefaultSkin

public plugin_init()
{
    register_plugin("Extended Arm Weapon Skin", "2.0", "KayDee")
   
    g_pcvAdminFlag = register_cvar("eaws_admin_flag", "")
    g_pcvAdminSkin = register_cvar("eaws_admin_skin", "8")
    g_pcvDefaultSkin = register_cvar("eaws_default_skin", "3")
   
    for(new i; i < sizeof g_szWeaponNames; i++)
    {
        RegisterHam(Ham_Item_Deploy, g_szWeaponNames[i], "ItemDeployPost", 1)
    }

    g_tModels = TrieCreate()
   
    for(new i = 0; i < BodyID; i++)
    {
        TrieSetCell(g_tModels, g_szModelName[i], i)
    }

    #if defined DEFAULT_MODE
    if((g_iVault = nvault_open(g_szVaultName)) == INVALID_HANDLE)
    {
        set_fail_state("Vault file ^"%s^" coudln't be opened!", g_szVaultName)
    }

    nvault_prune(g_iVault, 0, get_systime() - (PRUNE_DAYS * 86400))

    register_clcmd("say /armskin", "toggleCmd")
    register_clcmd("say_team /armskin", "toggleCmd")
    register_clcmd("amx_armskin", "toggleCmd")
    #endif
}

#if defined DEFAULT_MODE
public plugin_end()
{
        nvault_close(g_iVault)
}

public toggleCmd(id)
{
    g_bActive[id] = !g_bActive[id]

    client_print_color(id, print_team_default, "%s You^4 %s^1 arm skin!", CHAT_TAG, g_bActive[id] ? "enabled" : "disabled")

    nvault_set(g_iVault, g_szAuthID[id], fmt("%i", g_bActive[id] ? "1" : "0"))
}
#endif

public plugin_precache()
{
    register_forward(FM_PrecacheModel, "Forward_PrecacheModel", 0)    //Unprecache old viewmodels

    for(new i; i < sizeof g_szNewModels; i++)
    {
        precache_model(g_szNewModels[i])    //Precache now new viewmodels
    }

    #if defined SHIELD_SUPPORT
    for(new i; i < sizeof g_szNewShieldModels; i++)
    {
        precache_model(g_szNewShieldModels[i])    //Precache now new shield viewmodels
    }
    #endif
}

public Forward_PrecacheModel(const szModel[])
{
    for(new i; i < sizeof g_szOldModels; i++)
    {
        if(equal(szModel, g_szOldModels[i])) 
        { 
            forward_return(FMV_CELL, 0)
            return FMRES_SUPERCEDE
        } 
    }
    #if defined SHIELD_SUPPORT
    for(new i; i < sizeof g_szOldShieldModels; i++)
    {
        if(equal(szModel, g_szOldShieldModels[i])) 
        {
            forward_return(FMV_CELL, 0)
            return FMRES_SUPERCEDE
        } 
    }
    #endif
    return FMRES_IGNORED
}

public client_authorized(id)
{
    static szAdminFlags[16]
    if(get_user_flags(id) & get_pcvar_string(g_pcvAdminFlag, szAdminFlags, charsmax(szAdminFlags)))
        IsUserAdmin[id] = true
    else
        IsUserAdmin[id] = false

    #if defined DEFAULT_MODE
    static szData[8], iTs
    get_user_authid(id, g_szAuthID[id], charsmax(g_szAuthID[]))

    if(nvault_lookup(g_iVault, g_szAuthID[id], szData, charsmax(szData), iTs))
    {
        g_bActive[id] = bool:str_to_num(szData)
        }
    else
    {
        g_bActive[id] = DEFAULT_VALUE
    }
    #endif


public ItemDeployPost(iWeapon)
{   
    static id
    id = get_pdata_cbase(iWeapon, m_pPlayer, XO_WEAPON)

    if(!is_user_alive(id))
    {
        return HAM_IGNORED
    }

    #if defined DEFAULT_MODE
    if(!g_bActive[id])
    {
        return HAM_IGNORED
    }
    #endif

    static szModelInfo[9]
    get_user_info(id, g_szUserInfoModel, szModelInfo, charsmax(szModelInfo))
 
    new iNum;
    // Admin Model
    if(IsUserAdmin[id])
    {
        cs_set_viewmodel_body(id, get_pcvar_num(g_pcvAdminSkin))
    }
    // Real Model
    else if(TrieGetCell(g_tModels, szModelInfo, iNum))
    {
        cs_set_viewmodel_body(id, iNum)
    }
    // Custom Model
    else
    {
        cs_set_viewmodel_body(id, get_pcvar_num(g_pcvDefaultSkin))
    }

    set_task(0.1, "SetSkin", id) //this task is needed

    return HAM_IGNORED
}

const m_bOwnsShield = 2043
new const ShieldPossible = (1 << CSW_HEGRENADE) | (1 << CSW_SMOKEGRENADE) | (1 << CSW_FLASHBANG) | (1 << CSW_KNIFE) |(1 << CSW_USP) | (1 << CSW_P228) | (1 << CSW_GLOCK18) | (1 << CSW_FIVESEVEN) | (1 << CSW_DEAGLE)

public SetSkin(id)
{
    if(!is_user_alive(id))
        return
   
    new iWeapon = get_user_weapon(id)
       
    if(!iWeapon)
        return
       
    static szWeapon[64]
    get_weaponname(iWeapon, szWeapon, charsmax(szWeapon))
   
    if(equal(szWeapon, g_szWeaponNameMp5Navy))
    {
        replace(szWeapon, charsmax(szWeapon), szWeapon, g_szNewWeaponDirectoryMp5Navy)
    }
    #if defined SHIELD_SUPPORT
    else if(ShieldPossible & (1 << iWeapon) && get_pdata_bool(id, m_bOwnsShield))
    {
        replace(szWeapon, charsmax(szWeapon), g_szWeaponNamePrefix, g_szNewWeaponDirectoryShield)
        formatex(szWeapon, charsmax(szWeapon), "%s%s", szWeapon, g_szModelNameExtension)
    }
    #endif
    else
    {
        replace(szWeapon, charsmax(szWeapon), g_szWeaponNamePrefix, g_szNewWeaponDirectory)
        formatex(szWeapon, charsmax(szWeapon), "%s%s", szWeapon, g_szModelNameExtension)
    }   
    set_pev(id, pev_viewmodel2, szWeapon)
}

don't tested , i think it s working. if not let me know

for players:
normal/team chat command: /armskin
console command: amx_armskin

Thanks for answering, the plugin works but not as it should, the weapon just disappears, there is nothing left, I think it is because the original models are downloaded before, and they are not activated again with the command, but for the bots the weapon continues visible with the plugin.
https://i.imgur.com/mVg8Hxu.png
[OFF]
https://i.imgur.com/6NwPnpO.png
[ON]

lexzor 03-27-2023 12:54

Re: Extended Arm Weapon Skin 2.0 [CS/CZ] {22 Aug 2022}
 
i can't install the plugin on my server, saying the native from setviewentitybody2 does not exists even if i installed it correctly

anyways, the above problem can be cause by stopping precaching default models from the game.

tried to avoid unprecaching default models when this feature is enabled


PHP Code:

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

#define SHIELD_SUPPORT
//Shield can be disabled by changing code: //#define SHIELD_SUPPORT

#define DEFAULT_MODE
//This add the ability of the players to toggle if the plugin is active for them or not

#if defined DEFAULT_MODE
    #include <amxconst>
    #include <nvault>

    
new const CHAT_TAG[] = "^4[ARM SKIN]^1" //Tag chat when toggle the weapon skinn view
    
new const PRUNE_DAYS 30 //After how many days the inactive entries will be deleted
    
new const bool:DEFAULT_VALUE true //Default value for players that never toggled model changer. True means that players skin will be changed by default until they disable it
#endif

//Linux diff
const XO_WEAPON 4

// CBasePlayerItem
const m_pPlayer 41 // CBasePlayer *

native cs_set_viewmodel_body(iPlayeriValue);    //This will set v_ .mdl body (PlayerIndex, Bodygroup number)

enum _:BodyID
{
    
Arctic,
    
Gign,
    
GSG9,
    
Guerilla,
    
Leet,
    
SAS,
    
Terror,
    
Urban,
    
VIP,
    
Militia,
    
Spetsnaz
}

new const 
g_szModelName[BodyID][] =
{
    
"arctic",
    
"gign",
    
"gsg9",
    
"guerilla",
    
"leet",
    
"sas",
    
"terror",
    
"urban",
    
"vip",
    
"militia",
    
"spetsnaz"
}

new const 
g_szUserInfoModel[] = "model"
new const g_szWeaponNameMp5Navy[] = "weapon_mp5navy"
new const g_szNewWeaponDirectoryMp5Navy[] = "models/extended/v_mp5.mdl"

new const g_szWeaponNamePrefix[] = "weapon_"
new const g_szNewWeaponDirectory[] = "models/extended/v_"
new const g_szModelNameExtension[] = ".mdl"

new Trie:g_tModels

#if defined DEFAULT_MODE
    
new const g_szVaultName[] = "extended_arm_weapon_skin"
    
new g_iVault
    
new bool:g_bActive[MAX_PLAYERS+1]
    new 
g_szAuthID[MAX_PLAYERS+1][MAX_AUTHID_LENGTH]
#endif

//Weapon ents
new g_szWeaponNames[][] = {"weapon_knife""weapon_glock18""weapon_ak47""weapon_aug""weapon_awp""weapon_c4""weapon_deagle""weapon_elite""weapon_famas"
    
"weapon_fiveseven""weapon_flashbang""weapon_g3sg1""weapon_galil""weapon_hegrenade""weapon_m3""weapon_xm1014""weapon_m4a1""weapon_m249""weapon_mac10"
    
"weapon_mp5navy""weapon_p90""weapon_p228""weapon_scout""weapon_sg550""weapon_sg552""weapon_smokegrenade""weapon_tmp""weapon_ump45""weapon_usp" }

//Old models to unprecache
new g_szOldModels[][] = {"models/v_knife.mdl""models/v_glock18.mdl""models/v_ak47.mdl""models/v_aug.mdl""models/v_awp.mdl""models/v_c4.mdl" "models/v_deagle.mdl"
    
"models/v_elite.mdl""models/v_famas.mdl""models/v_fiveseven.mdl""models/v_flashbang.mdl""models/v_g3sg1.mdl""models/v_galil.mdl""models/v_hegrenade.mdl"
    
"models/v_m3.mdl""models/v_xm1014.mdl""models/v_m4a1.mdl""models/v_m249.mdl""models/v_mac10.mdl""models/v_mp5.mdl""models/v_p90.mdl""models/v_p228.mdl"
    
"models/v_scout.mdl""models/v_sg550.mdl""models/v_sg552.mdl""models/v_smokegrenade.mdl""models/v_tmp.mdl""models/v_ump45.mdl""models/v_usp.mdl" }

//New models to precache
new g_szNewModels[][] = {"models/extended/v_knife.mdl""models/extended/v_glock18.mdl""models/extended/v_ak47.mdl""models/extended/v_aug.mdl""models/extended/v_awp.mdl"
    
"models/extended/v_c4.mdl" "models/extended/v_deagle.mdl""models/extended/v_elite.mdl""models/extended/v_famas.mdl""models/extended/v_fiveseven.mdl"
    
"models/extended/v_flashbang.mdl""models/extended/v_g3sg1.mdl""models/extended/v_galil.mdl""models/extended/v_hegrenade.mdl""models/extended/v_m3.mdl"
    
"models/extended/v_xm1014.mdl""models/extended/v_m4a1.mdl""models/extended/v_m249.mdl""models/extended/v_mac10.mdl""models/extended/v_mp5.mdl""models/extended/v_p90.mdl"
    
"models/extended/v_p228.mdl""models/extended/v_scout.mdl""models/extended/v_sg550.mdl""models/extended/v_sg552.mdl""models/extended/v_smokegrenade.mdl""models/extended/v_tmp.mdl"
    
"models/extended/v_ump45.mdl""models/extended/v_usp.mdl"}

#if defined SHIELD_SUPPORT
// Old shield models to unprecache:
new g_szOldShieldModels[][] = {"models/shield/v_shield_usp.mdl""models/shield/v_shield_fiveseven.mdl""models/shield/v_shield_deagle.mdl",
    
"models/shield/v_shield_p228.mdl""models/shield/v_shield_knife.mdl""models/shield/v_shield_glock18.mdl",
    
"models/shield/v_shield_flashbang.mdl""models/shield/v_shield_hegrenade.mdl""models/shield/v_shield_smokegrenade.mdl"}

//New shield models to precache
new g_szNewShieldModels[][] = {"models/extended/v_shield_knife.mdl""models/extended/v_shield_glock18.mdl""models/extended/v_shield_deagle.mdl",
    
"models/extended/v_shield_fiveseven.mdl""models/extended/v_shield_flashbang.mdl""models/extended/v_shield_hegrenade.mdl",
    
"models/extended/v_shield_p228.mdl""models/extended/v_shield_smokegrenade.mdl""models/extended/v_shield_usp.mdl"}
    
new const 
g_szNewWeaponDirectoryShield[] = "models/extended/v_shield_"
#endif

new bool:IsUserAdmin[MAX_PLAYERS+1], g_pcvAdminFlagg_pcvAdminSking_pcvDefaultSkin

public plugin_init()
{
    
register_plugin("Extended Arm Weapon Skin""2.0""KayDee")
    
    
g_pcvAdminFlag register_cvar("eaws_admin_flag""")
    
g_pcvAdminSkin register_cvar("eaws_admin_skin""8")
    
g_pcvDefaultSkin register_cvar("eaws_default_skin""3")
    
    for(new 
isizeof g_szWeaponNamesi++)
    {
        
RegisterHam(Ham_Item_Deployg_szWeaponNames[i], "ItemDeployPost"1)
    }

    
g_tModels TrieCreate()
    
    for(new 
0BodyIDi++)
    {
        
TrieSetCell(g_tModelsg_szModelName[i], i)
    }

    
#if defined DEFAULT_MODE
    
if((g_iVault nvault_open(g_szVaultName)) == INVALID_HANDLE)
    {
        
set_fail_state("Vault file ^"%s^" coudln't be opened!"g_szVaultName)
    }

    
nvault_prune(g_iVault0get_systime() - (PRUNE_DAYS 86400))

    
register_clcmd("say /armskin""toggleCmd")
    
register_clcmd("say_team /armskin""toggleCmd")
    
register_clcmd("amx_armskin""toggleCmd")
    
#endif
}

#if defined DEFAULT_MODE
public plugin_end()
{
    
nvault_close(g_iVault)
}

public 
toggleCmd(id)
{
    
g_bActive[id] = !g_bActive[id]

    
client_print_color(idprint_team_default"%s You^4 %s^1 arm skin!"CHAT_TAGg_bActive[id] ? "enabled" "disabled")

    
nvault_set(g_iVaultg_szAuthID[id], fmt("%i"g_bActive[id] ? "1" "0"))
}
#endif

public plugin_precache()
{
    
register_forward(FM_PrecacheModel"Forward_PrecacheModel"0)    //Unprecache old viewmodels

    
for(new isizeof g_szNewModelsi++)
    {
        
precache_model(g_szNewModels[i])    //Precache now new viewmodels
    
}

    
#if defined SHIELD_SUPPORT
    
for(new isizeof g_szNewShieldModelsi++)
    {
        
precache_model(g_szNewShieldModels[i])    //Precache now new shield viewmodels
    
}
    
#endif
}

public 
Forward_PrecacheModel(const szModel[])
{
    
#if !defined DEFAULT_MODE
    
for(new isizeof g_szOldModelsi++) 
    { 
        if(
equal(szModelg_szOldModels[i]))  
        {  
            
forward_return(FMV_CELL0)
            return 
FMRES_SUPERCEDE
        
}  
    }
    
#endif 

    #if defined SHIELD_SUPPORT
    
for(new isizeof g_szOldShieldModelsi++) 
    { 
        if(
equal(szModelg_szOldShieldModels[i]))  
        {
            
forward_return(FMV_CELL0)
            return 
FMRES_SUPERCEDE
        
}  
    }
    
#endif
    
return FMRES_IGNORED
}

public 
client_authorized(id)
{
    static 
szAdminFlags[16]
    if(
get_user_flags(id) & get_pcvar_string(g_pcvAdminFlagszAdminFlagscharsmax(szAdminFlags)))
        
IsUserAdmin[id] = true
    
else
        
IsUserAdmin[id] = false

    
#if defined DEFAULT_MODE
    
static szData[8], iTs
    get_user_authid
(idg_szAuthID[id], charsmax(g_szAuthID[]))

    if(
nvault_lookup(g_iVaultg_szAuthID[id], szDatacharsmax(szData), iTs))
    {
        
g_bActive[id] = bool:str_to_num(szData)
    }
    else
    {
        
g_bActive[id] = DEFAULT_VALUE
    
}
    
#endif
}  

public 
ItemDeployPost(iWeapon)
{    
    static 
id
    id 
get_pdata_cbase(iWeaponm_pPlayerXO_WEAPON)

    if(!
is_user_alive(id))
    {
        return 
HAM_IGNORED
    
}

    
#if defined DEFAULT_MODE
    
if(!g_bActive[id])
    {
        return 
HAM_IGNORED
    
}
    
#endif

    
static szModelInfo[9]
    
get_user_info(idg_szUserInfoModelszModelInfocharsmax(szModelInfo))
   
    new 
iNum;
    
// Admin Model
    
if(IsUserAdmin[id])
    {
        
cs_set_viewmodel_body(idget_pcvar_num(g_pcvAdminSkin))
    }
    
// Real Model
    
else if(TrieGetCell(g_tModelsszModelInfoiNum))
    {
        
cs_set_viewmodel_body(idiNum)
    }
    
// Custom Model
    
else
    {
        
cs_set_viewmodel_body(idget_pcvar_num(g_pcvDefaultSkin))
    }

    
set_task(0.1"SetSkin"id//this task is needed

    
return HAM_IGNORED
}

#if defined SHIELD_SUPPORT
const m_bOwnsShield 2043
new const ShieldPossible = (<< CSW_HEGRENADE) | (<< CSW_SMOKEGRENADE) | (<< CSW_FLASHBANG) | (<< CSW_KNIFE) |(<< CSW_USP) | (<< CSW_P228) | (<< CSW_GLOCK18) | (<< CSW_FIVESEVEN) | (<< CSW_DEAGLE)
#endif

public SetSkin(id)
{
    if(!
is_user_alive(id))
        return
    
    new 
iWeapon get_user_weapon(id)
        
    if(!
iWeapon)
        return
        
    static 
szWeapon[64]
    
get_weaponname(iWeaponszWeaponcharsmax(szWeapon))
    
    if(
equal(szWeapong_szWeaponNameMp5Navy))
    {
        
replace(szWeaponcharsmax(szWeapon), szWeapong_szNewWeaponDirectoryMp5Navy)
    }
    
#if defined SHIELD_SUPPORT
    
else if(ShieldPossible & (<< iWeapon) && get_pdata_bool(idm_bOwnsShield))
    {
        
replace(szWeaponcharsmax(szWeapon), g_szWeaponNamePrefixg_szNewWeaponDirectoryShield)
        
formatex(szWeaponcharsmax(szWeapon), "%s%s"szWeapong_szModelNameExtension)
    }
    
#endif
    
else
    {
        
replace(szWeaponcharsmax(szWeapon), g_szWeaponNamePrefixg_szNewWeaponDirectory)
        
formatex(szWeaponcharsmax(szWeapon), "%s%s"szWeapong_szModelNameExtension)
    }    
    
set_pev(idpev_viewmodel2szWeapon)


also i suggest you to put the shield models and skin arm models in same archieve in an folder called "extended".

most of server owners doesn't know a grain of coding and it's easier to install

i added this too:
PHP Code:

#if defined SHIELD_SUPPORT
const m_bOwnsShield 2043
new const ShieldPossible = (<< CSW_HEGRENADE) | (<< CSW_SMOKEGRENADE) | (<< CSW_FLASHBANG) | (<< CSW_KNIFE) |(<< CSW_USP) | (<< CSW_P228) | (<< CSW_GLOCK18) | (<< CSW_FIVESEVEN) | (<< CSW_DEAGLE)
#endif 

due to a not used variable when not using shield support


and what do you mean by "the bots are still visible"? shall they not be?

bibu 03-28-2023 05:12

Re: Extended Arm Weapon Skin 2.0 [CS/CZ] {22 Aug 2022}
 
Easiest way would be to provide the default skins within the submodels, so the "default" models can be unprecached. Otherwise it's gonna use too much resources. Or another way would be to use the default submodel, which is by default the value of "3".

SoulWeaver16 04-16-2023 14:45

Re: Extended Arm Weapon Skin 2.0 [CS/CZ] {22 Aug 2022}
 
Quote:

Originally Posted by lexzor (Post 2801862)
i can't install the plugin on my server, saying the native from setviewentitybody2 does not exists even if i installed it correctly

anyways, the above problem can be cause by stopping precaching default models from the game.

tried to avoid unprecaching default models when this feature is enabled


PHP Code:

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

#define SHIELD_SUPPORT
//Shield can be disabled by changing code: //#define SHIELD_SUPPORT

#define DEFAULT_MODE
//This add the ability of the players to toggle if the plugin is active for them or not

#if defined DEFAULT_MODE
    #include <amxconst>
    #include <nvault>

    
new const CHAT_TAG[] = "^4[ARM SKIN]^1" //Tag chat when toggle the weapon skinn view
    
new const PRUNE_DAYS 30 //After how many days the inactive entries will be deleted
    
new const bool:DEFAULT_VALUE true //Default value for players that never toggled model changer. True means that players skin will be changed by default until they disable it
#endif

//Linux diff
const XO_WEAPON 4

// CBasePlayerItem
const m_pPlayer 41 // CBasePlayer *

native cs_set_viewmodel_body(iPlayeriValue);    //This will set v_ .mdl body (PlayerIndex, Bodygroup number)

enum _:BodyID
{
    
Arctic,
    
Gign,
    
GSG9,
    
Guerilla,
    
Leet,
    
SAS,
    
Terror,
    
Urban,
    
VIP,
    
Militia,
    
Spetsnaz
}

new const 
g_szModelName[BodyID][] =
{
    
"arctic",
    
"gign",
    
"gsg9",
    
"guerilla",
    
"leet",
    
"sas",
    
"terror",
    
"urban",
    
"vip",
    
"militia",
    
"spetsnaz"
}

new const 
g_szUserInfoModel[] = "model"
new const g_szWeaponNameMp5Navy[] = "weapon_mp5navy"
new const g_szNewWeaponDirectoryMp5Navy[] = "models/extended/v_mp5.mdl"

new const g_szWeaponNamePrefix[] = "weapon_"
new const g_szNewWeaponDirectory[] = "models/extended/v_"
new const g_szModelNameExtension[] = ".mdl"

new Trie:g_tModels

#if defined DEFAULT_MODE
    
new const g_szVaultName[] = "extended_arm_weapon_skin"
    
new g_iVault
    
new bool:g_bActive[MAX_PLAYERS+1]
    new 
g_szAuthID[MAX_PLAYERS+1][MAX_AUTHID_LENGTH]
#endif

//Weapon ents
new g_szWeaponNames[][] = {"weapon_knife""weapon_glock18""weapon_ak47""weapon_aug""weapon_awp""weapon_c4""weapon_deagle""weapon_elite""weapon_famas"
    
"weapon_fiveseven""weapon_flashbang""weapon_g3sg1""weapon_galil""weapon_hegrenade""weapon_m3""weapon_xm1014""weapon_m4a1""weapon_m249""weapon_mac10"
    
"weapon_mp5navy""weapon_p90""weapon_p228""weapon_scout""weapon_sg550""weapon_sg552""weapon_smokegrenade""weapon_tmp""weapon_ump45""weapon_usp" }

//Old models to unprecache
new g_szOldModels[][] = {"models/v_knife.mdl""models/v_glock18.mdl""models/v_ak47.mdl""models/v_aug.mdl""models/v_awp.mdl""models/v_c4.mdl" "models/v_deagle.mdl"
    
"models/v_elite.mdl""models/v_famas.mdl""models/v_fiveseven.mdl""models/v_flashbang.mdl""models/v_g3sg1.mdl""models/v_galil.mdl""models/v_hegrenade.mdl"
    
"models/v_m3.mdl""models/v_xm1014.mdl""models/v_m4a1.mdl""models/v_m249.mdl""models/v_mac10.mdl""models/v_mp5.mdl""models/v_p90.mdl""models/v_p228.mdl"
    
"models/v_scout.mdl""models/v_sg550.mdl""models/v_sg552.mdl""models/v_smokegrenade.mdl""models/v_tmp.mdl""models/v_ump45.mdl""models/v_usp.mdl" }

//New models to precache
new g_szNewModels[][] = {"models/extended/v_knife.mdl""models/extended/v_glock18.mdl""models/extended/v_ak47.mdl""models/extended/v_aug.mdl""models/extended/v_awp.mdl"
    
"models/extended/v_c4.mdl" "models/extended/v_deagle.mdl""models/extended/v_elite.mdl""models/extended/v_famas.mdl""models/extended/v_fiveseven.mdl"
    
"models/extended/v_flashbang.mdl""models/extended/v_g3sg1.mdl""models/extended/v_galil.mdl""models/extended/v_hegrenade.mdl""models/extended/v_m3.mdl"
    
"models/extended/v_xm1014.mdl""models/extended/v_m4a1.mdl""models/extended/v_m249.mdl""models/extended/v_mac10.mdl""models/extended/v_mp5.mdl""models/extended/v_p90.mdl"
    
"models/extended/v_p228.mdl""models/extended/v_scout.mdl""models/extended/v_sg550.mdl""models/extended/v_sg552.mdl""models/extended/v_smokegrenade.mdl""models/extended/v_tmp.mdl"
    
"models/extended/v_ump45.mdl""models/extended/v_usp.mdl"}

#if defined SHIELD_SUPPORT
// Old shield models to unprecache:
new g_szOldShieldModels[][] = {"models/shield/v_shield_usp.mdl""models/shield/v_shield_fiveseven.mdl""models/shield/v_shield_deagle.mdl",
    
"models/shield/v_shield_p228.mdl""models/shield/v_shield_knife.mdl""models/shield/v_shield_glock18.mdl",
    
"models/shield/v_shield_flashbang.mdl""models/shield/v_shield_hegrenade.mdl""models/shield/v_shield_smokegrenade.mdl"}

//New shield models to precache
new g_szNewShieldModels[][] = {"models/extended/v_shield_knife.mdl""models/extended/v_shield_glock18.mdl""models/extended/v_shield_deagle.mdl",
    
"models/extended/v_shield_fiveseven.mdl""models/extended/v_shield_flashbang.mdl""models/extended/v_shield_hegrenade.mdl",
    
"models/extended/v_shield_p228.mdl""models/extended/v_shield_smokegrenade.mdl""models/extended/v_shield_usp.mdl"}
    
new const 
g_szNewWeaponDirectoryShield[] = "models/extended/v_shield_"
#endif

new bool:IsUserAdmin[MAX_PLAYERS+1], g_pcvAdminFlagg_pcvAdminSking_pcvDefaultSkin

public plugin_init()
{
    
register_plugin("Extended Arm Weapon Skin""2.0""KayDee")
    
    
g_pcvAdminFlag register_cvar("eaws_admin_flag""")
    
g_pcvAdminSkin register_cvar("eaws_admin_skin""8")
    
g_pcvDefaultSkin register_cvar("eaws_default_skin""3")
    
    for(new 
isizeof g_szWeaponNamesi++)
    {
        
RegisterHam(Ham_Item_Deployg_szWeaponNames[i], "ItemDeployPost"1)
    }

    
g_tModels TrieCreate()
    
    for(new 
0BodyIDi++)
    {
        
TrieSetCell(g_tModelsg_szModelName[i], i)
    }

    
#if defined DEFAULT_MODE
    
if((g_iVault nvault_open(g_szVaultName)) == INVALID_HANDLE)
    {
        
set_fail_state("Vault file ^"%s^" coudln't be opened!"g_szVaultName)
    }

    
nvault_prune(g_iVault0get_systime() - (PRUNE_DAYS 86400))

    
register_clcmd("say /armskin""toggleCmd")
    
register_clcmd("say_team /armskin""toggleCmd")
    
register_clcmd("amx_armskin""toggleCmd")
    
#endif
}

#if defined DEFAULT_MODE
public plugin_end()
{
    
nvault_close(g_iVault)
}

public 
toggleCmd(id)
{
    
g_bActive[id] = !g_bActive[id]

    
client_print_color(idprint_team_default"%s You^4 %s^1 arm skin!"CHAT_TAGg_bActive[id] ? "enabled" "disabled")

    
nvault_set(g_iVaultg_szAuthID[id], fmt("%i"g_bActive[id] ? "1" "0"))
}
#endif

public plugin_precache()
{
    
register_forward(FM_PrecacheModel"Forward_PrecacheModel"0)    //Unprecache old viewmodels

    
for(new isizeof g_szNewModelsi++)
    {
        
precache_model(g_szNewModels[i])    //Precache now new viewmodels
    
}

    
#if defined SHIELD_SUPPORT
    
for(new isizeof g_szNewShieldModelsi++)
    {
        
precache_model(g_szNewShieldModels[i])    //Precache now new shield viewmodels
    
}
    
#endif
}

public 
Forward_PrecacheModel(const szModel[])
{
    
#if !defined DEFAULT_MODE
    
for(new isizeof g_szOldModelsi++) 
    { 
        if(
equal(szModelg_szOldModels[i]))  
        {  
            
forward_return(FMV_CELL0)
            return 
FMRES_SUPERCEDE
        
}  
    }
    
#endif 

    #if defined SHIELD_SUPPORT
    
for(new isizeof g_szOldShieldModelsi++) 
    { 
        if(
equal(szModelg_szOldShieldModels[i]))  
        {
            
forward_return(FMV_CELL0)
            return 
FMRES_SUPERCEDE
        
}  
    }
    
#endif
    
return FMRES_IGNORED
}

public 
client_authorized(id)
{
    static 
szAdminFlags[16]
    if(
get_user_flags(id) & get_pcvar_string(g_pcvAdminFlagszAdminFlagscharsmax(szAdminFlags)))
        
IsUserAdmin[id] = true
    
else
        
IsUserAdmin[id] = false

    
#if defined DEFAULT_MODE
    
static szData[8], iTs
    get_user_authid
(idg_szAuthID[id], charsmax(g_szAuthID[]))

    if(
nvault_lookup(g_iVaultg_szAuthID[id], szDatacharsmax(szData), iTs))
    {
        
g_bActive[id] = bool:str_to_num(szData)
    }
    else
    {
        
g_bActive[id] = DEFAULT_VALUE
    
}
    
#endif
}  

public 
ItemDeployPost(iWeapon)
{    
    static 
id
    id 
get_pdata_cbase(iWeaponm_pPlayerXO_WEAPON)

    if(!
is_user_alive(id))
    {
        return 
HAM_IGNORED
    
}

    
#if defined DEFAULT_MODE
    
if(!g_bActive[id])
    {
        return 
HAM_IGNORED
    
}
    
#endif

    
static szModelInfo[9]
    
get_user_info(idg_szUserInfoModelszModelInfocharsmax(szModelInfo))
   
    new 
iNum;
    
// Admin Model
    
if(IsUserAdmin[id])
    {
        
cs_set_viewmodel_body(idget_pcvar_num(g_pcvAdminSkin))
    }
    
// Real Model
    
else if(TrieGetCell(g_tModelsszModelInfoiNum))
    {
        
cs_set_viewmodel_body(idiNum)
    }
    
// Custom Model
    
else
    {
        
cs_set_viewmodel_body(idget_pcvar_num(g_pcvDefaultSkin))
    }

    
set_task(0.1"SetSkin"id//this task is needed

    
return HAM_IGNORED
}

#if defined SHIELD_SUPPORT
const m_bOwnsShield 2043
new const ShieldPossible = (<< CSW_HEGRENADE) | (<< CSW_SMOKEGRENADE) | (<< CSW_FLASHBANG) | (<< CSW_KNIFE) |(<< CSW_USP) | (<< CSW_P228) | (<< CSW_GLOCK18) | (<< CSW_FIVESEVEN) | (<< CSW_DEAGLE)
#endif

public SetSkin(id)
{
    if(!
is_user_alive(id))
        return
    
    new 
iWeapon get_user_weapon(id)
        
    if(!
iWeapon)
        return
        
    static 
szWeapon[64]
    
get_weaponname(iWeaponszWeaponcharsmax(szWeapon))
    
    if(
equal(szWeapong_szWeaponNameMp5Navy))
    {
        
replace(szWeaponcharsmax(szWeapon), szWeapong_szNewWeaponDirectoryMp5Navy)
    }
    
#if defined SHIELD_SUPPORT
    
else if(ShieldPossible & (<< iWeapon) && get_pdata_bool(idm_bOwnsShield))
    {
        
replace(szWeaponcharsmax(szWeapon), g_szWeaponNamePrefixg_szNewWeaponDirectoryShield)
        
formatex(szWeaponcharsmax(szWeapon), "%s%s"szWeapong_szModelNameExtension)
    }
    
#endif
    
else
    {
        
replace(szWeaponcharsmax(szWeapon), g_szWeaponNamePrefixg_szNewWeaponDirectory)
        
formatex(szWeaponcharsmax(szWeapon), "%s%s"szWeapong_szModelNameExtension)
    }    
    
set_pev(idpev_viewmodel2szWeapon)


also i suggest you to put the shield models and skin arm models in same archieve in an folder called "extended".

most of server owners doesn't know a grain of coding and it's easier to install

i added this too:
PHP Code:

#if defined SHIELD_SUPPORT
const m_bOwnsShield 2043
new const ShieldPossible = (<< CSW_HEGRENADE) | (<< CSW_SMOKEGRENADE) | (<< CSW_FLASHBANG) | (<< CSW_KNIFE) |(<< CSW_USP) | (<< CSW_P228) | (<< CSW_GLOCK18) | (<< CSW_FIVESEVEN) | (<< CSW_DEAGLE)
#endif 

due to a not used variable when not using shield support


and what do you mean by "the bots are still visible"? shall they not be?

Hello, thanks for your input and suggestion.
And the thing about the bots is still visible, it was a bad translation from Google Translator hahah, it meant that for the bots the weapon is still visible in first person.
-o-
The Extended folder already contains the v_ and Shield models in the same folder
The reason I'm putting it apart is for those who don't use Shield support, which seems to be the majority of servers, besides it had been an optional feature, we didn't know if it would cause too many problems and we would end up removing it, at the moment it seems to be stable, that's why it stayed that way.
-o-
Your code makes g_szOldModels unusable
PHP Code:

C:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\addons\amxmodx\scripting\EAWSv2.1.sma(84) : warning 203symbol is never used"g_szOldModels" 


SoulWeaver16 04-16-2023 15:39

Re: Extended Arm Weapon Skin 2.0 [CS/CZ] {22 Aug 2022}
 
Quote:

Originally Posted by lexzor (Post 2801862)
i can't install the plugin on my server, saying the native from setviewentitybody2 does not exists even if i installed it correctly

anyways, the above problem can be cause by stopping precaching default models from the game.

tried to avoid unprecaching default models when this feature is enabled

And regarding the SetViewEntityBody2, make sure that the plugin is not paused and recognizes it, if not, make sure that it is well written in Plugins.ini, it seems obvious but many times it happens that it is written wrong or it is not installed correctly

SoulWeaver16 04-16-2023 15:49

Re: Extended Arm Weapon Skin 2.0 [CS/CZ] {22 Aug 2022}
 
* 2.1 - 4/16/23
- Minor optimizations.
- Thanks lexzor

More information in the main post.

asdian 04-18-2023 09:03

Re: Extended Arm Weapon Skin 2.1 [CS/CZ] {16 Apr 2023}
 
i'm planning to use this to replace metadrawer from my ccx plugin. then i tried this plugin, but the submodel choosen is always "submodel 1". i didn't modify anything of the plugin. do you know what causes this ?

SoulWeaver16 04-18-2023 17:37

Re: Extended Arm Weapon Skin 2.1 [CS/CZ] {16 Apr 2023}
 
Quote:

Originally Posted by asdian (Post 2802969)
i'm planning to use this to replace metadrawer from my ccx plugin. then i tried this plugin, but the submodel choosen is always "submodel 1". i didn't modify anything of the plugin. do you know what causes this ?

Tell me more about the problem, did you follow all the steps correctly?
Did you compile SetViewEntityBody2_edit.sma and EAWSv2.1.sma locally?
Although it seems to be an EAWS issue

asdian 04-19-2023 00:13

Re: Extended Arm Weapon Skin 2.1 [CS/CZ] {16 Apr 2023}
 
Quote:

Originally Posted by SoulWeaver16 (Post 2803017)
Tell me more about the problem, did you follow all the steps correctly?
Did you compile SetViewEntityBody2_edit.sma and EAWSv2.1.sma locally?
Although it seems to be an EAWS issue

yes, i followed your steps. it loads the new models with armskin replacing old models, so it means the plugin is loaded successfully. it just doesn't change the hand skin to other variant

my plugin list :
Code:

; AMX Mod X plugins

; Admin Base - Always one has to be activated
admin.amxx                ; admin base (required for any admin-related)
;admin_sql.amxx                ; admin base - SQL version (comment admin.amxx)

; Basic
admincmd.amxx                ; basic admin console commands
adminhelp.amxx                ; help command for admin console commands
adminslots.amxx                ; slot reservation
multilingual.amxx        ; Multi-Lingual management

; Menus
menufront.amxx                ; front-end for admin menus
cmdmenu.amxx                ; command menu (speech, settings)
plmenu.amxx                ; players menu (kick, ban, client cmds.)
;telemenu.amxx                ; teleport menu (Fun Module required!)
mapsmenu.amxx                ; maps menu (vote, changelevel)
pluginmenu.amxx                ; Menus for commands/cvars organized by plugin

; Chat / Messages
adminchat.amxx                ; console chat commands
antiflood.amxx                ; prevent clients from chat-flooding the server
scrollmsg.amxx                ; displays a scrolling message
imessage.amxx                ; displays information messages
adminvote.amxx                ; vote commands

; Map related
nextmap.amxx                ; displays next map in mapcycle
mapchooser.amxx                ; allows to vote for next map
timeleft.amxx                ; displays time left on map

; Configuration
pausecfg.amxx                ; allows to pause and unpause some plugins
statscfg.amxx                ; allows to manage stats plugins via menu and commands

; Counter-Strike
;restmenu.amxx                ; restrict weapons menu
statsx.amxx                ; stats on death or round end (CSX Module required!)
;miscstats.amxx                ; bunch of events announcement for Counter-Strike
;stats_logging.amxx        ; weapons stats logging (CSX Module required!)


; Custom - Add 3rd party plugins here
TPS_Mode.amxx
noshield.amxx

func_SetViewEntityBody2_edit.amxx
func_EAWSv2.1.amxx

amx_settings_api.amxx
cs_player_models_api.amxx
;addon_csocharacters_xtended.amxx debug
md_cso_hud.amxx debug

; Weapons
;darkstar.amxx debug
umbra.amxx debug

and my modules list :
Code:

;;;
; To enable a module, remove the semi-colon (;) in front of its name.
; If it's not here, simply add it its name, one per line.
; You don't need to write the _amxx part or the file extension.
;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SQL Modules usually need to be enabled manually ;;
;; You can have any number on at a time.  Use      ;;
;;  amx_sql_type in sql.cfg to specify the default ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;mysql
;sqlite

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Put third party modules below here.              ;;
;; You can just list their names, without the _amxx ;;
;;  or file extension.                              ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

metadrawer
orpheu
csdm

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; These modules will be auto-detected and loaded  ;;
;;  as needed.  You do not need to enable them here ;;
;;  unless you have problems.                      ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

fun
engine
fakemeta
;geoip
;sockets
;regex
;nvault
cstrike
;csx
hamsandwich

is it conflicting or something?

SoulWeaver16 04-19-2023 15:06

Re: Extended Arm Weapon Skin 2.1 [CS/CZ] {16 Apr 2023}
 
Quote:

Originally Posted by asdian (Post 2803033)
is it conflicting or something?

Yes, it may be because you use CSO characters, remember that if you don't choose a character like Arctic, Leet, etc, the Default characters, the plugin will not take it into account. Maybe it's something else, but I assure you that in a clean installation, the plugin works correctly

asdian 04-20-2023 01:46

Re: Extended Arm Weapon Skin 2.1 [CS/CZ] {16 Apr 2023}
 
Quote:

Originally Posted by SoulWeaver16 (Post 2803085)
Yes, it may be because you use CSO characters, remember that if you don't choose a character like Arctic, Leet, etc, the Default characters, the plugin will not take it into account. Maybe it's something else, but I assure you that in a clean installation, the plugin works correctly

i've disabled my CSO characters plugin though..

SoulWeaver16 04-20-2023 06:05

Re: Extended Arm Weapon Skin 2.1 [CS/CZ] {16 Apr 2023}
 
Quote:

Originally Posted by asdian (Post 2803112)
i've disabled my CSO characters plugin though..

I wouldn't know how to help you then, I would suggest, does something else come out on the console? Any information you can provide like the logs? I doubt you see the problem there, but you seem to have a modified CS/CZ instance, perhaps the game itself has changed the class for them and therefore the plugin does not recognize them

asdian 04-20-2023 06:28

Re: Extended Arm Weapon Skin 2.1 [CS/CZ] {16 Apr 2023}
 
Quote:

Originally Posted by SoulWeaver16 (Post 2803121)
I wouldn't know how to help you then, I would suggest, does something else come out on the console? Any information you can provide like the logs? I doubt you see the problem there, but you seem to have a modified CS/CZ instance, perhaps the game itself has changed the class for them and therefore the plugin does not recognize them

nop, nothing comes out from the console. all works fine, disabled all additional plugins, but still can't change to other hand, always resulting first index of hand. :|

or maybe is it because im using latest amxmodx 1.10 so that makes it partially works?

SoulWeaver16 04-20-2023 13:41

Re: Extended Arm Weapon Skin 2.1 [CS/CZ] {16 Apr 2023}
 
Quote:

Originally Posted by asdian (Post 2803122)
nop, nothing comes out from the console. all works fine, disabled all additional plugins, but still can't change to other hand, always resulting first index of hand. :|

or maybe is it because im using latest amxmodx 1.10 so that makes it partially works?

I don't think so, I use the latest version and it works fine, also if it were due to the version, it would directly give you an error when compiling, the last thing I have to ask is if I use any of the available commands of the plugin, maybe I touched something in its configuration and that's why it acts like this

asdian 04-21-2023 09:26

Re: Extended Arm Weapon Skin 2.1 [CS/CZ] {16 Apr 2023}
 
Quote:

Originally Posted by SoulWeaver16 (Post 2803145)
I don't think so, I use the latest version and it works fine, also if it were due to the version, it would directly give you an error when compiling, the last thing I have to ask is if I use any of the available commands of the plugin, maybe I touched something in its configuration and that's why it acts like this

maybe can you make it set hand skin based on the player model that is choosen? AFAIK yours is set based on cvar value

fjlep 04-12-2024 20:21

Re: Extended Arm Weapon Skin 2.1 [CS/CZ] {16 Apr 2023}
 
Please help me with this =)

PHP Code:

EAWSv2.1.sma(84) : warning 203symbol is never used“g_szOldModels” 

PHP Code:

//Old models to unprecache
new g_szOldModels[][] = {“models/v_knife.mdl”“models/v_glock18.mdl”“models/v_ak47.mdl”“models/v_aug.mdl”“models/v_awp.mdl”“models/v_c4.mdl” “models/v_deagle.mdl”
    
“models/v_elite.mdl”“models/v_famas.mdl”“models/v_fiveseven.mdl”“models/v_flashbang.mdl”“models/v_g3sg1.mdl”“models/v_galil.mdl”“models/v_hegrenade.mdl”
    
“models/v_m3.mdl”“models/v_xm1014.mdl”“models/v_m4a1.mdl”“models/v_m249.mdl”“models/v_mac10.mdl”“models/v_mp5.mdl”“models/v_p90.mdl”“models/v_p228.mdl”
    
“models/v_scout.mdl”“models/v_sg550.mdl”“models/v_sg552.mdl”“models/v_smokegrenade.mdl”“models/v_tmp.mdl”“models/v_ump45.mdl”“models/v_usp.mdl” 



All times are GMT -4. The time now is 17:33.

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