Raised This Month: $ Target: $400
 0% 

SetEntityModel & Model Error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Floody
Member
Join Date: Jan 2012
Old 03-22-2014 , 12:16   SetEntityModel & Model Error
Reply With Quote #1

PHP Code:
#define PLUGIN_AUTHOR   "Floody"
#define PLUGIN_VERSION  "1.0."
#define PLUGIN_URL      "http://agtd.de"

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

public Plugin:myinfo 
{
    
name "Skins",
    
author PLUGIN_AUTHOR,
    
description "",
    
version PLUGIN_VERSION,
    
url PLUGIN_URL
}

public 
OnPluginStart()
{
    
HookEvent("player_spawn"EventPlayerSpawnEventHookMode_Pre);
}

public 
OnMapStart()
{
    
DefineDownloads();
    
PrecacheModel("models/player/against-the-dark/jail/ct-normal/chp_male_jacket.mdl"true);
}

public 
DefineDownloads()
{
    
AddFileToDownloadsTable("models/player/against-the-dark/jail/ct-normal/chp_male_jacket.dx80.vtx");
    
AddFileToDownloadsTable("models/player/against-the-dark/jail/ct-normal/chp_male_jacket.dx90.vtx");
    
AddFileToDownloadsTable("models/player/against-the-dark/jail/ct-normal/chp_male_jacket.mdl");
    
AddFileToDownloadsTable("models/player/against-the-dark/jail/ct-normal/chp_male_jacket.phy");
    
AddFileToDownloadsTable("models/player/against-the-dark/jail/ct-normal/chp_male_jacket.sw.vtx");
    
AddFileToDownloadsTable("models/player/against-the-dark/jail/ct-normal/chp_male_jacket.vvd");
    
AddFileToDownloadsTable("models/player/against-the-dark/jail/ct-normal/chp_male_jacket.xbox.vtx");

    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_coat.vmt");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_coat.vtf");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_coat_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_male_face.vmt");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_male_face.vtf");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_male_face_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_hands_m.vmt");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_hands_m.vtf");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_hands_m_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_holster.vmt");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_holster.vtf");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_pants.vmt");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_pants.vtf");
    
AddFileToDownloadsTable("materials/models/player/against-the-dark/jail/ct-normal/chp_pants_n.vtf");
}

public 
Action:EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(
IsPlayerAlive(client) && IsClientInGame(client))
    {
        if(
GetClientTeam(client) == CS_TEAM_CT)
            
SetEntityModel(client"models/player/against-the-dark/jail/ct-normal/chp_male_jacket.mdl");
    }

This is my code where I want to set a skin to a ct when he spawns. I am downloading the models, but ingame the ct is just a big red ERROR. The game is Counter-Strike Source.

Yes I updated every path in the .vmt files and decompiled the .mdl to change the path there aswell.

I'd appreciate any help!

Last edited by Floody; 03-22-2014 at 12:48. Reason: added game
Floody is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-22-2014 , 12:23   Re: SetEntityModel & Model Error
Reply With Quote #2

ok... what happen when you load that model using hlmv.exe ??
Can you see it's normal ?

*edit
in your own game
...Steam\SteamApps\common\that game you not mention\bin\hlmv.exe

Last edited by Bacardi; 03-22-2014 at 12:24.
Bacardi is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 03-22-2014 , 12:26   Re: SetEntityModel & Model Error
Reply With Quote #3

"PrecacheModel" already has its default path set to the "models"-folder.
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.

Last edited by Dr. Greg House; 03-22-2014 at 12:26.
Dr. Greg House is offline
Floody
Member
Join Date: Jan 2012
Old 03-22-2014 , 12:46   Re: SetEntityModel & Model Error
Reply With Quote #4

Quote:
Originally Posted by Bacardi View Post
ok... what happen when you load that model using hlmv.exe ??
Can you see it's normal ?

*edit
in your own game
...Steam\SteamApps\common\that game you not mention\bin\hlmv.exe
Oh lol sorry, it's Counter-Strike: Source.

And yes, I can see the model.
Quote:
Originally Posted by Dr. Greg House View Post
"PrecacheModel" already has its default path set to the "models"-folder.
Removing "models/" would crash my server.
Floody is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-22-2014 , 12:51   Re: SetEntityModel & Model Error
Reply With Quote #5

...try precache without preload = true
*edit
and changelevel everytime when you reload plugin

*wait... which SV_PURE you have on server ?

Last edited by Bacardi; 03-22-2014 at 12:52.
Bacardi is offline
Floody
Member
Join Date: Jan 2012
Old 03-22-2014 , 12:59   Re: SetEntityModel & Model Error
Reply With Quote #6

Quote:
Originally Posted by Bacardi View Post
...try precache without preload = true
*edit
and changelevel everytime when you reload plugin

*wait... which SV_PURE you have on server ?
Tried that, no changes. sv_pure 0

Edit:I figured out why. The server doesn't work correctly after an restart. When you change the map everything works fine. For example: If someone joins on the server immediately after an restart he's downloading the models but incorrect, so he won't see the models. If another players joins the server after the map changed once he's downloading the moldes correct, so he can see the models he just downloaded. Same goes for sprays and custom models for players; immediately after an restart players can't see their sprays and their custom models (e.g. skins for weapons). When the map changed once they can see them again. I hope you understand what I mean and maybe do you have any idea why this could be?

Last edited by Floody; 03-22-2014 at 13:19.
Floody is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-22-2014 , 15:54   Re: SetEntityModel & Model Error
Reply With Quote #7

Quote:
Originally Posted by Floody View Post
Tried that, no changes. sv_pure 0

Edit:I figured out why. The server doesn't work correctly after an restart. When you change the map everything works fine. For example: If someone joins on the server immediately after an restart he's downloading the models but incorrect, so he won't see the models. If another players joins the server after the map changed once he's downloading the moldes correct, so he can see the models he just downloaded. Same goes for sprays and custom models for players; immediately after an restart players can't see their sprays and their custom models (e.g. skins for weapons). When the map changed once they can see them again. I hope you understand what I mean and maybe do you have any idea why this could be?
That sounds like a sv_pure bug, if you have sv_pure value added in server.cfg.
*edit
Not bug, feature. It require map change after changing this mode.
Code:
Current sv_pure value is 1.
--------------------------------------------------------
sv_pure 0
--------------------------------------------------------
sv_pure set to 0.
Note: Changes to sv_pure take effect when the next map is loaded.
--------------------------------------------------------

if you could, remove all sv_pure cvars from configs and restart server again.
Typing into server console (or rcon) sv_pure, you get current sv_pure status. It should be 0 by default.
(Or join to server and type in your own game console)

if you however have, after these steps server in any other sv_pure mode than 0.
in ...cfg/autoexec.cfg add cvar sv_pure 0
restart server.


Info: Server launch parameter -sv_pure so called "unlock" cvar for to make change mode.
It will be run sv_pure 1 by default unless change it from autoexec.cfg, this config file will execute before map start and once when server start.

Last edited by Bacardi; 03-22-2014 at 15:57.
Bacardi is offline
Floody
Member
Join Date: Jan 2012
Old 03-22-2014 , 17:17   Re: SetEntityModel & Model Error
Reply With Quote #8

Thank you so much that solved my problem!

If I want to set a skin to a random one do I have to use an array? Like this?
PHP Code:
new const String:skinNames[2][ 60 ] =
{
    
"models/player/blackbirds/jailpublic/t_leet.mdl",    "models/player/against-the-dark/jail/ct-normal/chp_male_jacket.mdl"
};
new 
randomNum GetRandomInt(01);
SetEntityModel(clientskinNames[randonNum]); 

Last edited by Floody; 03-23-2014 at 06:41. Reason: fixed code
Floody 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 03:16.


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