Raised This Month: $32 Target: $400
 8% 

[CSGO] Working non-legacy models and glove skins


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OfficialSikari
Junior Member
Join Date: Aug 2017
Location: /dev/null
Old 09-29-2017 , 16:20   [CSGO] Working non-legacy models and glove skins
Reply With Quote #1

Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma newdecls required

// Models
#define T_PLAYER_MODEL "models/player/tm_professional_var1.mdl"
#define CT_PLAYER_MODEL "models/player/ctm_sas_varianta.mdl"

public void OnMapStart()
{
	PrecacheModel(T_PLAYER_MODEL, true);
	PrecacheModel(CT_PLAYER_MODEL, true);
	
	HookEvent("player_spawn", OnPlayerSpawn);
}

public void OnPlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
	int userid = event.GetInt("userid");
	CreateTimer(0.1, SetModels, userid);
}

public Action SetModels(Handle timer, int userid)
{
	int client = GetClientOfUserId(userid);

        if (!IsValidClient(client))
        {
                return Plugin_Handled;
        }
	
	switch(GetClientTeam(client))
	{		
		case CS_TEAM_T:
		{
			SetEntityModel(client, T_PLAYER_MODEL);
		}
		case CS_TEAM_CT:
		{
			SetEntityModel(client, CT_PLAYER_MODEL);
		}
                default:
                {
                        return Plugin_Handled;
                }
	}
}

Last edited by OfficialSikari; 01-14-2019 at 16:02.
OfficialSikari is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 09-30-2017 , 20:42   Re: [CSGO] Working non-legacy models and glove skins
Reply With Quote #2

if its just gonna be 1 model per team you could just use
PHP Code:
#define T_MODEL "models/player/tm_professional_var1.mdl" 
so you wouldn't need to globally declare strings and call a function to move them into the buffer. Also the IsValidClient function is missing. Honestly no need to use a switch case for 2 things. Also instead of GetEventInt you could just use Event directly instead of Handle so you could write something like
PHP Code:
event.GetInt("userid"); 
PHP Code:
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <cstrike>

#define T_PLAYER_MODEL    "models/player/tm_professional_var1.mdl"
#define CT_PLAYER_MODEL    "models/player/ctm_sas_varianta.mdl"

public void OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawn)
}

public 
void OnMapStart()
{
    
PrecacheModel(T_PLAYER_MODELtrue);
    
PrecacheModel(CT_PLAYER_MODELtrue);
}

public 
void Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int userid event.GetInt("userid");
    
CreateTimer(0.1SetModelsuserid);
}

public 
Action SetModels(Handle timerany userid)
{
    
int client GetClientOfUserId(userid);
    
    if(!
IsValidClient(client))
        return;
    
    switch(
GetClientTeam(client))
    {
        case 
CS_TEAM_CT:
        {
            
SetEntityModel(clientCT_PLAYER_MODEL);
        }
        
        case 
CS_TEAM_T:
        {
            
SetEntityModel(clientT_PLAYER_MODEL);
        }
    }
}


bool IsValidClient(int client)
{
    return (
<= client <= MaxClients && IsClientInGame(client));


Last edited by xerox8521; 09-30-2017 at 20:44.
xerox8521 is offline
Reply


Thread Tools
Display Modes

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 14:20.


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