Author Topic: 2FA Authentication for Garry's Mod  (Read 4142 times)

0 Members and 1 Guest are viewing this topic.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
2FA Authentication for Garry's Mod
« on: October 17, 2016, 05:40:33 PM »
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.
« Last Edit: October 18, 2016, 02:42:38 PM by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Hook Question
« Reply #1 on: October 17, 2016, 05:50:48 PM »
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.
Experiencing God's grace one day at a time.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Hook Question
« Reply #2 on: October 17, 2016, 07:23:51 PM »
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: [Select]
[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
related code:
https://github.com/iViscosity/2FA-Gmod/blob/master/2FA/lua/ulx/modules/sh/sh_setpin.lua#L85
« Last Edit: October 17, 2016, 07:25:50 PM by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

An Error Has Occurred!

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