Ulysses

General => Developers Corner => Topic started by: thetomm2010 on July 18, 2013, 10:53:53 PM

Title: Ulib Name enforcer. Cant seem to fix.
Post by: thetomm2010 on July 18, 2013, 10:53:53 PM
So this is for and older version of Ulib forcing people to have the same name as when they first join the server. Not to sure what the "pluginEnabled" is suppose to be now and kinda just on my last limb. So any help would be great, I'm sure other people would like this too.
Code: [Select]
i f 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)
else
        _Msg ("Plugin is not enabled\n")
end

here is the error

Quote
[ERROR] addons/ulib/lua/ulib/modules/nameforcer.lua:1: attempt to call field 'pluginEnabled' (a nil value)
  1. unknown - addons/ulib/lua/ulib/modules/nameforcer.lua:1
   2. include - [C]:-1
    3. unknown - addons/ulib/lua/ulib/cl_init.lua:23
     4. include - [C]:-1
      5. unknown - addons/ulib/lua/autorun/ulib_init.lua:5

 
Title: Re: Ulib Name enforcer. Cant seem to fix.
Post by: Decicus on July 19, 2013, 07:11:31 AM
I believe it's pretty easy to fix this.

The first line, where it's supposed to say "if", it's saying "i f", there's a space between the 'I' and the 'F' that shouldn't be there, just remove that and save, and it should in theory work (correct me if I'm wrong, Lua pro's).
Title: Re: Ulib Name enforcer. Cant seem to fix.
Post by: thetomm2010 on July 19, 2013, 12:40:56 PM
Not sure why the space is there but that is not suppose to be there. In the script that I use the i f is if. So unfortuately that is not it but thank you. I'm sure someone will know whats wrong tho hopefully lol.
Title: Re: Ulib Name enforcer. Cant seem to fix.
Post by: JamminR on July 19, 2013, 03:37:52 PM
This isn't for an older version of ULib.
This isn't for an older version of Gmod.
This is for an ancient version of both.

Just take the idea of it and re-write it.
Good Lua first learn project.
Title: Re: Ulib Name enforcer. Cant seem to fix.
Post by: thetomm2010 on July 19, 2013, 03:51:03 PM
Lmao alright thanks
Title: Re: Ulib Name enforcer. Cant seem to fix.
Post by: thetomm2010 on July 19, 2013, 03:52:05 PM
you can remove this thread if you want too. Ill make a new one with a new code.
Title: Re: Ulib Name enforcer. Cant seem to fix.
Post by: Megiddo on July 20, 2013, 12:04:46 PM
Wow, it's been a long time since I've seen GM9 code. I don't remember much at all about it, except that this was before Garry figured out that not everything was possible from the server side.
Title: Re: Ulib Name enforcer. Cant seem to fix.
Post by: Decicus on July 21, 2013, 01:30:35 AM
That makes a lot more sense.

I didn't even look up where the code was from until now... 2006. Geez.
Title: Re: Ulib Name enforcer. Cant seem to fix.
Post by: thetomm2010 on July 21, 2013, 12:23:43 PM
Haha yeahh I wasn't playing this game at the time this came out so I'm just catching up with the times lol