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

Changing weapon models (Extended)


Post New Thread Reply   
 
Thread Tools Display Modes
ish12321
Veteran Member
Join Date: May 2016
Old 08-12-2016 , 15:10   Re: Changing weapon models (Extended)
Reply With Quote #121

That way I get weaponbox but I want the name of weapon ,i.e., something link weapon_ak47 or. ...

So is that possible ?
ish12321 is offline
ish12321
Veteran Member
Join Date: May 2016
Old 08-12-2016 , 15:56   Re: Changing weapon models (Extended)
Reply With Quote #122

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))
			set_pev(id,pev_viewmodel2,v_ModelLocation)
		
		if (file_exists(p_ModelLocation))
			set_pev(id,pev_weaponmodel2,p_ModelLocation)
			
	//}
}

public fw_SetModel (entity, model[]) {
	// check if its a valid entity or else we'll get errors
	if(!is_valid_ent(entity))
		return FMRES_IGNORED
	pev(entity, pev_classname, WeaponName,31)
	
	for(new i=0;i<sizeof(AllWeapons);i++) {
		if (equal(WeaponName, AllWeapons[i])) {
			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
		
}

Did this much still not working can you tell me what's wrong
ish12321 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-13-2016 , 11:11   Re: Changing weapon models (Extended)
Reply With Quote #123

Quote:
Originally Posted by ish12321 View Post
That way I get weaponbox but I want the name of weapon ,i.e., something link weapon_ak47 or. ...

So is that possible ?
Sorry. You need to loop all slots from the box to get the weapon entity, after that you can use pev_classname on it and get what you need.
PHP Code:
RetrieveWeapon(WeaponBoxEntity

    const 
XoWeapon 4
    
new const m_rgpPlayerItems_CWeaponBox[6] = {3435, ...}
    
    new 
WeaponEntity
    
for(new 1isizeof m_rgpPlayerItems_CWeaponBoxi++) 
    { 
        
WeaponEntity get_pdata_cbase(WeaponBoxEntitym_rgpPlayerItems_CWeaponBox[i], XoWeapon
        if(
pev_valid(WeaponEntity)) 
        { 
            break
        } 
    } 

    return 
WeaponEntity

Use this stock, it returns the weapon entity index that's inside the weaponbox.
__________________
HamletEagle is offline
lolerto
Member
Join Date: Jul 2011
Old 02-01-2021 , 02:19   Re: Changing weapon models (Extended)
Reply With Quote #124

Quote:
Originally Posted by ConnorMcLeod View Post
https://forums.alliedmods.net/showth...78#post1020078

Code:
 * v 0.2.3
 * - Added shield support
 * - Fixed missing p_ models support that were causing crashes
 * - Added pdata check on player on weapon deploy event
Also, Freeman, if you experience crashes, you can enable line 65 and recompile :
Code:
// #define DONT_BLOCK_PRECACHE
And see if crashes still happen or not.

If line 286 ( get_pdata_cbase(id, m_pActiveItem) ) still throw errors after pev_valid(id) == 2 check is passed, fault is on hamsandwich module, can't do anything on it (bug reported https://bugs.alliedmods.net/show_bug.cgi?id=5787 ).
How can I restrict only for administrators?
__________________
lolerto is offline
Reply


Thread Tools
Display Modes

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 07:13.


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