Raised This Month: $ Target: $400
 0% 

Setting Knife Model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
anon12
Member
Join Date: Aug 2013
Old 07-13-2014 , 23:12   Setting Knife Model
Reply With Quote #1

Why wont it work? The knife model is staying at default..

just wondering wats wrong with my code?
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fakemeta>
#include <creditweapons>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new PANDA_KNIFE[64] = "models/SurfWorld/v_pandaknife.mdl"
new DEFAULT_KNIFE[64] = "models/v_knife.mdl"

new bool:DefaultKnife[33]
new 
bool:PandaKnife[33]

#define WEAPON_ID CSW_KNIFE

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("CurWeapon","checkWeapon","be","1=1")
    
    
//Knifes
    
credits_shop_add_item("Default Knife \r[3]""knife"00"Callback_Default")
    
credits_shop_add_item("Panda Knife \r[3]""pandaknife"503000"Callback_PandaKnife")
}
public 
plugin_precache()
{
    
precache_model(DEFAULT_KNIFE)
    
precache_model(PANDA_KNIFE)
}
public 
Callback_Default(id)
{
    
DefaultKnife[id] = true
    PandaKnife
[id] = false
    
    
new weap read_data(2)
    
    if(
weap == WEAPON_ID && DefaultKnife[id] == true)
    {
        
set_pev(idpev_viewmodel2DEFAULT_KNIFE)
    }
}
public 
Callback_PandaKnife(id)
{
    
DefaultKnife[id] = false
    PandaKnife
[id] = true
    
    
new weap read_data(2)
    
        
    if(
weap == WEAPON_ID && PandaKnife[id] == true)
    {
        
set_pev(idpev_viewmodel2PANDA_KNIFE)
    }
}

public 
checkWeapon(id)
{
    new 
weap read_data(2)
    
    if(
weap==WEAPON_ID && PandaKnife[id] == true)
    {
        
set_pev(idpev_viewmodel2PANDA_KNIFE)
    }
    else if(
weap==WEAPON_ID && DefaultKnife[id] == true)
    {
        
set_pev(idpev_viewmodel2DEFAULT_KNIFE)
    }


Last edited by anon12; 07-14-2014 at 02:04.
anon12 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-14-2014 , 06:28   Re: Setting Knife Model
Reply With Quote #2

Attach the custom include which you are using. Also, there's absolutely no need to precache the default knife model - everyone has it.
__________________

Last edited by Flick3rR; 07-14-2014 at 07:49.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-14-2014 , 06:33   Re: Setting Knife Model
Reply With Quote #3

Use Ham_ItemDeploy instead of currentweapon event. Also, please give us your include file and the plugin that create this inc.

Last edited by HamletEagle; 07-14-2014 at 10:43.
HamletEagle is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-14-2014 , 07:54   Re: Setting Knife Model
Reply With Quote #4

It's not that fine. Now, when I'm on my PC, I can take a look at all of it.
You can't read_data(2) in menu callback?! This is especial data for the CurWeapon event.
As mentioned above, you can (and better) use Ham_ItemDeploy, or you can register CurWeapon only with knife. Look at amxconst.inc to see the index of knife and register in the event parameters (which now are "1=1").
Also, I think that callbacks should be registered with menu_makecallback("MyCallBackFunction"), but I could be wrong here (if your callback is working properly).
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Reply


Thread Tools
Display Modes

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 21:09.


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