1

I have some troubles with a simple code that I've made :

SWEP.PrintName          = "Gestionnaire d'alarmes Administrateur"           
SWEP.Author         = "Frass"
SWEP.Instructions       = "Clic Gauche : Ouvrir le gestionnaire"

SWEP.Spawnable = true
SWEP.AdminOnly = true

SWEP.Primary.ClipSize       = -1
SWEP.Primary.DefaultClip    = -1
SWEP.Primary.Automatic      = false
SWEP.Primary.Ammo       = "none"

SWEP.Secondary.ClipSize     = -1
SWEP.Secondary.DefaultClip  = -1
SWEP.Secondary.Automatic    = true
SWEP.Secondary.Ammo     = "none"

SWEP.Weight         = 5
SWEP.AutoSwitchTo       = false
SWEP.AutoSwitchFrom     = false

SWEP.Slot           = 1
SWEP.SlotPos            = 2
SWEP.DrawAmmo           = false
SWEP.DrawCrosshair      = true


SWEP.ViewModel          = "models/weapons/v_pistol.mdl"
SWEP.WorldModel         = "models/weapons/w_pistol.mdl"

local ShootSound = Sound( "buttons/button14.wav" )

function SWEP:PrimaryAttack()

    self:TabletMenu()

end


function TabletMenu() (reduced, there's a lot of code inside)

When I try to use my SWEP in GMOD, the console give me this error :

[ERROR] lua/weapons/alarmtabletld.lua:44: attempt to call method 'TabletMenu' (a nil value)
  1. unknown - lua/weapons/alarmtabletld.lua:44

I really don't understand what is doing this error... Some help could be really nice !

Egor Skriptunoff
  • 906
  • 1
  • 8
  • 23
Jean Pindemie
  • 11
  • 1
  • 3
  • 1
    Apparently, there is no `TabletMenu` in whatever you try to index at line `44` of the file `alarmtabletld.lua`. The code provided has less than 44 lines and it is not even clear that it is `alarmtabletld.lua`. The function `function TabletMenu() (reduced, there's a lot of code inside)` is global variable, not a field of `SWEP`, so if the provided code is all of it, then `self:TabletMenu()` is error. – Dimitry Jul 30 '18 at 16:10
  • Hello, like I say before, the function TabletMenu() have been hide in my text editor that's why there is less than 44 lines. How can I make this function as a field of my swep ? – Jean Pindemie Jul 30 '18 at 16:15
  • The same way as you did for `function SWEP:PrimaryAttack()` . – Dimitry Jul 30 '18 at 16:21
  • Thx it worked, now i have another problem but I'm going to do another post for that. – Jean Pindemie Jul 30 '18 at 16:44

1 Answers1

0

You are calling a TabletMenu function that doesnt exist as part of the SWEP table. Is it defined somewhere else perhaps?

brianolive
  • 1,573
  • 2
  • 9
  • 19