Jump to content

Count Followers On Save?

Recommended Posts

I'm trying to detect how many followers a player has when they save/leave the game, but so this doesn't seem possible.  Any ideas?

This is what I tried, but the results were simply zero.

local function OnSave(inst, data)
	print("Number of Forever Hound Followers on Save: " .. inst.components.leader:CountFollowers("hound"))

Seems to me like the game dismisses your followers before saving your character's information.
I'm trying to give the player an item for each follower they had when they exited the game.

Link to comment
Share on other sites

I’ll check.
The hope is to give the player a summoning item for each follower, but this might cause them to drop the items when the player tries leaving.  I’m not sure how Webber’s spiders remember him.  I haven’t had a chance to read this code about Domestication.

Update:  It seems to be working!

local function player_despawn(inst, data)
	print("Number of Forever Friend Followers on Save: " .. inst.components.leader:CountFollowers("ForeverFriend"))

	local Test = 0
		Test = Test + 1
	until( Test >= inst.components.leader:CountFollowers("ForeverFriend") )

	inst:ListenForEvent("player_despawn", player_despawn)

I just need to work this into the default player prefab and it should be good to go.

Edited by FurryEskimo
Link to comment
Share on other sites

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