Raised This Month: $209 Target: $400
 52% 

Problems Changing Player Model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PsychoAlex
Junior Member
Join Date: Oct 2009
Old 01-15-2010 , 20:12   Problems Changing Player Model
Reply With Quote #1

I am having a problem changing the model of the players class

Code:
SetEntityModel(target, "models/player/hwm/demoman.mdl");
this is an example of one of my model change code lines. The error I get is not at compile but in run-time. The Server crashes and produces the error



Any thoughts how to stop this? I don't know if it's a code or server side problem,

Thanks in advance.
PsychoAlex is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 01-15-2010 , 20:14   Re: Problems Changing Player Model
Reply With Quote #2

You need to precache the model first.
bl4nk is offline
PsychoAlex
Junior Member
Join Date: Oct 2009
Old 01-15-2010 , 20:26   Re: Problems Changing Player Model
Reply With Quote #3

Thanks for that, it's stopped the crashes.

However, for some reason my code isn't actually changing the players model.

Code:
PrintToChatAll("Start Class Check");
    if (TF2_GetPlayerClass(target) == TF2_GetClass("scout"))
    {
        SetEntityModel(target, "models/player/hwm/scout.mdl");
        PrintToChatAll("done");
    }else{
        if (TF2_GetPlayerClass(target) == TF2_GetClass("soldier"))
        {
            SetEntityModel(target, "models/player/hwm/soldier.mdl");
            PrintToChatAll("done");
        }else{
            if (TF2_GetPlayerClass(target) == TF2_GetClass("pyro"))
            {
                SetEntityModel(target, "models/player/hwm/pyro.mdl");
                PrintToChatAll("done");
            }else{
                if (TF2_GetPlayerClass(target) == TF2_GetClass("heavy"))
                {
                    SetEntityModel(target, "models/player/hwm/heavy.mdl");
                    PrintToChatAll("done");
                }else{
                    if (TF2_GetPlayerClass(target) == TF2_GetClass("engineer"))
                    {
                        SetEntityModel(target, "models/player/hwm/engineer.mdl");
                        PrintToChatAll("done");
                    }else{
                        if (TF2_GetPlayerClass(target) == TF2_GetClass("demoman"))
                        {
                            SetEntityModel(target, "models/player/hwm/pyro.mdl");
                            PrintToChatAll("done");
                        }else{
                            if (TF2_GetPlayerClass(target) == TF2_GetClass("spy"))
                            {
                                SetEntityModel(target, "models/player/hwm/spy.mdl");
                                PrintToChatAll("done");
                            }else{
                                if (TF2_GetPlayerClass(target) == TF2_GetClass("medic"))
                                {
                                    SetEntityModel(target, "models/player/hwm/medic.mdl");
                                    PrintToChatAll("done");
                                }else{
                                    if (TF2_GetPlayerClass(target) == TF2_GetClass("sniper"))
                                    {
                                        SetEntityModel(target, "models/player/hwm/sniper.mdl");
                                        PrintToChatAll("done");
                                    }else{
                                        PrintToChatAll("Class Not Found, No Model Set");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
The output I get is
Start Class Check
Done

I placed the Precashing in the OnMapStart() method

Last edited by PsychoAlex; 01-15-2010 at 20:33.
PsychoAlex is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 01-15-2010 , 21:07   Re: Problems Changing Player Model
Reply With Quote #4

Oh, you're doing this for TF2. Player models are handled client-side and therefore can not be changed by the server (ie a plugin).
bl4nk is offline
PsychoAlex
Junior Member
Join Date: Oct 2009
Old 01-16-2010 , 06:17   Re: Problems Changing Player Model
Reply With Quote #5

Really? Damn, oh well. Thanks for enlightening me to that. Kind sucks though, a load of people running around without head could be pretty funny
PsychoAlex 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 01:53.


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