Wazarr94 / haxball_bot_headless

Ready-to-go scripts and functions for the HaxBall Headless API !
MIT License
46 stars 74 forks source link

Avatar that changes when you sign #63

Closed peppewarrior1 closed 1 year ago

peppewarrior1 commented 1 year ago

Hi sorry for the inconvenience. I did a little search to avoid duplicates but didn't find what I was hoping for... The question is simple: I would like when someone scores, makes an assist or an own goal to change the avatar for a certain amount of time (I think it's 3 seconds from the goal to the kick off) and then reset it again. I checked various functions in the scripts but I don't know where to apply "setPlayerAvatar" and since I've never programmed in java I don't even know how to pass certain seconds of interval. I hope I made myself understood with my bad English... :)

Wazarr94 commented 1 year ago

You can do so in the function getGoalString. The code to do what you want is along the lines:

room.setPlayerAvatar(goalAttribution[0].id, "G")
setTimeout(() => { room.setPlayerAvatar(goalAttribution[0].id, "") }, 3 * 1000)
peppewarrior1 commented 1 year ago

Thank you. For those who will be looking at this place in the future:

room.setPlayerAvatar(goalAttribution[0].id,` "G")
setTimeout(() => { room.setPlayerAvatar(goalAttribution[0].id, null) }, 1,8 * 1000)