Help calling hooks correctly

I need to use hook.Call. It passes 3 arguments: the hook name, the gamemode table, and varargs. Varargs stands for Variable Arguments, yes? As in, the amount of arguments isn’t predetermined by gmod, you determine them.

What’s the correct syntax for passing varargs? Just adding additional arguments as needed with commas, or do varargs need to be in a table?

For example, this is a hook.Call in a piece of my code causing problems. Is the syntax correct, assuming round, roundvictor, and leadingteam are all valid vars to begin with?



hook.Call( "RoundEnd", self, round, roundvictor, leadingteam )


The wiki suggests

hook.Run, because then you don’t need to worry about the gamemode table.
The syntax looks correct, but I’m not sure you need to use self, or if self is valid.

I’m calling hook.Add in a function already within the gamemode table.

I have ULX installed on my server, and my server console looks like this shortly before it crashes (btw, this is causing server crashing)



Nobody's won the game yet.
GM:RoundEnd called
Nobody's won the game yet.
GM:RoundEnd called
Nobody's won the game yet.
GM:RoundEnd called
Nobody's won the game yet.
GM:RoundEnd called
Nobody's won the game yet.

[ERROR] addons/ulib/lua/ulib/shared/hook.lua:98: stack overflow
  1. Call - addons/ulib/lua/ulib/shared/hook.lua:98
   2. Call - gamemodes/project-onelife/gamemode/sv_roundhandler.lua:267
    3. Call - gamemodes/project-onelife/gamemode/sv_roundhandler.lua:267
     4. Call - gamemodes/project-onelife/gamemode/sv_roundhandler.lua:267
      5. Call - gamemodes/project-onelife/gamemode/sv_roundhandler.lua:267
       6. Call - gamemodes/project-onelife/gamemode/sv_roundhandler.lua:267
        7. Call - gamemodes/project-onelife/gamemode/sv_roundhandler.lua:267
         8. Call - gamemodes/project-onelife/gamemode/sv_roundhandler.lua:267
          9. Call - gamemodes/project-onelife/gamemode/sv_roundhandler.lua:267
           10. Call - gamemodes/project-onelife/gamemode/sv_roundhandler.lua:267
            11. Call - gamemodes/project-onelife/gamemode/sv_roundhandler.lua:267
             12. Call - gamemodes/project-onelife/gamemode/sv_roundhandler.lua:267
              13. Call - gamemodes/project-onelife/gamem


“print(“GM:RoundEnd called”)” is the first line of the function, and “print( “Nobody’s won the game yet.” )” is the first line of the if statement the hook.Call is placed in. While you can’t see it,



GM:RoundEnd called
Nobody's won the game yet.


Is being spammed from the top of the console until the end where ULX errors a stack overflow.

[editline]13th November 2017[/editline]

I found the problem. The V wasn’t capitalized in roundvictor.

RIP.