General > Developers Corner

2FA Authentication for Garry's Mod

(1/3) > >>

iViscosity:
I was wondering about some hooks. In particular, PlayerSpawn, PlayerInitialSpawn, PlayerConnect, and PlayerAuthed. When, exactly are these called? PlayerSpawn says it calls even on respawns, so that one's out of the question of what I want. Basically, I want a hook that is called when the person first actually enters the game, and not again until they leave.


EDIT: Read below.

Megiddo:
You want PlayerInitialSpawn and PlayerDisconnected.

If you want to know exactly when they're called, add them all and have them print some test message.

iViscosity:
Ok, on a related note, can you help me figure out why this isn't working?

Here's a link to my repo: https://github.com/iViscosity/2FA-Gmod

You've probably seen it on the forums, but it's the 2FA-style authentication for gmod. Basically, nothing pops up when I first spawn into the server, and there is no 'pins.txt' file in my data/2fa folder (but there is a data/2fa folder). Is there something obvious I'm missing here? Also, adding a PIN works fine, but changing it gives me an error:

--- Code: ---[ERROR] addons/ulx/lua/ulx/log.lua:476: bad argument #2 to 'format' (number expected, got userdata)
  1. format - [C]:-1
   2. unknown - addons/ulx/lua/ulx/log.lua:476
    3. gsub - [C]:-1
     4. fancyLogAdmin - addons/ulx/lua/ulx/log.lua:450
      5. fancyLog - addons/ulx/lua/ulx/log.lua:514
       6. call - addons/2fa/lua/ulx/modules/sh/sh_setpin.lua:85
        7. __fn - addons/ulib/lua/ulib/shared/commands.lua:943
         8. unknown - addons/ulib/lua/ulib/shared/commands.lua:1296
          9. unknown - lua/includes/modules/concommand.lua:54

--- End code ---
related code:
https://github.com/iViscosity/2FA-Gmod/blob/master/2FA/lua/ulx/modules/sh/sh_setpin.lua#L85

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given

[0] Board index

Go to full version