Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

Wrong initial IPlayer.CurrentCommandIndex value

Did you encounter a problem, exploit, glitch or bug while playing the game or running the dedicated server software? Tell us about it here.
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
Post Reply
NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

Wrong initial IPlayer.CurrentCommandIndex value

Post by NearHuscarl » Fri Mar 25, 2022 5:40 pm

When a player is spawned, the initial IPlayer.CurrentCommandIndex value is -1, this is inconsistent with the docs:
CurrentCommandIndex[get]
Returns the current command action index being processed. If this equals to PerformedCommandActionsCount then no more command actions are queued
This means when there are no other commands to execute, CurrentCommandIndex = PerformedCommandActionsCount - 1. Calling ClearCommandQueue() will then reset the CurrentCommandIndex to 0 which is the correct initial value.

Current behavior:

Code: Select all

player.SetInputEnabled(false);

// CurrentCommandIndex: -1, PerformedCommandCount: 0
player.AddCommand(new PlayerCommand(PlayerCommandType.StartCrouch));
// CurrentCommandIndex: 0, PerformedCommandCount: 1
player.AddCommand(new PlayerCommand(PlayerCommandType.Grab));
// CurrentCommandIndex: 1, PerformedCommandCount: 2
Expected result (without having to call ClearCommandQueue()):

Code: Select all

player.SetInputEnabled(false);
player.ClearCommandQueue();

// CurrentCommandIndex: 0, PerformedCommandCount: 0
player.AddCommand(new PlayerCommand(PlayerCommandType.StartCrouch));
// CurrentCommandIndex: 1, PerformedCommandCount: 1
player.AddCommand(new PlayerCommand(PlayerCommandType.Grab));
// CurrentCommandIndex: 2, PerformedCommandCount: 2
0 x
Image

Post Reply