View Single Post
Kxnrl
AlliedModders Donor
Join Date: May 2015
Old 05-26-2017 , 16:40   Re: [CS:GO] -N- Arms Fix
Reply With Quote #95

PHP Code:
#include <sdktools>

#pragma newdecls required

char g_szDefaultModel[][] = 
{
    
"models/player/custom_player/legacy/tm_anarchist.mdl",
    
"models/player/custom_player/legacy/tm_pirate.mdl",
    
"models/player/custom_player/legacy/ctm_gign.mdl",
    
"models/player/custom_player/legacy/ctm_fbi.mdl"
};

public 
void OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawnEventHookMode_Post);
}

public 
void OnConfigsExecuted() 
{
    
PrecacheDefaultModel();
}

public 
void Event_PlayerSpawn(Handle event, const char[] namebool dontBroadcast)
{
    
int userid GetEventInt(event"userid");
    
int client GetClientOfUserId(userid);

    
// Set Default
    
SetDefaultSkin(clientGetClientTeam(client));
    
    
// Set Custom
    
SetEntPropString(clientProp_Send"m_szArmsModel""Your Custom Arms");
    
CreateTimer(0.1Timer_ModelDelayuserid);

    
// Fix Spawn without any weapon.
    
int decoy GivePlayerItem(client"weapon_decoy");
    if(
decoy != -1CreateTimer(0.1Timer_DecoyDelayEntIndexToEntRef(decoy));
}

public 
Action Timer_DecoyDelay(Handle timerint iRef)
{
    
int decoy decoy EntRefToEntIndex(decoy)
    
    if(!
IsValidEdict(decoy))
        return 
Plugin_Stop;

    
int owner GetEntPropEnt(decoyProp_Send"m_hOwnerEntity");
    
    if(
IsClientInGame(owner) && IsPlayerAlive(owner))
        
RemovePlayerItem(ownerdecoy);
    
    
AcceptEntityInput(decoy"Kill");

    return 
Plugin_Stop;
}

public 
Action Timer_ModelDelay(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);
    
    if(!
IsClientInGame(client) || !IsPlayerAlive(client))
        return 
Plugin_Stop;
    
    
SetEntityModel(client"Your Custom Model");

    return 
Plugin_Stop;
}

void SetDefaultSkin(int clientint team)
{
    
char m_szMoedl[128];
    
GetEntPropString(clientProp_Data"m_ModelName"m_szMoedl128);

    if(
team == 2)
    {
        
SetEntityModel(client, (StrContains(m_szMoedl"tm_anarchist") != -1) ? g_szDefaultModel[1] : g_szDefaultModel[0]);
        
SetEntPropString(clientProp_Send"m_szArmsModel""models/weapons/t_arms.mdl");
    }
    else if(
team == 3)
    {
        
SetEntityModel(client, (StrContains(m_szMoedl"ctm_fbi") != -|| StrContains(m_szMoedl"ctm_sas") != -|| StrContains(m_szMoedl"ctm_swat") != -1) ? g_szDefaultModel[2] : g_szDefaultModel[3]);
        
SetEntPropString(clientProp_Send"m_szArmsModel""models/weapons/ct_arms.mdl");
    }
}

void PrecacheDefaultModel()
{
    for(
int x 0sizeof(g_szDefaultModel); ++x)
        
PrecacheModel(g_szDefaultModel[x]);

    
PrecacheModel("models/weapons/t_arms.mdl");
    
PrecacheModel("models/weapons/ct_arms.mdl");
    
    
// Precahce Your Custom Model and Arms.
    
PrecacheModel("Your Custom Model");
    
PrecacheModel("Your Custom Arms");

this work for me.
tested on ze/mg/ttt/casual server.
__________________
Kxnrl is offline