Jump to content

Recommended Posts

Hello there, It's my 1st time trying to create a mod and just testing creating a function that increase level on player kill , just a simple thing like

 

local function onkill(inst, data)
    local victim = data.victim
	if IsValidVictim(victim) then
        inst.level = inst.level + 1
    end
end

inst:ListenForEvent("killed", onkilll)

but I have no idea how to show this level to see if its working

If you're goal is to simply test whether the level increase works or not then using print() is your best option. If you're planning on actually creating a widget to visualize players level then there's a lot of things you'd need to do like creating a widget, putting it in PlayerHud, creating a mod RPC handler.

For simple testing I would recommend just using print(). To see what's being printed you need to check either the client_log or the server_log depending on where you run the function.

You also seem to have accidentally written `onkilll` instead of `onkill` in ListenForEvent.

Edited by -t-
  • Thanks 1

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...