Ulysses

Ulysses Stuff => Ulysses Release Archives => Releases => Releases for ULib v1.* => Topic started by: fackelkind on November 15, 2006, 04:50:31 PM

Title: Keep Names
Post 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.

Code: [Select]
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
Title: Re: Keep Names
Post by: Megiddo on November 15, 2006, 05:42:47 PM
Sweet, awesome idea fackelkind!
Title: Re: Keep Names
Post by: fackelkind on November 16, 2006, 05:20:33 AM
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.
Title: Re: Keep Names
Post by: JamminR on November 16, 2006, 08:24:17 PM
Nice addition!