AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Changing weapons model (https://forums.alliedmods.net/showthread.php?t=164273)

dreamedward 08-09-2011 12:14

Changing weapons model
 
Can someone give me a simple code that changes knife's model.

wickedd 08-09-2011 13:03

Re: Changing weapons model
 
Weapon Model Replacement

drekes 08-09-2011 13:06

Re: Changing weapons model
 
Search in the tutorial section.

cheap_suit made a tutorial about this.

dreamedward 08-09-2011 14:57

Re: Changing weapons model
 
Found the script -
PHP Code:

#include <amxmodx> 
#include <engine> 
#include <fakemeta> 
new VIEW_MODEL[]    = "models/v_newKnife.mdl" 
new PLAYER_MODEL[]    = "models/p_newKnife.mdl" 
new WORLD_MODEL[]    = "models/w_knife.mdl"
new OLDWORLD_MODEL[]    = "models/w_knife.mdl"
new PLUGIN_NAME[]        = "Custom Knife Model" 
new PLUGIN_AUTHOR[]    = "Cheap_Suit" 
new PLUGIN_VERSION[]     = "1.0" 
public plugin_init() 
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)     
    
register_event("CurWeapon""Event_CurWeapon""be","1=1")
    
register_forward(FM_SetModel"fw_SetModel")

public 
plugin_precache() 
{    
    
precache_model(VIEW_MODEL)     
    
precache_model(PLAYER_MODEL
    
precache_model(WORLD_MODEL)

public 
Event_CurWeapon(id
{     
    new 
weaponID read_data(2
    if(
weaponID != CSW_KNIFE)
        return 
PLUGIN_CONTINUE
    set_pev
(idpev_viewmodel2VIEW_MODEL)
    
set_pev(idpev_weaponmodel2PLAYER_MODEL)
    
    return 
PLUGIN_CONTINUE 
}
public 
fw_SetModel(entitymodel[])
{
    if(!
is_valid_ent(entity)) 
        return 
FMRES_IGNORED
    
if(!equali(modelOLDWORLD_MODEL)) 
        return 
FMRES_IGNORED
    
new className[33]
    
entity_get_string(entityEV_SZ_classnameclassName32)
    
    if(
equal(className"weaponbox") || equal(className"armoury_entity") || equal(className"grenade"))
    {
        
engfunc(EngFunc_SetModelentityWORLD_MODEL)
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED


Now how can I make it to change the knife model only when I write a command in chat and at a new round to reset back to the normal knife model?

drekes 08-09-2011 15:35

Re: Changing weapons model
 
Try something like this:

PHP Code:

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

new VIEW_MODEL[]        = "models/v_newKnife.mdl" 
new PLAYER_MODEL[]       = "models/p_newKnife.mdl" 
new WORLD_MODEL[]        = "models/w_knife.mdl"
new OLDWORLD_MODEL[]    = "models/w_knife.mdl"

new PLUGIN_NAME[]       = "Custom Knife Model" 
new PLUGIN_AUTHOR[]        = "Cheap_Suit" 
new PLUGIN_VERSION[]    = "1.0" 

new boolg_bHasModel[33] = {false, ...};

public 
plugin_init() 
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR
    
    
register_clcmd("say /knife""CmdKnife");
    
register_logevent("EventRoundStart"2"1=Round_Start");
    
register_event("CurWeapon""Event_CurWeapon""be","1=1")
    
    
register_forward(FM_SetModel"fw_SetModel")


public 
CmdKnife(id)
{
    
g_bHasModel[id] = true;
    
    return 
PLUGIN_HANDLED;
}

public 
plugin_precache() 
{    
    
precache_model(VIEW_MODEL)     
    
precache_model(PLAYER_MODEL
    
precache_model(WORLD_MODEL)

public 
Event_CurWeapon(id
{     
    if(!
g_bHasModel[id])
        return 
PLUGIN_CONTINUE;
        
    new 
weaponID read_data(2
    if(
weaponID != CSW_KNIFE)
        return 
PLUGIN_CONTINUE
    set_pev
(idpev_viewmodel2VIEW_MODEL)
    
set_pev(idpev_weaponmodel2PLAYER_MODEL)
    
    return 
PLUGIN_CONTINUE 
}
public 
fw_SetModel(entitymodel[])
{
    if(!
is_valid_ent(entity)) 
        return 
FMRES_IGNORED
    
if(!equali(modelOLDWORLD_MODEL)) 
        return 
FMRES_IGNORED
    
new className[33]
    
entity_get_string(entityEV_SZ_classnameclassName32)
    
    if(
equal(className"weaponbox") || equal(className"armoury_entity") || equal(className"grenade"))
    {
        
engfunc(EngFunc_SetModelentityWORLD_MODEL)
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED
}  


public 
EventRoundStart()
    
arrayset(g_bHasModelfalsesizeof(g_bHasModel)); 

If you're not able to code yourself, it might be easier to use the plugin wickedd posted.

dreamedward 08-10-2011 05:25

Re: Changing weapons model
 
I was wondering could you tell me how can I make it to all players by menu? I mean Im the admin and every round I choose which knife will be for Ts which knife for CTs. Something like 1. New knife1
2. New knife2 3.New Knife3
I'll be very greatful! Thanks!

Exolent[jNr] 08-10-2011 10:06

Re: Changing weapons model
 
There is already a different knife model plugin with a menu and all.
Search for it.

dreamedward 08-10-2011 10:59

Re: Changing weapons model
 
Yes but its not the same. Has many differences than what I want.

hornet 08-10-2011 11:17

Re: Changing weapons model
 
Of course It won't be exactly the same but all of the functionality is there.

dreamedward 08-10-2011 16:45

Re: Changing weapons model
 
Well could you tell me how can I make it the Admin to set different knife models to all players, not for himself only? And every round the models to reset and to let him choose the knifes for Ts and CTs. Here is the plugin: http://forums.alliedmods.net/showthread.php?t=44586


All times are GMT -4. The time now is 09:12.

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