Skip to content

Instantly share code, notes, and snippets.

@Donkie
Created April 3, 2018 12:37
Show Gist options
  • Save Donkie/0a8052f288c32e483db75a2150768fe6 to your computer and use it in GitHub Desktop.
Save Donkie/0a8052f288c32e483db75a2150768fe6 to your computer and use it in GitHub Desktop.
Custom player names in garrysmod
local plymeta = FindMetaTable("Player")
if not plymeta.SteamName then -- Makes sure we don't override them more than once
local getPlyName = function(self)
if #self:GetNWString("CustomName", "") > 0 then
return self:GetNWString("CustomName")
else
return self:SteamName()
end
end
plymeta.SteamName = plymeta.Nick -- Create the SteamName method so we can still get the actual name
plymeta.Nick = getPlyName
plymeta.Name = getPlyName
plymeta.GetName = getPlyName
if SERVER then
function plymeta:SetCustomName(name)
self:SetNWString("CustomName", name)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment