GetModel of a Team

Hi !
I tell you today for a little f****** problem!
I want to Set Model of a player. The player must have the model of his team (normally he has the model of his team, but i’ve change the model previously).
I tried this (ent is player) :

ent:SetModel( team.GetModel(ent:Team()))

But, and i know that, team.GetModel doesn’t exist… But team.GetName exist…
So i search a way to manage the player has the Model of his team.
Thanks in advance! And sorry, i’m a beginner :wink:

Can’t you just do something like

if ply:Team() == SOME_TEAM then
   ply:SetModel( 'some/team/model.mdl' )
elseif ply:Team() == SOME_OTHER_TEAM then
   ply:SetModel( 'some/other/team/model.mdl' )

And just go through doing that for each team?

[editline]19th March 2016[/editline]

What gamemode are you trying to get the team’s model for?

Yeah but this is not good… If i create a new team i must go here and add… And i have more than 50 jobs so the if is… long :stuck_out_tongue:
There is no an automatic way, a class ? That’s so strange… :0

I trying with DarkRP.

This may be useful

You don’t understand the principle of the code, i think. So i explain entirely :

  • There is a ply:SetModel( “models/XXXXX.mdl” ) in a serverside file, in a function. Works perfectly.
    And i would like to, in an other function, the player has the previous model…
    So that possible :

local getmodel = ply:GetModel()
ply:SetModel( "models/XXXXXX.mdl" )


ply:SetModel( getmodel )

But that’s not possible in my case because this is in 2 files, because there is one serverside file when the player change skin, and one weapon which allows to change the skin… So use variables is not possible…
Your function is clientside, and I don’t know what is the interest…
Please help!

So… you’re trying to set the player’s model as some random model, and then set it as whatever it was before? Why? I’m confused

Probably something like a disguise kit.

--When you change the model the first time:

ply.PreviousModel = ply:GetModel( )
ply:SetModel( newmodel )

--When you want to revert it

ply:SetModel( ply.PreviousModel )

You can store variables on the player object, which would then be accessible in other files, but only in the same state - if you set it on the server, it won’t be accessible on the client, and the opposite holds true as well.

Oh thanks, totally forget I can use global variable for case like this !
Thanks :smiley:
I have an other question : Do you know how save DTextEntry in a DListView ?
For example, if player DoDoubleClick on a line and enter a text, the text is saved and show up if i re-click on the line.
Thanks in advance!

I would make a table with the team names as indexes and models as values. Then you can even add the Get and SetModel functions yourself.
[lua]local teammodels = {}

function team.SetModel(team, model)
teammodels[team] = model

function team.GetModel(team)
return teammodels[team]