Author Topic: Keep Names  (Read 7209 times)

0 Members and 1 Guest are viewing this topic.

Offline fackelkind

  • Newbie
  • *
  • Posts: 24
  • Karma: 4
Keep Names
« 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

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Keep Names
« Reply #1 on: November 15, 2006, 05:42:47 PM »
Sweet, awesome idea fackelkind!
Experiencing God's grace one day at a time.

Offline fackelkind

  • Newbie
  • *
  • Posts: 24
  • Karma: 4
Re: Keep Names
« Reply #2 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.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Keep Names
« Reply #3 on: November 16, 2006, 08:24:17 PM »
Nice addition!
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming