Raised This Month: $ Target: $400
 0% 

Weapon Change Model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-07-2017 , 13:33   Re: Weapon Change Model
Reply With Quote #1

Quote:
Originally Posted by Natsheh View Post
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fakemeta>
#include <tfcx>

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

new const FILE[] = "weapons_models.ini";
new const 
DIRECTOR[] = "addons/amxmodx/configs";

new Array:
g_arraygarraysize;

public 
plugin_precache()
{
    
g_array ArrayCreate(641)
    
garraysize xmod_get_maxweapons();
    for(new 
0garraysizei++)
        
ArrayPushString(g_array"")
    
    static 
strFile[64];
    
formatex(strFile63"%s/%s"DIRECTORFILE)
    
    if(!
file_exists(strFile)) return; // file isnt exists
    
new fp fopen(strFile"rt")
    if(!
fp) return; // file isnt exists or failed to open.
    
new sBuffer[128], sParam[2][64], paramj;
    
    while(!
feof(fp)) // reading file line by line
    
{
        
fgets(fpsBuffer127// getting line info..
        
trim(sBuffer//. trim all spaces..
        
        
if(sBuffer[0] == ';' || sBuffer[0] == '/' && sBuffer[1] == '/' || strlen(sBuffer) <= 3) continue;
        
        
param parse(sBuffersParam[0], charsmax(sParam[]), sParam[1], charsmax(sParam[]))
        if(
param != 2) continue;
        for(
0<= charsmax(sParam); j++)
            
remove_quotes(sParam[j]);
        
        if(
tfc_weapon_exists(sParam[0]))
        {
            
ArraySetString(g_arrayjsParam[1])
        }
    }
    
    
fclose(fp// closing the file...,after we  finished from it
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_forward(FM_SetModel"fw_SetModel_pre")
}

public 
fw_SetModel_pre(const ent, const model[])
{
    if(!
pev_valid(ent)) // if its an entity ( NOT A WORLD )
        
return FMRES_IGNORED;
    
    if(
containi(model"w_") != -&& pev(entpev_owner) == 0)
    {
        new 
sName[32], sModel[64];
        
xmod_get_wpnname(ent,sName,31)
        new 
tfc_weapon_exists(sName)
        if(
== -1) return FMRES_IGNORED;
        
ArrayGetString(g_arrayjsModelcharsmax(sModel))
        
set_pev(entpev_modelsModel)
        return 
FMRES_SUPERCEDE;
    }
    return 
FMRES_IGNORED;
}

stock tfc_weapon_exists(const weapon[])
{
    new 
sWpnname[32], i;
    for(
0garraysizei++)
    {
        
xmod_get_wpnname(i,sWpnname,charsmax(sWpnname))
        if(
equali(sWpnnameweapon))
        {
            return 
i;
        }
    }
    return -
1;

This one's not working but thanks anyway for trying.
DarthMan 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 17:48.


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