AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting Knife Model (https://forums.alliedmods.net/showthread.php?t=244118)

anon12 07-13-2014 23:12

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

just wondering wats wrong with my code? :P
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)
    }



Flick3rR 07-14-2014 06:28

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

HamletEagle 07-14-2014 06:33

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

Flick3rR 07-14-2014 07:54

Re: Setting Knife Model
 
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).


All times are GMT -4. The time now is 21:09.

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