Get Player Object or Player Entity?

Ok, even after reading through the wiki and PIL, I still feel like I don’t really know what I’m doing.

I’m trying to make an RPG using Networked Ints. (**[Entity.SetNetworkedInt

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.SetNetworkedInt)**, **[Entity.GetNetworkedInt

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.GetNetworkedInt)**)

I need to make a function in shared.lua(or included, which is my case) that receives the player’s entity/player object so that I can use **[Entity.GetNetworkedInt

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.GetNetworkedInt)**.

I currently have:

[lua]
local metaplayer = FindMetaTable(“Player”) //Get the meta table of player

function metaplayer:SetXP(amount)
metaplayer:SetNetworkedInt( “xp”, amount )
//self:SaveXP()
end

function metaplayer:GetXP()
return metaplayer:GetNetworkedInt( “xp” )
end
[/lua]

I would be grateful for any help that would point me in the right direction.

This doesn’t answer your question, but you have a few typos in your code


local metaplayer = FindMetaTable("Player") //Get the meta table of player
 
function metaplayer:SetXP(amount)
    self:SetNetworkedInt( "xp", amount )
    //self:SaveXP()
end
 
function metaplayer:GetXP()
    return self:GetNetworkedInt( "xp" )
end

When in those meta functions (e.g. metaplayer:GetXP), self refers to the player, not metaplayer.

problem with using self: Self does not work in shared.lua

[lua]
function metaplayer:GetLevel()
return self:GetNetworkedInt( “level” ) // line 99
end
[/lua]

[gamemodes\gmodrpg\gamemode\sh_npc.lua:99] attempt to index local ‘self’ (a nil value)

That is why you use “if CLIENT then” or “if SERVER then” conditions, or you put each function in a separate file.

so what would i use instead of self for client?

You always use self if you are trying to reference the object/table. The problem is that the function you are trying to call is not available on the client (SetNetworkedInt): this is why you use 2 different functions on the client / server.

what is the function for clients then? SetNWInt?

Think about what you want the client to do, and what the server should do. It might clear things up.

SetNWInt and SetNetworkedInt are the same thing. Clients have access these for prediction only. It will not change on the server and the server’s value will always be valued more then the clients.

Well, I just want the server to keep track of the Networked ints, and I’m not sure why the client is trying to call the function, because I never intended them to.

hmm, still getting the same result ([gamemodes\gmodrpg\gamemode\sh_npc.lua:125] attempt to index local ‘self’ (a nil value)), could this be the cause?

[lua]
function AveragePlayerLvl()
if SERVER then
local lvl = 0
local count = 0
local total
for k, v in pairs(player.GetAll()) do
lvl = lvl + v.GetLevel() // this line
count = count + 1
end

	total = lvl/count
	return total
end

end

function PlayerCount()
if SERVER then
local count
for k, v in pairs(player.GetAll()) do
count = count + 1
end
return count
end
end
[/lua]

You posted irrelevant code. If you don’t want the client to use those functions, why did you try to put them in a shared file. Define Entity:SetXP on the server only. You do not want / need the client to have that. As for the GetXP function, make it return the contents of the NetworkedInt, and then network it to the client.

Also, your second function is unnecessary:

[lua]
local pCount = #player.GetAll()
[/lua]

Thanks for that little tidbit of code, saved me from making useless code :slight_smile:

anyway, I guess I can elaborate a little more.

Here’s my real problem:

ERROR: Hook ‘NPC_Initialize’ Failed: [gamemodes\gmodrpg\gamemode\sh_npc.lua:20] attempt to perform arithmetic on a nil value
Removing Hook ‘NPC_Initialize’

[lua]
function NPC_Init()
if SERVER then
local pCount = #player.GetAll()
for _, v in pairs( ents.GetAll() ) do
if v:IsNPC() then
local health = v:Health()
v:SetNetworkedInt(“npcxp”, ((healthAveragePlayerLvl()) + math.pow(10, (AveragePlayerLvl()/10)))) // this line
v:SetHealth((health
AveragePlayerLvl()*pCount))
end
end
end
end
hook.Add( “InitPostEntity”, “NPC_Initialize”, NPC_Init)
[/lua]

The reason I posted the functions before this post, was because it calls those functions where its saying it is getting a nil value.

I made a console cmd version of that function so that I could test to see if it just wasn’t setting the NWInt on NPCs that haven’t spawned yet.

It gives me the error [gamemodes\gmodrpg\gamemode\sh_npc.lua:99] attempt to index local ‘self’ (a nil value)

which is the line I showed you before.

[lua]
function NPC_ReInit()
if SERVER then
local pCount = #player.GetAll()
for _, v in pairs( ents.GetAll() ) do
if v:IsNPC() then
if v:GetNetworkedInt(“npcxp”) == 0 then
local health = v:Health()
v:SetNetworkedInt(“npcxp”, ((healthAveragePlayerLvl()) + math.pow(10, (AveragePlayerLvl()/10))))
v:SetHealth((health
AveragePlayerLvl()*pCount))
end
end
end
end
end

concommand.Add(“gmodrpg_reinit_npc”, NPC_ReInit)
[/lua]

I’m trying to figure out what function is returning a nil value in that line.

[lua]v:SetNetworkedInt(“npcxp”, ((health*AveragePlayerLvl()) + math.pow(10, (AveragePlayerLvl()/10)))) // this line[/lua]

AveragePlayerLvl() probably is. v.GetLevel() should be v:GetLevel(). Post that function please.

here.

[lua]
function metaplayer:GetLevel()
if SERVER then
return self:GetNetworkedInt( “level” )
end
end
[/lua]

Current Problem:

No lua errors, but the NPC won’t die, and I can’t get hit by the npc. hmmn Finally killed it with a combine ball.

console log:



ot toybox authentication
] sv_defaultgamemode gmodrpg
maxplayers set to 1
Unknown command "sv_unlag_fixstuck"
Lua initialized (Lua 5.1)
======== Installing Table (De)Serialiser Module | ver: 1.4 ========
ERROR! Module 'rawio' not found!
[addons
pc_control2\lua\autorun\init.lua:2] attempt to call global 'AddCSLua' (a nil value)
======== RD BeamLib v0.23 Installed ========
==========================================================
Simple Prop Protection Version 1.5 by Spacetech has loaded
==========================================================
=======================================================
StarGate Pack: Initializing
Version: 44

Loading: stargate/shared/init.lua
Loading: stargate/shared/bullets.lua
Loading: stargate/shared/lib.lua
Loading: stargate/shared/matrix.lua
Loading: stargate/shared/print_r.lua
Loading: stargate/shared/tracelines.lua
Loading: stargate/server/init.lua
INIParser:parse - File stargate/config.ini successfully parsed
INIParser:new - File stargate/user_config.ini does not exist!
Loading: stargate/server/entity.lua
Loading: stargate/server/ini_parser.lua
Loading: stargate/server/protection.lua
Loading: stargate/server/spawner.lua
Loading: stargate/server/teleport.lua
Loading: stargate/server/tool.lua
Loading: stargate/server/wire_rd.lua
=======================================================
///////////////////////////////
//      Ulysses Library      //
///////////////////////////////
// Loading...                //
//  shared/defines.lua       //
//  server/hook.lua          //
//  server/gamemode_hooks.lua//
//  shared/misc.lua          //
//  shared/util.lua          //
//  shared/table.lua         //
//  shared/player.lua        //
//  server/player.lua        //
//  shared/messages.lua      //
//  shared/concommand.lua    //
//  server/concommand.lua    //
//  server/util.lua          //
//  shared/sh_ucl.lua        //
//  server/ucl.lua           //
//  server/phys.lua          //
//  server/player_ext.lua    //
//  server/entity_ext.lua    //
// Load Complete!            //
///////////////////////////////
[ULIB] Loading SHARED module: ulx_init.lua
///////////////////////////////
//       ULX Admin Mod       //
///////////////////////////////
// Loading...                //
//  sh_defines.lua           //
//  lib.lua                  //
//  base.lua                 //
//  log.lua                  //
//  MODULE: chat.lua         //
//  MODULE: fun.lua          //
//  MODULE: menus.lua        //
//  MODULE: rcon.lua         //
//  MODULE: slots.lua        //
//  MODULE: teleport.lua     //
//  MODULE: toolmode.lua     //
//  MODULE: user.lua         //
//  MODULE: util.lua         //
//  MODULE: vote.lua         //
//  MODULE: votemap.lua      //
//  MODULE: userhelp.lua     //
//  end.lua                  //
// Load Complete!            //
///////////////////////////////
================================
===  Wire  1998   Installed  ===
================================
======== Beam NetVars Lib v0.71 Installed ========
ERROR! Module 'zlib_b64' not found!
==== Advanced Duplicator v.1.72 shared module installed! ====
==== Advanced Duplicator v.1.85 server module installed! ====
Registering gamemode 'fretta' derived from 'base'
Registering gamemode 'fretta' derived from 'base'
Registering gamemode 'gmodrpg' derived from 'fretta'
ScriptEnforce is disabled
Couldn't include file 'nuke_vars_init.lua' (File not found)
Couldn't include file 'nuke_vars_init.lua' (File not found)
[RunString:9825] attempt to call field 'registerDebuggerFormat' (a nil value)
[RunString:12595] attempt to call field 'registerDebuggerFormat' (a nil value)
[RunString:13156] attempt to call field 'registerDebuggerFormat' (a nil value)
Executing listen server config file
Couldn't find scene 'scenes/npc/female01/question21.vcd'
Couldn't find scene 'scenes/npc/female01/question31.vcd'
Couldn't find scene 'scenes/npc/female01/answer35.vcd'
Couldn't find scene 'scenes/npc/female01/gordead_ques03a.vcd'
Couldn't find scene 'scenes/npc/female01/gordead_ques03b.vcd'
Couldn't find scene 'scenes/npc/female01/nice.vcd'
Couldn't find scene 'scenes/npc/male01/nice01.vcd'
Couldn't find scene 'scenes/npc/male01/nice02.vcd'
Couldn't find scene 'scenes/npc/female01/oneforme.vcd'
Couldn't find scene 'scenes/npc/Barney/ba_run.vcd'
Couldn't find scene 'scenes/npc/Barney/ba_ohshit.vcd'
Couldn't find scene 'scenes/npc/Barney/ba_thisisbad.vcd'
Couldn't find scene 'scenes/npc/Barney/ba_headcrabs.vcd'
Attempted to create unknown entity type gmod_tool!
Can't init gmod_tool
Attempted to create unknown entity type gmod_tool!
Can't init gmod_tool
Attempted to create unknown entity type gmod_tool!
Can't init gmod_tool
Attempted to create unknown entity type gmod_tool!
Can't init gmod_tool
Attempted to create unknown entity type gmod_tool!
Can't init gmod_tool
Attempted to create unknown entity type gmod_tool!
Can't init gmod_tool
Attempted to create unknown entity type gmod_tool!
Can't init gmod_tool
Attempted to create unknown entity type gmod_tool!
Can't init gmod_tool
Attempted to create unknown entity type gmod_tool!
Can't init gmod_tool
Attempted to create unknown entity type gmod_tool!
Can't init gmod_tool
Couldn't find any entities named ar2_temp, which point_template template4 is specifying.
trigger_changelevel to gm_adventure2_beta3 doesn't have a landmarkCan't find landmark 
ERROR: Hook 'gmod_wire_hologram_shared' Failed: [addons\wire\lua\entities\gmod_wire_hologram\shared.lua:14] attempt to index field 'base_gmodentity' (a nil value)
Removing Hook 'gmod_wire_hologram_shared'
exec: couldn't exec listenserver.cfg
Attemped to precache unknown particle system "blood_impact_blue_01"!
ERROR: Hook 'LSTakeDamage' Failed: [addons\life support\lua\autorun\server\sv_lifesupport.lua:396] attempt to compare number with nil
Removing Hook 'LSTakeDamage'
InitFastCopy: only 51% fast props. Bug?
Lua initialized (Lua 5.1)
======== Installing Table (De)Serialiser Module | ver: 1.4 ========
ERROR! Module 'rawio' not found!
-NPC Control-
Main Content Loaded
Episode 2 Content Loaded!
--------------------
======== RD BeamLib v0.23 Installed ========
==========================================================
Simple Prop Protection Version 1.5 by Spacetech has loaded
==========================================================
Attemped to precache unknown particle system "blood_impact_blue_01"!
Attemped to precache unknown particle system "blood_impact_blue_01"!
=======================================================
StarGate Pack: Initializing
Version: 44

Loading: stargate/shared/init.lua
Loading: stargate/shared/bullets.lua
Loading: stargate/shared/lib.lua
Loading: stargate/shared/matrix.lua
Loading: stargate/shared/print_r.lua
Loading: stargate/shared/tracelines.lua
Loading: stargate/client/init.lua
Loading: stargate/client/menu.lua
Loading: stargate/client/modelclipping.lua
Loading: stargate/vgui/SAddressPanel.lua
Loading: stargate/vgui/SAddressSelect.lua
Loading: stargate/vgui/SControlePanel.lua
Loading: stargate/vgui/SHelpButton.lua
Loading: stargate/vgui/SHTMLHelp.lua
=======================================================
RunConsoleCommand blocked - sent before player spawned (ulib_cl_loaded)
======== Beam NetVars Lib v0.71 Installed ========
loading materials
loading material: cable/rope_icon
loading material: cable/cable2
loading material: cable/xbeam
loading material: cable/redlaser
loading material: cable/blue_elec
loading material: cable/physbeam
loading material: cable/hydra
loading material: arrowire/arrowire
loading material: arrowire/arrowire2
=== Loading Wire Model Packs ===
	Loaded: Stargate.txt
	Loaded: default.txt
	Loaded: expression2.txt
	Loaded: cheeze_buttons2.txt
	Loaded: wire_model_pack_1.txt
	Loaded: wire_model_pack_1plus.txt
	Adding Cheeze's Buttons Pack
	Adding various Buttons from HL2 and Portal
	Jaanus' Thruster Pack
	Beer's Model pack
--- Missing Vgui material ignore_this_error
ERROR! Module 'zlib_b64' not found!
==== Advanced Duplicator v.1.72 shared module installed! ====
==== Advanced Duplicator v.1.741 client module installed! ====
Registering gamemode 'fretta' derived from 'base'
Registering gamemode 'fretta' derived from 'base'
Registering gamemode 'gmodrpg' derived from 'fretta'
You have tried to create a render target via Lua. This is now disabled, it's way too slow. Check out garrysmod\settings\render_targets
You have tried to create a render target via Lua. This is now disabled, it's way too slow. Check out garrysmod\settings\render_targets
KeyValues Error: LoadFromBuffer: missing { in file materials/sprites/blborder.vmt
(*UnlitGeneric*), (*proxies*), (*AnimatedTexture*), 
KeyValues Error: LoadFromBuffer: missing { in file materials/sprites/blborder.vmt
(*UnlitGeneric*), (*proxies*), (*AnimatedTexture*), 
KeyValues Error: LoadFromBuffer: missing { in file materials/sprites/noblue.vmt
(*Unlittwotexture*), (*proxies*), (*AnimatedTexture*), 
KeyValues Error: LoadFromBuffer: missing { in file materials/sprites/noblue.vmt
(*Unlittwotexture*), (*proxies*), (*AnimatedTexture*), 
KeyValues Error: LoadFromBuffer: missing { in file materials/sprites/nored.vmt
(*Unlittwotexture*), (*proxies*), (*AnimatedTexture*), 
KeyValues Error: LoadFromBuffer: missing { in file materials/sprites/nored.vmt
(*Unlittwotexture*), (*proxies*), (*AnimatedTexture*), 
You have tried to create a render target via Lua. This is now disabled, it's way too slow. Check out garrysmod\settings\render_targets
You have tried to create a render target via Lua. This is now disabled, it's way too slow. Check out garrysmod\settings\render_targets
Can't find factory for entity: info_null
Sending 27 'User Info' ConVars to server (cl_spewuserinfoconvars to see)
ConCommand blocked! (SPropProtection_toggle 1
)
Adding Player
RunConsoleCommand blocked - sent before player spawned (ZLib_Installed)
[UCL] Access set.
This server is running ULib version 2.21.
[ULIB] Loading SHARED module: ulx_init.lua
AdvDupeShared: Server Compression: false
================================
===  Wire revision: 1998     ===
=== Local Wire revision:1998 ===
================================
Warning: Unhandled usermessage 'StarGate_IsOnServer'
Hook 'gmod_wire_hologram_shared' Failed: [addons\wire\lua\entities\gmod_wire_hologram\shared.lua:14] attempt to index field 'base_gmodentity' (a nil value)
ERROR: Hook 'sendMapAutoComplete' Failed: [@addons\ulx\lua\ulx\modules\util.lua:69] bad argument #1 to 'ipairs' (table expected, got nil)
Removing Hook 'sendMapAutoComplete'
ULX version 3.31 loaded.
Redownloading all lightmaps
INIParser:new - File stargate/gatespawner_maps/gm_adventure_beta10.ini does not exist!
INIParser:parse - File stargate/config.ini successfully parsed
Timer Error: [addons\stargate\lua\autorun\server\gate_spawner.lua:16] attempt to index field 'config' (a nil value)
InstantDeath joined Red Team
=================================================
Simple Prop Protection: 417 props belong to world
=================================================
] impulse 101
You recieved 0 experience from killing npc_zombie
You recieved 0 experience from killing npc_zombie


it must have set the zombie’s health to 0 ?

gonna add a console msg that prints in the NPC_Initalize function that tells what the intial health of that npc is.

Edit:

and the result:




gmodrpg_reinit_npc 
[GMOD: RPG] npc_zombie has -2147483648 health
[GMOD: RPG] Set the Health of npc_zombie to -2147483648 health
[GMOD: RPG] npc_zombie has -2147483648 health
[GMOD: RPG] Set the Health of npc_zombie to -2147483648 health
[GMOD: RPG] npc_zombie has -2147483648 health
[GMOD: RPG] Set the Health of npc_zombie to -2147483648 health
[GMOD: RPG] npc_zombie has 2147483520 health
[GMOD: RPG] Set the Health of npc_zombie to 2147483520 health
[GMOD: RPG] npc_zombie has -2147483648 health
[GMOD: RPG] Set the Health of npc_zombie to -2147483648 health
[GMOD: RPG] npc_turret_floor has -2147483648 health
[GMOD: RPG] Set the Health of npc_turret_floor to -2147483648 health
[GMOD: RPG] npc_turret_floor has -2147483648 health
[GMOD: RPG] Set the Health of npc_turret_floor to -2147483648 health
[GMOD: RPG] npc_turret_floor has -2147483648 health
[GMOD: RPG] Set the Health of npc_turret_floor to -2147483648 health
[GMOD: RPG] npc_turret_floor has -2147483648 health
[GMOD: RPG] Set the Health of npc_turret_floor to -2147483648 health
[GMOD: RPG] npc_turret_floor has -2147483648 health
[GMOD: RPG] Set the Health of npc_turret_floor to -2147483648 health
[GMOD: RPG] npc_turret_floor has -2147483648 health
[GMOD: RPG] Set the Health of npc_turret_floor to -2147483648 health
[GMOD: RPG] npc_turret_floor has -2147483648 health
[GMOD: RPG] Set the Health of npc_turret_floor to -2147483648 health
[GMOD: RPG] npc_zombie has 50 health
[GMOD: RPG] Set the Health of npc_zombie to 50 health
[GMOD: RPG] npc_zombie_torso has 50 health
[GMOD: RPG] Set the Health of npc_zombie_torso to 50 health
[GMOD: RPG] npc_zombie_torso has 50 health
[GMOD: RPG] Set the Health of npc_zombie_torso to 50 health
[GMOD: RPG] npc_zombie has 50 health
[GMOD: RPG] Set the Health of npc_zombie to 50 health
[GMOD: RPG] npc_zombie has 50 health
[GMOD: RPG] Set the Health of npc_zombie to 50 health
[GMOD: RPG] npc_zombie has 50 health
[GMOD: RPG] Set the Health of npc_zombie to 50 health
[GMOD: RPG] npc_zombie has 50 health
[GMOD: RPG] Set the Health of npc_zombie to 50 health
[GMOD: RPG] npc_zombie_torso has 50 health
[GMOD: RPG] Set the Health of npc_zombie_torso to 50 health
[GMOD: RPG] npc_zombie_torso has 50 health
[GMOD: RPG] Set the Health of npc_zombie_torso to 50 health
[GMOD: RPG] npc_zombie_torso has 50 health
[GMOD: RPG] Set the Health of npc_zombie_torso to 50 health
[GMOD: RPG] npc_zombie has 50 health
[GMOD: RPG] Set the Health of npc_zombie to 50 health
[GMOD: RPG] npc_zombie has 50 health
[GMOD: RPG] Set the Health of npc_zombie to 50 health

] stats_get
Your Level is: 1
Your Experience is: 0
] impulse 101
You recieved 2147483520 experience from killing npc_zombie
You recieved -2147483648 experience from killing npc_zombie
You recieved -2147483648 experience from killing npc_zombie
You recieved -2147483648 experience from killing npc_zombie
You recieved -2147483648 experience from killing npc_zombie
] mystats
Unknown command: mystats
] stats_get
Your Level is: 1
Your Experience is: -6442450944
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 51.258926391602 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 51.258926391602 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_headcrab
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 51.258926391602 experience from killing npc_zombie_torso
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie_torso
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie_torso
You recieved 0 experience from killing npc_zombie_torso
You recieved 0 experience from killing npc_zombie
You recieved 51.258926391602 experience from killing npc_zombie
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie_torso
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie_torso
You recieved 0 experience from killing npc_zombie_torso
You recieved 0 experience from killing npc_zombie_torso
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 51.258926391602 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie_torso
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie_torso
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
You recieved 0 experience from killing npc_zombie
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 51.258926391602 experience from killing npc_zombie_torso
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie_torso
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie_torso
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie
You recieved 0 experience from killing npc_zombie
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 51.258926391602 experience from killing npc_zombie_torso
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 0 experience from killing npc_zombie_torso
[LuaCmd:1] attempt to call method 'AddNotify' (a nil value)
You now own this prop
You recieved 51.258926391602 experience from killing npc_zombie_torso
] stats_get
Your Level is: 1
Your Experience is: -6442450944




now I’m really confused. why are some negative values and some 50? Just FYI, this map uses npc_templates that spawn npcs after a trigger(its to reduce lag as its a very long and big coop map I made).

ok, I noticed that npcs that spawn AFTER NPC_Init is called never give any XP. is there a way I can hook when an NPC spawns or entity is created? Because I would prefer not to execute this line of code on every frame…