Raised This Month: $ Target: $400
 0% 

Weapon Change Model


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-07-2017 , 06:17   Weapon Change Model
Reply With Quote #1

Hello. I am trying to make a plugin that is supossed to change the weapon skin for v,w and p.
I failed to do it, so, can anyone fix the plugin for me? Thanks !

Code:
/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "Weapon Changer"
#define VERSION "1.0"
#define AUTHOR "DarthMan"

new file_model[128]
new p_modelsnum


public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_event("CurWeapon", "Event_CurWeapon", "be","1=1")
	register_forward(FM_SetModel, "fw_SetModel")
}

public plugin_precache()
{
    new conffile_mdl[200]
    new configdir_mdl[200]
 
    get_configsdir(configdir_mdl,199)
    format(conffile_mdl,199,"%s/weapons-models.ini",configdir_mdl)
    if(!file_exists(conffile_mdl))
    {
        log_amx("amxmodx/configs/weapons-models.ini is missing!")
        return 0
    }
    
    new line = 0, textline[256], len
    const SIZE = 63
    new line_model[SIZE + 1], line_model_replace[SIZE + 1], parsedParams;  
    new model_path[128];
    new linetoread[512];
    
    while ((line = read_file(conffile_mdl, line, textline, 255, len)))
    {
	if (len == 0 || equal(textline, ";", 1))
	continue // comment line
	formatex(linetoread, 511, "%s^" ^"%s^"", line_model, line_model_replace)
	parsedParams = parse(textline, line_model, SIZE, line_model_replace)
	if (parsedParams == 2)
	{
	format(model_path, charsmax(model_path), "models/max/%s.mdl",line_model_replace)
	precache_model(model_path);
	p_modelsnum++;
	}
	if (parsedParams != 2)
	continue	// Send warning/error?
    }
    return PLUGIN_HANDLED;
}

public Event_CurWeapon(id) 
{     
    new szModel[32] , szReplace[32], parsedParams;
    new conffile_mdl[200];
    new configdir_mdl[200];
    get_configsdir(configdir_mdl,199)
    format(conffile_mdl,199,"%s/weapons-models.ini",configdir_mdl)
    for(new i=0;i<p_modelsnum;i++)
    {
    	new buffer;
	read_file(conffile_mdl, i, file_model, 127, buffer)
	parsedParams = parse(file_model,szModel,charsmax(szModel),szReplace,charsmax(szReplace))
	if (parsedParams == 2)
	{
		set_pev(id,pev_viewmodel2,szReplace[i]);
		set_pev(id,pev_weaponmodel2,szReplace[i]);
	}
	if (parsedParams != 2)
	continue		
    }
    return PLUGIN_CONTINUE;	
}

public fw_SetModel(entity, model[])
{
    new szModel[32] , szReplace[32], parsedParams;
    new conffile_mdl[200];
    new configdir_mdl[200];
    get_configsdir(configdir_mdl,199)
    format(conffile_mdl,199,"%s/weapons-models.ini",configdir_mdl)
    for(new i=0;i<p_modelsnum;i++)
    {
    	new buffer;
	read_file(conffile_mdl, i, file_model, 127, buffer)
	parsedParams = parse(file_model,szModel,charsmax(szModel),szReplace,charsmax(szReplace))
	if (parsedParams == 2)
	{
		engfunc(EngFunc_SetModel, entity, szReplace)
		return FMRES_SUPERCEDE
	}
	if (parsedParams != 2)
	continue		
    }
    return FMRES_IGNORED
}
DarthMan is offline
 



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 17:48.


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