FurryEskimo Posted July 29, 2021 Share Posted July 29, 2021 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")) end 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 More sharing options...
CarlZalph Posted July 29, 2021 Share Posted July 29, 2021 @FurryEskimo In player_common.lua function OnDespawn: inst:PushEvent("player_despawn") inst.components.leader:RemoveAllFollowers() So thankfully there's an event that's pushed right before all followers get nuked, in your case you can listen for it and give the items then. 1 1 Link to comment Share on other sites More sharing options...
FurryEskimo Posted July 29, 2021 Author Share Posted July 29, 2021 (edited) 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 repeat inst.components.inventory:GiveItem(SpawnPrefab("houndcollar")) Test = Test + 1 until( Test >= inst.components.leader:CountFollowers("ForeverFriend") ) end 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 July 30, 2021 by FurryEskimo Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now