bombsquad-plugin-manager/plugins/utilities/wave_emote.py

54 lines
1.5 KiB
Python
Raw Permalink Normal View History

2025-01-26 20:33:06 +03:00
# ba_meta require api 9
2025-01-26 20:34:29 +03:00
# crafted by brostos
2025-01-26 20:33:06 +03:00
#! Fix bug when the previous message is "hello" it will not trigger the wave emote on new round or game
import time
import babase
import bascenev1 as bs
last_len_msg = 0 # Initialize the global variable outside the function
2025-01-26 17:40:01 +00:00
2025-01-26 20:33:06 +03:00
def wave_emote():
global last_len_msg # To modify the global variable
2025-01-26 17:40:01 +00:00
2025-01-26 20:33:06 +03:00
# Check if the players are in game first
try:
act_players = bs.get_foreground_host_activity().players
if not act_players:
return
except AttributeError:
# Except the attribute error if the player is in a server
return
2025-01-26 17:40:01 +00:00
2025-01-26 20:33:06 +03:00
# Incase chats are empty or in replay
try:
lastmsg = bs.get_chat_messages()[-1]
except:
return
2025-01-26 17:40:01 +00:00
# Perform a check to see if the player is playing|spectating
2025-01-26 20:33:06 +03:00
for player in act_players:
try:
if player.actor.node:
continue
except:
return
2025-01-26 17:40:01 +00:00
2025-01-26 20:33:06 +03:00
# Check if the message contains "hello"
if len(bs.get_chat_messages()) != last_len_msg:
if act_players and "hello" in lastmsg:
for player in act_players:
if player.getname() in lastmsg:
# Trigger the wave emote
player.actor.node.handlemessage("celebrate_r", 1000)
last_len_msg = len(bs.get_chat_messages())
print(last_len_msg, "last_len_msg")
2025-06-24 00:55:09 +05:30
# ba_meta export babase.Plugin
2025-06-23 19:27:10 +00:00
2025-01-26 20:33:06 +03:00
class brostos(babase.Plugin):
timer = bs.AppTimer(0.5, wave_emote, repeat=True)