AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] Knife view model (https://forums.alliedmods.net/showthread.php?t=272974)

redivcram 10-10-2015 11:07

[Solved] Knife view model
 
Solved...

Solution below post(s)

PHP Code:

#pragma semicolon 1

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

public plugin_init()
{
    
register_plugin("testblah""1.0""redivcram");
    
    
register_event("CurWeapon""CurrentWeapon""be""1=1");
}

public 
plugin_precache()
{
    
precache_model("models/xgcdr/v_ctblade.mdl");
    
precache_model("models/xgcdr/v_tblade.mdl");
    
precache_model("models/xgcdr/v_vipblade.mdl");
    
precache_model("models/xgcdr/v_svipblade.mdl");
    
precache_model("models/xgcdr/v_adminblade.mdl");
    
precache_model("models/xgcdr/v_headblade.mdl");
}

public 
CurrentWeapon(id)
{
    if(
get_user_flags(id) & ADMIN_IMMUNITY && get_user_flags(id) && ADMIN_CVAR && get_user_weapon(id) == CSW_KNIFE)
    {
        
set_pev(idpev_viewmodel"models/xgcdr/v_headblade.mdl");
    }
    else if(
get_user_flags(id) & ADMIN_CHAT && get_user_weapon(id) == CSW_KNIFE)
    {
        
set_pev(idpev_viewmodel"models/xgcdr/v_adminblade.mdl");
    }
    else if(
get_user_flags(id) & ADMIN_LEVEL_F && get_user_weapon(id) == CSW_KNIFE)
    {
        
set_pev(idpev_viewmodel"models/xgcdr/v_svipblade.mdl");
    }
    else if(
get_user_flags(id) & ADMIN_LEVEL_H && get_user_weapon(id) == CSW_KNIFE)
    {
        
set_pev(idpev_viewmodel"models/xgcdr/v_vipblade.mdl");
    }
    else
    {
        if(
get_user_team(id) == && get_user_weapon(id)== CSW_KNIFE)
        {
            
set_pev(idpev_viewmodel"models/xgcdr/v_ctblade.mdl");
        }
        else if(
get_user_team(id) == && get_user_weapon(id) == CSW_KNIFE)
        {
            
set_pev(idpev_viewmodel"models/xgcdr/v_tblade.mdl");
        }
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_HANDLED;



HamletEagle 10-10-2015 13:10

Re: [Help] Knife view model
 
You should be using Deploy, not CurWeapon. Deploy is the right place to put your code, you will set exactly after the game.

Now, I think that the problem is that you are using pev_viewmodel. When using pev_viewmodel you have to allocate the string. If you don't want to allocate(EngFunc_AllocString) manually, you can use pev_viewmodel2. If you choose to allocate be sure to do only one time in a place like init and save the value.

redivcram 10-10-2015 13:47

Re: [Help] Knife view model
 
Alright, thanks, that should do it... took a while to search for the other pevs

Spoiler


All times are GMT -4. The time now is 22:04.

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