I was wondering how I would be able to make to so that when a player is an admin on my server, they use a custom “admin” player model?
[lua]
function AdminModel( ply )
if ply:IsAdmin() then
ply:SetModel( “model path” )
end
end
hook.Add( “PlayerSpawn”, “AdminModel”, AdminModel )
[/lua]
Put this in your lua / autorun map.
*Untested
Xyro
I dont understand what you mean when you say that. o.o
EDIT: I didnt see the lua. Sorry
EDIT: Yet I still dont understand it. I dont have a “map” in the lua/autorun. I only have ulib_init.
You do have a garrysmod server ? cause you should have a garrymod folder with stuff like lua, data and that sort of stuff, send me a screen of you server map
He means, put in garrysmod>lua>(you may need to crete this folder)autorun>(may need to create this folder to)server. Put it there and it should work.
he calls it a map instead a of a folder, lol
There’s a way you can do it with steam ID’s if this helps:
[lua]
function GM:SetupPlayerModel( pl )
if pl:SteamID() == "SteamID" then
pl:GetTable().PlayerModel = "model"
pl:SetModel( pl:GetTable().PlayerModel )
return
elseif pl:SteamID() == "SteamID" then
pl:GetTable().PlayerModel = "model"
pl:SetModel( pl:GetTable().PlayerModel )
return
elseif pl:SteamID() == "SteamID" then
pl:GetTable().PlayerModel = "model"
pl:SetModel( pl:GetTable().PlayerModel )
return
elseif pl:SteamID() == "SteamID" then
pl:GetTable().PlayerModel = "model"
pl:SetModel( pl:GetTable().PlayerModel )
return
elseif pl:SteamID() == "SteamID" then
pl:GetTable().PlayerModel = "model"
pl:SetModel( pl:GetTable().PlayerModel )
return
elseif pl:SteamID() == "SteamID" then
pl:GetTable().PlayerModel = "model"
pl:SetModel( pl:GetTable().PlayerModel )
return
elseif pl:SteamID() == "SteamID" then
pl:GetTable().PlayerModel = "model"
pl:SetModel( pl:GetTable().PlayerModel )
return
end
end
[/lua]
You don’t need the returns, as it will ignore the rest of the if-then. Also, it’s “GM:PlayerSetModel”. A shorter version would be:
[lua]local model = {}
local function addModel(steamID, model)
model[steamID] = model
end
addModel(“steamID”, “model”)
function GM:PlayerSetModel(ply)
util.PrecacheModel(model[ply:SteamID()]) --Not sure if this is needed anymore.
ply:SetModel(model[ply:SteamID()])
end[/lua]
It’s old computer slang and it’s valid.
Why do people overwride the gamemode functions? and Unrealomega, you might want to add a check for if the steamID is not in the table :
[lua]local model = {}
function addModel(steamID, model)
model[steamID] = model
end
hook.Add(“PlayerSetModel”,“SteamIDBasedModels”,function(ply)
if model[ply:SteamID()] then
ply:SetModel(model[ply:SteamID()])
end
end)[/lua]
Missing a ‘)’ after the last end.
Ah, forgot about that, its fixed now.
Ugh… why not use a table for the SteamIDs?