Jump to content

Recommended Posts

Good afternoon! I apologize in advance for my bad english. I have trouble with my own mod, specifically with

inst.Network:GetPlayerAge()

function. I need, that when player join to server in variable saved this value and i use it as wish. 

Part of my code:

local function OnPlayerJoined(inst)
        local days_lived = inst.Network:GetPlayerAge()
    	inst.components.hunger.current = days_lived
end

local function PlayerPostInit(inst)
    GLOBAL.TheWorld:ListenForEvent("ms_playerjoined", function() OnPlayerJoined(inst) end, TheWorld)
end

AddPlayerPostInit(PlayerPostInit)

it works fine, when player join to server for the first time (with choosing character). But next time server crashed.

In logs i found this.

[00:02:12]: [string "../mods/Petooh_RPG/modmain.lua"]:29: attempt to perform arithmetic on local 'days_lived' (a nil value)

But i don't understand, why 'days_lived' is nil and wnen it initialize.

Thank you in advance. I am hope for your help

Edited by Petooh

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...