Raised This Month: $ Target: $400
 0% 

Knife Models [XP System & Skills Support]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-07-2018 , 08:07   Re: Knife Models [XP System Support]
Reply With Quote #11

Actually, I just tested it again and I think the problem is from fakemeta, not hamsandwich. Here's the code that won't work:

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

#if !defined m_pPlayer
    #define m_pPlayer 41
#endif

#define V_MODEL "models/iplaydr/v_knife20.mdl"
#define P_MODEL "models/iplaydr/p_knife20.mdl"

public plugin_init()
{
    
register_plugin("PluginName""1.0""OciXCrom")
    
RegisterHam(Ham_Spawn"player""OnPlayerSpawn"1)
    
RegisterHam(Ham_Item_Deploy"weapon_knife""OnKnifeDeploy"1)
    
//register_event("CurWeapon", "OnKnifeDeploy", "be", "1=1", "2=29")
}

public 
plugin_precache()
{
    
precache_model(V_MODEL)
    
precache_model(P_MODEL)
}

public 
OnPlayerSpawn(id)
{
    if(
is_user_alive(id))
    {
        
strip_user_weapons(id)
        
give_item(id"weapon_knife")
    }
}    

public 
OnKnifeDeploy(iEnt)
{
    new 
id pev(iEntpev_owner)
    
//new id = get_pdata_cbase(iEnt, 41, 5)
    
client_print(0print_chat"id is %i"id)
    
set_pev(idpev_viewmodel2V_MODEL)
    
set_pev(idpev_weaponmodel2P_MODEL)

This happens only if the weapons are removed on spawn.
The same code will work without problems if we use the CurWeapon event instead.

With the testing I just did, I found that using pev(iEnt, pev_owner) to get the player's id returns 0 which is why the models isn't set. It returns the correct id however if the weapons aren't removed on spawn.

Getting the id with get_pdata_cbase(iEnt, 41, 5) returns the correct value and the model is set.
__________________

Last edited by OciXCrom; 07-07-2018 at 08:13.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
 



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 18:15.


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