Ulysses Stuff > Releases for ULib v1.*
Keep Names
(1/1)
fackelkind:
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.
--- Code: ---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
--- End code ---
Put this into lua/Ulib/modules/nameforcer.lua
Please correct my bad spelling :D
Megiddo:
Sweet, awesome idea fackelkind!
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.
JamminR:
Nice addition!
Navigation
[0] Message Index
Go to full version