• Hey! Register here to create your account, engage with the community, and talk about what is new!

Chat message sending twice.

onion_hq

New member
Joined
Dec 23, 2023
Messages
14
Reaction score
0
I have code that will send a chat message to a player to confirm their choice of weapon, but for some reason the message is sent twice. I have checked the code over and over and I can't figure out why it does this. What's additionally confusing is that I have other lines of code that are the exact same, except for the message and variable contents, and they work normally.

The code goes like this:

Player Event: Right Click -> Call Function -> If Player: is looking at block (different block for each weapon) -> Player Action: Send Message + Set Variable (variable is used to give weapon when they enter the arena)
 

sapfii

Staff Manager
Administrator
Joined
Jan 12, 2021
Messages
21
Reaction score
5
i would recommend making a cooldown (you can just set an item cooldown on an item you never use) due to the Right Click player event oftentimes running more than once (which i believe is a paper bug)
1729296272111.png
 

Jimmy_The_Knight

Well-known member
Joined
Dec 28, 2020
Messages
73
Reaction score
32
Is the player doing an arm swing when right-clicking that block? Sometimes click events can trigger twice, I recommend locking that part of the code with a %default variable then resetting it a few ticks later

So basically like:
R-Click event fires
if(%default weaponConfirmLock == 0) {
set %default weaponConfirmLock to 1
Call process WeaponClickLockReset
//do stuff
}

WeaponClickLockReset process:
wait 2 ticks
set %default weaponConfirmLock to 0
 
Top Bottom