AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Weapon model change (https://forums.alliedmods.net/showthread.php?t=154414)

egbertjan 04-07-2011 13:41

Weapon model change
 
Hello,

I have a weapon model, but when I get the weapon and change to a pistol it keeps the weapon model instead of taking the pistol. When I shoot I do hear the pistol shot, so that means that the weapon model replaces the pistol, but when I change to another item (like a knife) and then change to the pistol I do get it. So I was wondering what I did wrong with this code:

PHP Code:

    new wpnid read_data(2)

        if(
player_class[id] == Mage  && wpnid == CSW_AK47 ) {
        
entity_set_string(idEV_SZ_viewmodelMAGICAK47)
        } 


drekes 04-08-2011 15:41

Re: Weapon model change
 
Try this (untested):

PHP Code:

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

public plugin_init()
    
RegisterHam(Ham_Item_Deploy"weapon_ak47""FwdAk47DeployPost"1);
    
    
public 
FwdAk47DeployPost(iWeapon)
{    
    new 
id entity_get_edict(iWeaponEV_ENT_owner);
    
    if(
id && player_class[id] == Mage)
        
entity_set_string(idEV_SZ_viewmodelMAGICAK47);



egbertjan 04-08-2011 16:18

Re: Weapon model change
 
This seems to be working perfectly! Thank you very much! If I will have other questions, could I PM you?

Edit: There is 1 run time error. When I drop the gun, and pick it up it says "Index out of bounds" Also I would have to switch weapons to get the model back on.

Exolent[jNr] 04-08-2011 16:29

Re: Weapon model change
 
Quote:

Originally Posted by egbertjan (Post 1446121)
Please, any suggestions?

Don't bump until 2 weeks have passed since last post.

Also, try this:

PHP Code:

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

#define m_pPlayer 41

public plugin_init()
    
RegisterHam(Ham_Item_Deploy"weapon_ak47""FwdAk47DeployPost"1);
    
    
public 
FwdAk47DeployPost(iWeapon)
{    
    new 
id get_pdata_cbase(iWeaponm_pPlayer4);
    
    if(
id && player_class[id] == Mage)
        
entity_set_string(idEV_SZ_viewmodelMAGICAK47);



egbertjan 04-08-2011 16:41

Re: Weapon model change
 
Thank you, this is working.

Sorry for the quick bump, sometimes I got the feeling that when it's not at the first page anymore people will not look into it anymore. I will try to set that out of my mind.


All times are GMT -4. The time now is 20:11.

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