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

Solved Knife Not Change


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lantimilan
Senior Member
Join Date: May 2016
Old 02-25-2024 , 18:13   Knife Not Change
Reply With Quote #1

Hello, i use this plugin to change skin but when person change skin he need to touch 2 or 3 to show grenad or pistol and when set knife show skin not change directly. I mean when chose you need to set otherthing and when back skin change i need to make skin to change direct when you have knife
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <cromchat>

new const PLUGIN[] = "Knife Menu";
new const 
VERSION[] = "1.0";
new const 
AUTHOR[] = "RevCrew";

new const 
KNFModels[][] =
{
    
"models/v_knife.mdl",
    
"models/RevCrewz/v_Knife1.mdl",
    
"models/RevCrewz/v_Knife2.mdl",
    
"models/RevCrewz/v_Knife3.mdl",
    
"models/RevCrewz/v_Knife4.mdl"
};

new const 
KNFMenuNames[][] =
{
    
"Knife [DEFAUT]",
    
"Knife Gamma",
    
"Knife Tatto's",
    
"Knife Glace",
    
"Knife Slice"
};

new 
KNF[33];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say /knife","KnfMenu");
    
register_event("CurWeapon""CurentWeapon""be""1=1");
}

public 
plugin_precache() 

    for(new 
isizeof KNFModelsi++) 
    {
        
precache_model(KNFModels[i]);
    }
}

public 
MenuKnf(id)
{
    new 
menu menu_create("\y>>>>> \rKnife Menu \y<<<<<^n \dby >>\rRevCrew\d<<""KnfCase")
    
    
menu_additem(menu"Knife \r[DEFAUT]^n""1"0)
    
menu_additem(menu"\wKnife \yGamma""2"0)
    
menu_additem(menu"\wKnife \yTatto's""3"0)
    
menu_additem(menu"\wKnife \yGlace""4"0)
    
menu_additem(menu"\wKnife \ySlice""5"0)
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu);
    
    return 
1
}

public 
KnfCase(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        return 
1;
    }
    new 
nick[33]; get_user_name(idnick32);
    
KNF[id] = item;
    
CC_SendMessage(id"&x03%s &x01You Chouse &x04%s &x01as Your Knife"nickKNFMenuNames[item]);
    
    
menu_destroy (menu);
    return 
1;
}

public 
CurentWeapon(id
{
    if(
get_user_weapon(id) == CSW_KNIFE
    {
        
set_pev(idpev_viewmodel2KNFModels[KNF[id]]);
    }
}

public 
KnfMenu(id)
{
    if(
is_user_alive(id))
    {
        
MenuKnf(id);
    }else{
        
MenuKnf(id);
    }


Last edited by lantimilan; 02-28-2024 at 01:45. Reason: Solved
lantimilan is offline
Send a message via MSN to lantimilan
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 02-25-2024 , 19:32   Re: Knife Not Change
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=293632
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 02-25-2024 , 19:32   Re: Knife Not Change
Reply With Quote #3

  1. CurWeapon
  2. Ham_Item_Deploy
__________________
mlibre is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 02-26-2024 , 00:39   Re: Knife Not Change
Reply With Quote #4

run client_cmd(id, "lastinv;lastinv") right after set_pev
__________________
bigdaddy424 is online now
lantimilan
Senior Member
Join Date: May 2016
Old 02-26-2024 , 02:44   Re: Knife Not Change
Reply With Quote #5

Quote:
Originally Posted by Nutu_ View Post
Thanks man but i need for some weapons not for knife and i dont use level just skins
lantimilan is offline
Send a message via MSN to lantimilan
lantimilan
Senior Member
Join Date: May 2016
Old 02-26-2024 , 18:28   Re: Knife Not Change
Reply With Quote #6

Quote:
Originally Posted by mlibre View Post
  1. CurWeapon
  2. Ham_Item_Deploy
Can you edit in plugin what do you said please ?
lantimilan is offline
Send a message via MSN to lantimilan
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 02-27-2024 , 07:36   Re: Knife Not Change
Reply With Quote #7

Quote:
Originally Posted by lantimilan View Post
Can you edit in plugin what do you said please ?
let's go in parts
  1. we added two modules that we will use next
    Quote:
    Originally Posted by lantimilan View Post
    Code:
    #include <amxmodx> //#include <cstrike> #include <cromchat>
    #include <hamsandwich>
    #include <engine>
  2. here we can directly add the color parameters
    Quote:
    Originally Posted by lantimilan View Post
    Code:
    new const KNFMenuNames[][] = {     /*     "Knife [DEFAUT]",     "Knife Gamma",     "Knife Tatto's",     "Knife Glace",     "Knife Slice"     */    
        "Knife \r[DEFAUT]^n",
        "\wKnife \yGamma",
        "\wKnife \yTatto's",
        "\wKnife \yGlace",
        "\wKnife \ySlice"
    }
  3. we disable the CurWeapon to use Ham_Item_Deploy
    Quote:
    Originally Posted by lantimilan View Post
    Code:
    public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_clcmd("say /knife","KnfMenu");     //register_event("CurWeapon", "CurentWeapon", "be", "1=1");
        RegisterHam(Ham_Item_Deploy, "weapon_knife", "Ham_Item_Deploy_Post", true)
    }
  4. we start the loop from point 1 since the first one does not require reloading, we also make sure that the mdls exist to prevent the server from crashing.
    Quote:
    Originally Posted by lantimilan View Post
    Code:
    public plugin_precache() {     //for(new i; i < sizeof KNFModels; i++)
        for(new i = 1; i < sizeof KNFModels; i++)
        {
            if(file_exists(KNFModels[i]))
            {
                precache_model(KNFModels[i]);
            }
            else
            {
                #if AMXX_VERSION_NUM <= 182
                new sfs[256]; formatex(sfs, charsmax(sfs), "No exist: ^"%s^"", KNFModels[i])
               
                set_fail_state(sfs)
                #else
                set_fail_state("No exist: ^"%s^"", KNFModels[i])
                #endif
            }
        }
    }
  5. here we can apply a loop to later use the array created previously where we adjust the color parameters in KNFMenuNames
    Quote:
    Originally Posted by lantimilan View Post
    Code:
    public MenuKnf(id) {     new menu = menu_create("\y>>>>> \rKnife Menu \y<<<<<^n \dby >>\rRevCrew\d<<", "KnfCase")     /*     menu_additem(menu, "Knife \r[DEFAUT]^n", "1", 0)     menu_additem(menu, "\wKnife \yGamma", "2", 0)     menu_additem(menu, "\wKnife \yTatto's", "3", 0)     menu_additem(menu, "\wKnife \yGlace", "4", 0)     menu_additem(menu, "\wKnife \ySlice", "5", 0)     */
        for(new i; i < sizeof KNFMenuNames; i++)
        {
            menu_additem(menu, KNFMenuNames[i])
        }
            menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);     menu_display(id, menu, 0 );         //return 1; }
  6. we verify if you have the knife in your hand when selecting another one in the menu, to later make the new model visible. suggestion by @bigdaddy424, we also make a small adjustment when it comes to obtaining the nickname.
    Quote:
    Originally Posted by lantimilan View Post
    Code:
    public KnfCase(id, menu, item) {     if(item == MENU_EXIT)     {         return 1;     }    
        if(is_user_alive(id) && get_user_weapon(id) == CSW_KNIFE)
        {
            client_cmd(id, "lastinv;lastinv")
        }
            //new nick[33]; get_user_name(id, nick, 32);
        new nick[32]; get_user_name(id, nick, charsmax(nick));
            KNF[id] = item;         CC_SendMessage(id, "&x03%s &x01You Chouse &x04%s &x01as Your Knife", nick, KNFMenuNames[item]);         menu_destroy (menu);         return 1; }
  7. we finish with what makes the magic...
    Quote:
    Originally Posted by lantimilan View Post
    Code:
    /* public CurentWeapon(id) {     if(get_user_weapon(id) == CSW_KNIFE)     {         set_pev(id, pev_viewmodel2, KNFModels[KNF[id]]);     } } */
    public Ham_Item_Deploy_Post(iWeapon)
    {
        if( !is_valid_ent(iWeapon) )
            return HAM_IGNORED
           
        const OFFSET_WEAPONOWNER = 41
        const OFFSET_LINUX_WEAPONS = 4
           
        new iPlayer = get_pdata_cbase(iWeapon, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
       
        if( !is_user_connected(iPlayer) || !KNF[iPlayer] )
            return HAM_IGNORED
           
        entity_set_string(iPlayer, EV_SZ_viewmodel, KNFModels[KNF[iPlayer]])
       
        return HAM_IGNORED
    }
    /* public KnfMenu(id) {     if(is_user_alive(id))     {         MenuKnf(id);     }else{         MenuKnf(id);     } } */

this would be the final result
__________________

Last edited by mlibre; 02-28-2024 at 16:55. Reason: /knife
mlibre is offline
lantimilan
Senior Member
Join Date: May 2016
Old 02-27-2024 , 11:46   Re: Knife Not Change
Reply With Quote #8

Thank you very much mlibre ;)
lantimilan is offline
Send a message via MSN to lantimilan
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 02-28-2024 , 16:53   Re: Knife Not Change
Reply With Quote #9

Quote:
Originally Posted by lantimilan View Post
Thank you very much mlibre ;)
you're welcome, it's a pleasure.
__________________
mlibre is offline
Reply



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 22:01.


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