Key bingings for 1 player, trigger results for all

Report any bugs here or ask questions here!

Key bingings for 1 player, trigger results for all

Postby Assassin49 » 6 February 2021, 01:49

Hello, everyone,

Does anyone know of any way to do what I'm describing below for a coop game?

Ok, so...

What I can do so far: I have assigned a key binding that is available only for a specific player. When that player presses and holds that key on their keyboard a trigger is called executing a set of actions. Then, when the player releases that key, another trigger is called with a different set of actions.

What I need help with: The 2 triggers mentioned above work great for the player who has the ability to activate them by pressing, holding, and releasing the specified key on the keyboard. The problem is that the trigger results don't "show up" for the rest players who can't activate those triggers using that key binding. Does anyone know how to make the results of the trigger actions available to all players, while the triggers can only be called by the person that the key binding is activated for? Is it even possible?

Thanks in advance!

P.S: I am not interested in solutions that don't work with the method of pressing, holding, and later releasing a key on the keyboard to call the 2 triggers. I know of other ways to solve this already, but it's really important to me to find a way that still allows the use of key bindings (instead of regions that can call triggers when you press E, but not when releasing it).

Assassin49
 
Posts: 3
Joined: 30 November 2020, 21:40

Re: Key bingings for 1 player, trigger results for all

Postby Nyove » 7 February 2021, 05:12

Hey Assassin49,

The reason why other players could not seem to see the user pressing the keybinds is because keybind actions are only client-sided. You need to implement region sync trick, enabling you to sync keybind actions.

Refer to the map description in https://www.plazmaburst2.com/?s=9&a=&m= ... &id=999227 for detailed explanation and map source. (This only demonstrates key press, but the same concept applies for key release.)

Best regards,
Nyove
Proud to be part of something meaningful.
Need any assistance? Join the PB2 discord server at https://discord.com/invite/Bhe9rNz or raise a support ticket at https://www.plazmaburst2.com/support

Contact me on discord for quickest reply possible.

User avatar
Nyove
Moderator
 
Posts: 255
Joined: 7 July 2016, 10:26
Location: Cicada 3301

Re: Key bingings for 1 player, trigger results for all

Postby Assassin49 » 8 February 2021, 11:29

Thank you Nyove.

After all, I came up with a different idea but it's still somewhat similar to what you said. I will describe it here in case it helps someone in the future.

First, I made sure that the trigger actions that define which trigger will be executed when a key is pressed/released, will only run for the player I want by checking the player's slot. So only the player with the specified slot will be able to use the keybinds.
In the triggers that are executed when the specified key is pressed/released, I always change the value of a variable (1 when the key is pressed, 0 when released). Because this is happening client-sided only for the player who is allowed to use the keybind, I then sync the value of that variable across all players.
A timer with 0 seconds delay is constantly calling a trigger which is checking that variable's value. This is now happening for all players and all "see" the same value for that variable. Based on the value, 2 triggers can be called, one when the value is 1 and another one when the value is 0. Since the variable is synced, the actions of these 2 triggers will execute for every player. And that's it.

Assassin49
 
Posts: 3
Joined: 30 November 2020, 21:40

Re: Key bingings for 1 player, trigger results for all

Postby Nyove » 8 February 2021, 12:41

Hey Assassin49,

I really admire that you attempted to try and solve this issue and came up with your own unique solution! It is awesome to see other map makers' various approach in map making. :)

Your solution works great, however I have a small critic. I feel like constantly running 2 timers with a 0 delay is very unoptimised and could introduce unnecessary lag.

Best regards,
Nyove
Proud to be part of something meaningful.
Need any assistance? Join the PB2 discord server at https://discord.com/invite/Bhe9rNz or raise a support ticket at https://www.plazmaburst2.com/support

Contact me on discord for quickest reply possible.

User avatar
Nyove
Moderator
 
Posts: 255
Joined: 7 July 2016, 10:26
Location: Cicada 3301

Re: Key bingings for 1 player, trigger results for all

Postby Assassin49 » 10 February 2021, 13:20

Well yeah, you are definitely right. I will probably try your suggested solution soon. Thanks again for your help! :)

Assassin49
 
Posts: 3
Joined: 30 November 2020, 21:40


Return to Bug Reporting, Help & Support

Who is online

Users browsing this forum: No registered users