Thread: [Solved] Knife Not Change
View Single Post
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