Now, you see I have this gamemode where each player has a specific bot that they own, I want that once they leave, that specific bot of theirs will be destroyed, this wouldve been an easy task to do but for some reason the event “Player Left Match” doesn’t work with this strangely??, is there any other way to erase something once a player has left the match? or like a new condition that detects players leaving the match?
Let’s say that “Player Left Match” shows you that a player joined spectators (or disconnected but still stays in spectators like disactivated) so no an actual data about its position in a team remains. You can store relationship info into a global variable (array). That means once a player left just check which slot is not existing and destroy required bot but do not use Wait action so Player Joined Match won’t mix stored data.
More info about me and my game mods you can find here.
Create an array with all players, for example like this:
player joined match
actions:
- if(team of(event player), ==, team 1)
- set global variable at index(myPlayers, slot of(event player), event player)
- else()
- set global variable at index(myPlayers, add(slot of(event player), 6), event player)
- end
When you create a bot you assign its slot into array “myBots” at index “index of array value(global variable(myPlayers), event player)”.
And with this rule you will destroy the bot:
player left match
actions:
- destroy dummy bot(team of(event player), value in array(global variable(myBots), index of array value(global variable(myPlayers), event player)))
In case “team of(event player)” doesnt work, do an “if-then-else” with if “index of array value(myPlayer, event player) <= 5” then “team1” else “team2”.
Shanalotte, You cannot know what was team of event player when Player Left Match is fired already. It is in the inspector but you have no an access to this data anymore.
More info about me and my game mods you can find here.
Ok. In this case, “team of(event player)” has to be replaced this way
if(compare(index of array value(myPlayer, event player), <=, 5))
- destroy dummy bot(team1, ...)
- else()
- destroy dummy bot(team2, ...)
or this way (PTR only)
destroy dummy bot(index of array value(myPlayer, event player) <= 5 ? team1 : team2, global.myBots[index of array value(global.myPlayers[event player])])
You have no an access to player variables after firing Player Left… Here is only by Global Management. I had a lot of headache with this … when worked on 76C2G game mod (SHRINE TREASURES). The only way to deal with it is to run in background such manager (or cleaner|garbage collector whatever).
More info about me and my game mods you can find here.
Did you tried to reference Null in replace for Event Player?
Use the Entity Exists value to determine if a player has disconnected or not.
You can do this by setting a bot’s player variable to their master player, and then having a rule for bots (Is Dummy Bot(Event Player) == True) that causes them to destroy themselves if their master player has disconnected. (Entity Exists(Player Variable(Event Player, MasterPlayer)) != True).
it does not help to find bot_id when there is no actual info left.
More info about me and my game mods you can find here.
Wich is exactly what I posted ![]()
Did you read it?
(Btw. I have solved this problem in this way a year ago already so … I’m pretty sure it works)
Ok this is an even simpler way. @OP go for SpaceJesters solution.
There is no a relation between a player and a bot after a player leaves. How can you know index of array event player when it is not existing already?
Because I saved the event player in a global array.
But it has a strong relationship and a value disappears (equals null) once a player leaves… I have tried some hours to solve this annoying thing. There is no a slot info anymore.
I wont need the slot info since its is saved by the index of the player in the “myPlayers” array.
Idk, last time I used leaver management, it worked fine.
Event player in a team and Event player that left teams are not the same objects. When you see it in the inspector you find another record for a “new player”.
I know. Still, the last time I tested it (wich was a couple of month ago tbh) it worked fine, since “player left” still holds the reference of the original player, afaik.
Might be different now, idk.