AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [CS] CS 1.5 (Retro) Knife (https://forums.alliedmods.net/showthread.php?t=346108)

anssik 02-10-2024 01:50

[CS] CS 1.5 (Retro) Knife
 
1 Attachment(s)
Very simple addon to use the CS 1.5 knife model in CS 1.6.

Note that only the p_knife_r.mdl needs to be downloaded from server, since v_knife_r.mdl already exist by default in CS1.6 installation but is unused. The w_knife.mdl is still the same 1.5 model in 1.6, so it doesn't need to be changed.

edit: use the code from the post below, as it is more efficient

Also note that while it's supposedly better to hook v_ / p_ model using
PHP Code:

RegisterHam(Ham_Item_Deploy"weapon_knife""OnKnifeDeploy"1

It doesn't work with bots or on knife maps. While the event method below always works.

https://i.imgur.com/kqQIll4.png

PHP Code:

#include <amxmodx>
#include <engine>

#define PLUGIN "CS 1.5 Knife"
#define VERSION "1.0"
#define AUTHOR "kebabstorm"

#pragma semicolon 1

new const V_KNIFE_R[] = "models/v_knife_r.mdl";
new const 
P_KNIFE_R[] = "models/p_knife_r.mdl";

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event("CurWeapon""EV_CurWeapon""be""1=1");
}

public 
plugin_precache()
{
    
precache_model(V_KNIFE_R);
    
precache_model(P_KNIFE_R);
}

public 
EV_CurWeapon(player)
{
    if (
get_user_weapon(player) == CSW_KNIFE) {
        
entity_set_string(playerEV_SZ_viewmodelV_KNIFE_R);
        
entity_set_string(playerEV_SZ_weaponmodelP_KNIFE_R);
    }



WATCH_D0GS UNITED 02-10-2024 09:03

Re: [CS] CS 1.5 (Retro) Knife
 
PHP Code:

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

#define PLUGIN "CS 1.5 Knife"
#define VERSION "1.1"
#define AUTHOR "kebabstorm"

new const V_KNIFE_R[] = "models/v_knife_r.mdl"
new const P_KNIFE_R[] = "models/p_knife_r.mdl"

static iPlayer
static iWeapon

public plugin_init() {
        
register_plugin(PLUGINVERSIONAUTHOR);
        
RegisterHam(Ham_Item_Deploy,"weapon_knife","OnKnifeDeployPost",1)
}

public 
plugin_precache() {
        
precache_model(V_KNIFE_R)
        
precache_model(P_KNIFE_R)
}

public 
OnKnifeDeployPost(ent) {
        
iPlayer get_pdata_cbase(ent,41)
        
iWeapon get_pdata_int(ent,43)
        if(
iWeapon == CSW_KNIFE) {
                
set_pev(iPlayerpev_viewmodel2V_KNIFE_R)
                
set_pev(iPlayerpev_weaponmodel2P_KNIFE_R)
        }


Thanks for sharing!
Have a nice day.

HamletEagle 02-11-2024 06:40

Re: [CS] CS 1.5 (Retro) Knife
 
Please do not use CurWeapon to set weapon models. Use Ham_Item_Deploy.

To make it work with bots, look into RegisterHamFromEntity and provide a bot id, or if you are using amxx 1.9+, there are two easier solutions: set the last argument of RegisterHam called specialbot to true or use RegisterHamPlayer.

There should be no difference for knife maps, a knife is a knife and it is deployed in the same way no matter the map.

Jhob94 02-11-2024 06:58

Re: [CS] CS 1.5 (Retro) Knife
 
There are some problems that will cause the model not change on item deploy but it’s always a programmer mistake.

If you use multiple model plugins to change the model of the same weapon you may encounter this “bug”. It isn’t really a bug just a bad server management.

Also, and derailing topic, i guy once asked me help because on Basebuilder a m4 model would display on Knife model. I guess it’s the fast weapon change that bb plugin causes on build time. At the time I didn’t had the opportunity to help the guy fixing but yeah. Item deploy despite reliable must be used carefully if you run multiple plugins with it.

anssik 02-11-2024 22:56

Re: [CS] CS 1.5 (Retro) Knife
 
@WATCH_D0GS UNITED

This version seems to indeed work correctly, even with bots and on knife maps.
So the problem was using Ham_Item_Deploy and then entity_set_string, which doesn't work correctly; by using set_pev it works. Thanks.

metal_upa 02-13-2024 08:52

Re: [CS] CS 1.5 (Retro) Knife
 
ReAPI method:


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

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