Change player model Individual based on steamID

Hey guys, I have a question,

I run a TTT server but is there a way to change the playermodel from a specific player based on steamID

eg.

Onplayerconnect()
and ply.steamid = “id” then playermodel “models/players/barney.mdl” if you guys get what I mean,

Also is there a way to play a specific sound when a player connects? Based on steamID to?

Thanks!

Find where TTT sets it’s models and do like: if ply:SteamID() == “STEAM_0:1:1337” then ply:SetModel(“models/player/barney.mdl”) return end

For the sound, I think only PlayerAuthed sends in SteamID as an argument, or you could use PlayerInitialSpawn.

well the models are all on 1 place so basicly i make a new LUA file with in it

if ply:SteamID() == “STEAM_0:1:1337” then ply:SetModel(“models/player/barney.mdl”) return end

And place it into lua/autorun/server or just lua/autorun ?

The sound, i actolly have no idea how to make that i tought with the line on ply:connect or something like that then "broadcastlua “sound” i got that code just not the beginning

Dont put it in lua/autorun… Put it instead of the base TTT models are set.

thats a file into the gamemode itself what selects the playermodels by default for everyone, but this is a different file right?

It looks like TTT uses http://wiki.garrysmod.com/?title=Gamemode.PlayerSetModel and the actual code is in init.lua [lua]function GM:PlayerSetModel(ply)
local mdl = GAMEMODE.playermodel or “models/player/phoenix.mdl”
util.PrecacheModel(mdl)
ply:SetModel(mdl)
end[/lua]
So all you need to do is edit this to your liking.

Yes but i want a specific model for only 1 guy on 1 steam id
Not for everybody, just one guy with a specific model eg. barney on steamid

I just told you how to accomplish that.

Ok but i need to place that into lua/autorun right?

Edit:

if ply:SteamID() == “STEAM_0:0:27682564” then
ply:SetModel(“models/player/barney.mdl”)
return
end

Dont work :frowning:

…Put the code into the PlayerSetModel hook in the gamemode…

hmm then i think it is

function GM:PlayerSetModel(ply)
local mdl = GAMEMODE.playermodel or “models/player/phoenix.mdl”
if ply:SteamID() == “STEAM_0:0:27682564” then
ply:SetModel(“models/player/barney.mdl”)
return
util.PrecacheModel(mdl)
ply:SetModel(mdl)
end

in player.lua

You’re missing an end.

yeah but that i have at the very bottom of the script so it should work now right?

Edit: dont work spits out a LUA error:

[gamemodes/terrortown/gamemode/player.lua:270] “end” expected (to close id at line 266 near ply)

Function now:

function GM:PlayerSetModel(ply)
local mdl = GAMEMODE.playermodel or “models/player/phoenix.mdl”
if ply:SteamID() == “STEAM_0:0:27682564” then
ply:SetModel(“models/player/barney.mdl”)
return
util.PrecacheModel(mdl)
ply:SetModel(mdl)
end
end

[lua]function GM:PlayerSetModel(ply)

local mdl = GAMEMODE.playermodel or "models/player/phoenix.mdl";
if ply:SteamID() == "STEAM_0:0:27682564" then
    mdl = "models/player/barney.mdl";
end
util.PrecacheModel(mdl)
ply:SetModel(mdl)

end
[/lua]
How I’d do it.

Thanks this works perfectly :smiley:

But to add more players i have to do:

local mdl = GAMEMODE.playermodel or “models/player/phoenix.mdl”;
if ply:SteamID() == “STEAM_0:0:27682564” then
mdl = “models/player/barney.mdl”;
end
if ply:SteamID() == “STEAM_0:0:4565321” then
mdl = “models/player/alyx.mdl”;
end
util.PrecacheModel(mdl)
ply:SetModel(mdl)
end

?

Use a table to hold the steam id’d and models then check if the players id is stored inside the table.

Im sorry but what do you mean? xD

[lua]
local models = {
[“STEAM_0:1:2345678”] = “models/player/barney.mdl”,
[“STEAM_0:1:8765432”] = “models/player/alyx.mdl”,
}

function GM:PlayerSetModel(ply)
local mdl = models[ply:SteamID()] or GAMEMODE.playermodel or “models/player/phoenix.mdl”;
util.PrecacheModel(mdl)
ply:SetModel(mdl)
end
[/lua]

Thanks will do looks a lot easier tho, But how about that a sound playes when someone connects, based on steamid too?