Raised This Month: $ Target: $400
 0% 

Ham_item_deploy


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-21-2014 , 17:17   Re: Ham_item_deploy
Reply With Quote #4

I'll just suggest untested method, because I haven't got time to test it, but decided to share it. Any modifications will be done later, I just want to show the idea. You may use an enum and a const to loop and register the weapons by their "weapon_" name, then to set the model for each weapon by the const and a loop.
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <engine>

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



enum _:WeaponParts
{
    
_wname[32],
    
_vmodel[32],
    
_pmodel[32]
}

new const 
WeaponsToLoop[][WeaponParts]=
{
    {
"weapon_knife"KNIFE_VIEWKNIFE_PLAYER},
    {
"weapon_c4"C4_VIEWC4_PLAYER},
    {
"weapon_hegrenade"HE_VIEWHE_PLAYER},
    {
"weapon_smokegrenade"SE_VIEWSE_PLAYER},
    {
"weapon_flashbang"FL_VIEWFL_PLAYER}
    
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    for(new 
0sizeof(WeaponsToLoop) - 1i++)
    {
        
RegisterHam(Ham_Item_DeployWeaponsToLoop[i][_wname], "fwReplaceModels"0)
    }    
}

public 
fwReplaceModels(ent)
{
    new 
id get_pdata_cbaseent41)
    
    
set_task(0.1"chat"id)
                
    
}

public 
chat(id)
{
    new 
weapon,clip,ammo,item
    weapon 
get_user_weapon(idclipammo)
    switch(
weapon)
    {
        case 
CSW_KNIFE:     item 0
        
case CSW_C4:         item 1
        
case CSW_HEGRENADE:     item 2
        
case CSW_FLASHBANG:     item 3
        
case CSW_SMOKEGRENADE:     item 4
    
}
    
            
    
entity_set_string(idEV_SZ_viewmodelWeaponsToLoop[item][_vmodel])  
    
entity_set_string(idEV_SZ_weaponmodelWeaponsToLoop[item][_pmodel])  

EDIT: The code is edited to the optimal way. So, look. In Ham_Item_Deploy, get_user_weapon is called before the change and actually in the moment of change it takes the index of the previous weapon. So, I made it with task, which to take the weapon index 0.1 sec after the change. Here you go, this worked on a test with a chat command, so it should work with this function, too.
__________________

Last edited by Flick3rR; 05-21-2014 at 20:00. Reason: EDIT of the code
Flick3rR is offline
Send a message via Skype™ to Flick3rR
 



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


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