Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Player:SetSquadLeader event has bugs #746

Closed
FlashHit opened this issue Jan 20, 2022 · 13 comments
Closed

[Bug] Player:SetSquadLeader event has bugs #746

FlashHit opened this issue Jan 20, 2022 · 13 comments

Comments

@FlashHit
Copy link

I tried player:SetSquadLeader(leader: bool, squadPrivate: bool) and squad.leader 1 1 voteban_flash but the event doesn't get triggered by that. Seems like this never worked because I went to prod branch and there it also doesn't work. So it's not a new issue.

Also I wonder if Player:SetSquad should get called if a squad leader doesn't leave the squad but is no squad leader anymore.

@FlashHit
Copy link
Author

FlashHit commented Jan 20, 2022

Talking about the server event. The client event seems to work.

@kiwidoggie
Copy link

Cannot repro:

image

Events:Subscribe("Player:SetSquadLeader", function(p_Player)
	print("player: " .. p_Player.name .. " sid: " .. p_Player.squadId)
end)

If anything this gets fired more than once (which may be a bug)

@FlashHit
Copy link
Author

FlashHit commented Feb 9, 2022

grafik
My bad...

@FlashHit
Copy link
Author

FlashHit commented Feb 11, 2022

you have 2 players in 1 squad, you use squad.leader 1 1 playername in rcon
-> the event fires and gives the old squad leader. the isSquadLeader is still true for that player.

you use Player:SetSquadLeader(squadLeader: bool, squadPrivate: bool) and it will return the previous squad leader and the old squadLeader state.

you leave a squad as squad leader
-> the new squad leader triggers the event but player.isSquadLeader is false

you create a new squad
-> the event fires, the squadId is correct and player.isSquadLeader is true. Thats correct.

@FlashHit FlashHit changed the title [Bug] Player:SetSquadLeader event is not working [Bug] Player:SetSquadLeader event has bugs Feb 11, 2022
@FlashHit
Copy link
Author

Just run this mod and you will see all issues:
SquadSetLeaderCheck.zip

The output that I got. First I always describe what I am going to do and then I print the actual state of the players. And then it should trigger the Player:SetSquadLeader event with the correct parameters, but as you can see it's often wrong.

[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] ----------------
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] We make BotPlayer1 squad leader using Player:SetSquadLeader(true, false) command
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer1: TeamId: 1 SquadId: 1 IsSquadLeader: true
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer2: TeamId: 1 SquadId: 1 IsSquadLeader: false
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] Player:SetSquadLeader Name: BotPlayer1 TeamId: 1 SquadId: 1 IsSquadLeader: true
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] ----------------
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] We make BotPlayer1 NOT a squad leader using Player:SetSquadLeader(false, false) command
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer1: TeamId: 1 SquadId: 1 IsSquadLeader: true
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer2: TeamId: 1 SquadId: 1 IsSquadLeader: false
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] Player:SetSquadLeader Name: BotPlayer1 TeamId: 1 SquadId: 1 IsSquadLeader: true
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] ----------------
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] We make BotPlayer1 squad leader again using Player:SetSquadLeader(true, false) command. So we have a squad leader.
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer1: TeamId: 1 SquadId: 1 IsSquadLeader: false
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer2: TeamId: 1 SquadId: 1 IsSquadLeader: false
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] Player:SetSquadLeader Name: BotPlayer1 TeamId: 1 SquadId: 1 IsSquadLeader: false
[2022-02-11 17:45:57+01:00] [info] [VeniceEXT] [squadset] ----------------
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] We make BotPlayer2 squad leader using Player:SetSquadLeader(true, false) command. So we have a squad leader.
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer1: TeamId: 1 SquadId: 1 IsSquadLeader: true
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer2: TeamId: 1 SquadId: 1 IsSquadLeader: false
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] Player:SetSquadLeader Name: BotPlayer2 TeamId: 1 SquadId: 1 IsSquadLeader: false
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] ----------------
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] We make BotPlayer1 squad leader again using RCON command: 'squad.leader 1 1 BotPlayer1' command.
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer1: TeamId: 1 SquadId: 1 IsSquadLeader: false
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer2: TeamId: 1 SquadId: 1 IsSquadLeader: true
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] Player:SetSquadLeader Name: BotPlayer2 TeamId: 1 SquadId: 1 IsSquadLeader: true
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] RCON response:
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] { 1 = "OK" }
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] ----------------
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] We make BotPlayer1 leave the squad by setting his squadId to none.
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer1: TeamId: 1 SquadId: 1 IsSquadLeader: true
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer2: TeamId: 1 SquadId: 1 IsSquadLeader: false
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] ----------------
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] We make BotPlayer1 create a new squad by setting his squadId to squad2.
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer1: TeamId: 1 SquadId: 0 IsSquadLeader: false
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] Current status before change. Player: BotPlayer2: TeamId: 1 SquadId: 1 IsSquadLeader: true
[2022-02-11 17:45:58+01:00] [info] [VeniceEXT] [squadset] Player:SetSquadLeader Name: BotPlayer1 TeamId: 1 SquadId: 2 IsSquadLeader: true

@FlashHit
Copy link
Author

For changing squad leaders within a squad it would be nice if the old squad leader would trigger the event Player:SetSquad.

FYI: In Player:SetSquad we can compare p_Player.squadId with p_SquadId. the squadId in the player object is the old squadId (PLS don't change that) and the squad parameter p_SquadId is the new squadId. So it wouldn't be to bad if you trigger that event even the old squad leader didn't leave the squad.

@kiwidoggie
Copy link

This should be a new issue, has nothing to do with Player:SetSquadLeader, but the isSquadLeader call.

@FlashHit
Copy link
Author

But the Player is also wrong. and when leaving the squad (by setting it the squadId to 0) it didn't fire the event.

@kiwidoggie
Copy link

Isn't that the same behavior you asked me not to change? I'm not understanding the actual issue that's happening anymore.

@FlashHit
Copy link
Author

Isn't that the same behavior you asked me not to change?

Ye for the Player:SetSquad event because atm we have both in there old squadId and new squadId. And if this would get changed then we would lose that.

@kiwidoggie
Copy link

This has been resolved by firing the event after updating frostbite instead of before. This should re-align properly with expectations. This IS A BREAKING CHANGE please be warned. Pushed to experimental waiting for build.

RCON will be fixed in the next part.

@kiwidoggie
Copy link

Fixed in build 18070 A new issue (reference this one) will need to be created for RCON specifically as it's a different code path/checks all together. The event has been moved to post-engine update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants