Raised This Month: $12 Target: $400
 3% 

Custom Skin Player Model & model color Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EnteXzzz
Junior Member
Join Date: Dec 2022
Old 12-20-2022 , 09:33   Custom Skin Player Model & model color Plugin
Reply With Quote #1

Hi,
I'm looking for advices on plugin code i made with help of people from alliedmodders discord.
This plugin is supposed to change all player models to custom skin model (full white) and color it to either red or blue depending on the team they chose.
SetEntityRenderColor works as it should but it doesnt replace skin model with the one ive choosen.

CODE:
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <sdkhooks>

public Plugin myinfo = {
    
name        "Player Models Color",
    
author      "EnteX",
    
description "Gives a player complete white skin model and give it a red/blue tint",
    
version     "2.1.3.7",
    
url         ""
};

public 
void OnPluginStart()
{
    for (
int i=1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i))
            
ColorByTeam(i);
    }
    
PrecacheModel("models/player/custom_player/Cosmic Surf/accelero_04_v3_backwards.mdl");
    
HookEvent("player_spawn"OnPlayerSpawn);
}
Action OnPlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (
client)
        
ColorByTeam(client);
}
void ColorByTeam(int client)
{
    
int team GetClientTeam(client);
    
    if (
team == CS_TEAM_T)
        
SetEntityRenderColor(client25500);
    else if (
team == CS_TEAM_CT)
        
SetEntityRenderColor(client25508);
    if (
team == CS_TEAM_T)
        
SetEntityModel(client"models/player/custom_player/Cosmic Surf/accelero_04_v3_backwards.mdl"); //T model
    
else if (team == CS_TEAM_CT)
        
SetEntityModel(client"models/player/custom_player/Cosmic Surf/accelero_04_v3_backwards.mdl"); //CT
    


Last edited by EnteXzzz; 12-20-2022 at 10:48.
EnteXzzz is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 12-20-2022 , 13:08   Re: Custom Skin Player Model & model color Plugin
Reply With Quote #2

Move PrecacheModel to OnMapStart instead of OnPluginStart is my first guess.
Drixevel is offline
EnteXzzz
Junior Member
Join Date: Dec 2022
Old 12-20-2022 , 14:04   Re: Custom Skin Player Model & model color Plugin
Reply With Quote #3

Quote:
Originally Posted by Drixevel View Post
Move PrecacheModel to OnMapStart instead of OnPluginStart is my first guess.
Got some help from discord and my code now looks like
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <sdkhooks>

public Plugin myinfo = {
    
name        "Player Models Color",
    
author      "EnteX",
    
description "Gives a player complete white skin model and give it a red/blue tint",
    
version     "2.1.3.7",
    
url         ""
};

public 
void OnPluginStart()
{
    for (
int i=1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i))
            
ColorByTeam(i);
    }
    
    
HookEvent("player_spawn"OnPlayerSpawnEventHookMode_Post);
}
Action OnPlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
    if (
client)
        
ColorByTeam(client);
}
void set_model(int clientchar model_path[128])
{
    if (!
StrEqual(model_path"models/player/custom_player/Cosmic Surf/accelero_04_v3_backwards.mdl")) {
        if(!
IsModelPrecached(model_path))
            
PrecacheModel(model_path);
        
Entity_SetModel(clientmodel_path);
}
void ColorByTeam(int client)
{
    if (!
IsClientInGame(client))
        return;

    
int team GetClientTeam(client);
    
    if (
team == CS_TEAM_T)
        
SetEntityRenderColor(client25500);
    else if (
team == CS_TEAM_CT)
        
SetEntityRenderColor(client25508); 

Last edited by EnteXzzz; 12-20-2022 at 14:04.
EnteXzzz 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 00:34.


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