Raised This Month: $51 Target: $400
 12% 

Changing weapon models (Extended)


Post New Thread Reply   
 
Thread Tools Display Modes
ish12321
Veteran Member
Join Date: May 2016
Old 08-11-2016 , 14:29   Re: Changing weapon models (Extended)
Reply With Quote #111

On drop can we check which weapon(name) is dropped ?
For ex - weapon_ak47 or something ...
ish12321 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-11-2016 , 15:37   Re: Changing weapon models (Extended)
Reply With Quote #112

get_user_weapon(id) + get_weaponname.
__________________
HamletEagle is offline
ish12321
Veteran Member
Join Date: May 2016
Old 08-12-2016 , 04:19   Re: Changing weapon models (Extended)
Reply With Quote #113

Quote:
Originally Posted by HamletEagle View Post
get_user_weapon(id) + get_weaponname.
Will it work with entity as the weapon's dropped I think the user will have another weapon in hand and it may give result of that instead of what we dropped ?
ish12321 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-12-2016 , 06:25   Re: Changing weapon models (Extended)
Reply With Quote #114

Hooking drop command + what I told you would work just fine. At this point, the next weapon is not yet deployed and m_pActiveItem still points to the item that you are going to drop.
__________________
HamletEagle is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-12-2016 , 08:20   Re: Changing weapon models (Extended)
Reply With Quote #115

Quote:
Originally Posted by HamletEagle View Post
Hooking drop command + what I told you would work just fine. At this point, the next weapon is not yet deployed and m_pActiveItem still points to the item that you are going to drop.
Remember that a weapon can also be dropped by its name. For example, if you held a knife and executed "drop weapon_ak47", get_user_weapon() will return knife's, not AK47's ID.
klippy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-12-2016 , 10:30   Re: Changing weapon models (Extended)
Reply With Quote #116

The thing is, I've realised that after posting and wanted to edit, but I forgot. Thanks for reminding.

ish12321, you can use such code:
PHP Code:
public ClientCommand_Drop(id)
{
    new 
WeaponName[32]
    
read_argv(1WeaponNamecharsmax(WeaponName))
    if(
WeaponName[0] == EOS)
    {
        new 
WeaponIndex get_user_weapon(id)
        
get_weaponname(WeaponIndexWeaponNamecharsmax(WeaponName))
    }

WeaponName holds what you are asking for.
__________________

Last edited by HamletEagle; 08-12-2016 at 13:32.
HamletEagle is offline
ish12321
Veteran Member
Join Date: May 2016
Old 08-12-2016 , 13:26   Re: Changing weapon models (Extended)
Reply With Quote #117

Quote:
Originally Posted by HamletEagle View Post
The thing is, I've realised that after posting and wanted to edit, but I forgot. Thanks for reminding.

ish12321, you can you such code:
PHP Code:
public ClientCommand_Drop(id)
{
    new 
WeaponName[32]
    
read_argv(1WeaponNamecharsmax(WeaponName))
    if(
WeaponName[0] == EOS)
    {
        new 
WeaponIndex get_user_weapon(id)
        
get_weaponname(WeaponIndexWeaponNamecharsmax(WeaponName))
    }

WeaponName holds what you are asking for.
When will your function be called that call command also can you supply please
ish12321 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-12-2016 , 13:31   Re: Changing weapon models (Extended)
Reply With Quote #118

register_clcmd("drop", "ClientCommand_Drop") :facepalm:
__________________

Last edited by HamletEagle; 08-12-2016 at 13:32.
HamletEagle is offline
ish12321
Veteran Member
Join Date: May 2016
Old 08-12-2016 , 13:56   Re: Changing weapon models (Extended)
Reply With Quote #119

In my plugin at fw_SetModel() I want get the name of weapon dropped and as per that I want replace the model (name is required in correct location of the weapon model)

Please can you tell me what edits should be done so as to do that as in my code I'm getting a error
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>

#define PLUGIN "VIP Models"
#define VERSION "1.0"
#define AUTHOR "Ish Chhabra"

const ADMIN_VIP = (1<<26); //Declaring new admin flag 'w'
new AllWeapons[] = {
	"weapon_p228",
	"weapon_shield",
	"weapon_scout",
	"weapon_hegrenade",
	"weapon_xm1014",
	"weapon_c4",
	"weapon_mac10",
	"weapon_aug",
	"weapon_smokegrenade",
	"weapon_elite",
	"weapon_fiveseven",
	"weapon_ump45",
	"weapon_sg550",
	"weapon_galil",
	"weapon_famas",
	"weapon_usp",
	"weapon_glock18",
	"weapon_awp",
	"weapon_mp5navy",
	"weapon_m249",
	"weapon_m3",
	"weapon_m4a1",
	"weapon_tmp",
	"weapon_g3sg1",
	"weapon_flashbang",
	"weapon_deagle",
	"weapon_sg552",
	"weapon_ak47",
	"weapon_knife",
	"weapon_p90"
}

new v_ModelLocation[200]
new w_ModelLocation[200]
new p_ModelLocation[200]

new iWeapon
new WeaponName[31]

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_event("CurWeapon", "vipChangeModel", "be","1=1")
	// Add your code here...
	register_forward(FM_SetModel, "fw_SetModel")
}

public plugin_precache() {
	for(new i=0;i<sizeof(AllWeapons);i++) {
		
		format(v_ModelLocation,199,"models/vip/v_%s.mdl",AllWeapons[i])
		format(w_ModelLocation,199,"models/vip/w_%s.mdl",AllWeapons[i])
		format(p_ModelLocation,199,"models/vip/p_%s.mdl",AllWeapons[i])
		
		if(file_exists(v_ModelLocation))
			precache_model(v_ModelLocation)
	
		if(file_exists(w_ModelLocation))
			precache_model(w_ModelLocation)
			
		if(file_exists(p_ModelLocation))
			precache_model(p_ModelLocation)
	}
}

public vipChangeModel(id) {
	//if(get_user_flags(id) & ADMIN_VIP) { // 'w' flag is for VIP's
		
		iWeapon = get_user_weapon(id)
		get_weaponname(iWeapon, WeaponName, 30)
		
		format(v_ModelLocation,199,"models/vip/v_%s.mdl",WeaponName)
		format(w_ModelLocation,199,"models/vip/w_%s.mdl",WeaponName)
		
		if (file_exists(v_ModelLocation))
			entity_set_string(id, EV_SZ_viewmodel, v_ModelLocation)
		
		if (file_exists(p_ModelLocation))
			entity_set_string(id, EV_SZ_weaponmodel, p_ModelLocation)
			
	//}
}

public fw_SetModel (id, entity, model[]) {
	// check if its a valid entity or else we'll get errors
	//if(!is_valid_ent(entity))
	//	return FMRES_IGNORED
	
	iWeapon = get_user_weapon(id)
	get_weaponname(iWeapon, WeaponName, 30)
	
	format(w_ModelLocation,199,"models/vip/w_%s.mdl",WeaponName)
	
	if (file_exists(w_ModelLocation)) {
		entity_set_model(entity, w_ModelLocation)
		return FMRES_SUPERCEDE
	}
	return FMRES_IGNORED
		
}
ish12321 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-12-2016 , 14:58   Re: Changing weapon models (Extended)
Reply With Quote #120

You should have asked this directly.....
Use pev_classname to get the entity classname.
__________________
HamletEagle is offline
Reply



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 12:02.


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