Ulysses
Ulysses Stuff => Ulysses Release Archives => Releases => Releases for ULib v1.* => Topic started by: fackelkind on November 15, 2006, 04:50:31 PM
-
Well thats nothing big, but maybe someone wants all clients too keep theire names duing a serverrun.
Lets say you just kicked someone, and he rejoines with another name. You would lookup his steamid, but now he changes his name immedetly to the old one.
if ULib.pluginEnabled() then
ULib.addon = ULib.addon or {}
local usernames = {}
ULib.addon.forcename = function (iUserid, sNewname, sOldname)
if not _PlayerInfo (iUserid, "connected") then
return false, "User is not connected"
end
local login, name = ULib.getSteamLogin (iUserid), _PlayerInfo (iUserid, "name")
if not usernames[login] then
usernames[login] = name
elseif sNewname ~= usernames[login] then
_PrintMessage (iUserid, HUD_PRINTTALK, "The server forced you to keep your name.")
AddTimer (0.1, 1, ULib.cexec, iUserid, "name " .. usernames[login])
end
return true
end
HookEvent ("eventPlayerInitialSpawn", ULib.addon.forcename)
HookEvent ("eventPlayerNameChange", ULib.addon.forcename)
else
_Msg ("Plugin is not enabled\n")
end
Put this into lua/Ulib/modules/nameforcer.lua
Please correct my bad spelling :D
-
Sweet, awesome idea fackelkind!
-
Thank you :)
If you just wont allow a client to change theire name outside the game,
comment line 22 out
-- HookEvent ("eventPlayerNameChange", ULib.addon.forcename)
Now they can change theire name ingame (where you can see it)
but if they connect with another name, the name will be switched back.
-
Nice addition!