haxball / haxball-issues

115 stars 43 forks source link

New Events: onTimeLimitChange(newLimit:int, byPlayer: PlayerObject) and onScoreLimitChange(newLimit:int, byPlayer: PlayerObject) #2087

Open AndreaCasaluci opened 11 months ago

AndreaCasaluci commented 11 months ago

Hello Basro, I would like to request two new function for the Headless API which is triggered when TimeLimit and ScoreLimit change. This is similar to my previous request that was implemented, so I hope this won't be that hard. Those events could help prevent cases where a normal user finds himself being admin in an automated room and, by setting the TimeLimit and ScoreLimit to some random values, would bring the room to chaos.

Example:

room.onTimeLimitChange = function(newLimit:int, byPlayer: PlayerObject) {
if(byPlayer){
 // Check if byPlayer is an actual room admin and stuff
}
else room.setTimeLimit(defaultTimeLimitValue);
});

room.onScoreLimitChange = function(newLimit:int, byPlayer: PlayerObject) {
if(byPlayer){
 // Check if byPlayer is an actual room admin and stuff
}
else room.setScoreLimit(defaultScoreLimitValue);
});
kadavrahaxball commented 11 months ago

dont wait for basro's update. it aint gonna happen. learn to create custom events for yourself. its possible.

AndreaCasaluci commented 11 months ago

?? Only admins can change time and score limits... Another unnecessary things..

@Anooxy did u check the issue I've mentioned in this current post? It was a similar request and in that post I've explained why it was useful. If that request was fulfilled in a few hours, I don't understand why this one should be considered useless as well. I can't see what's your problem with a simple request guys, really.

AndreaCasaluci commented 11 months ago

If u really need something like this in your script - your script is not good then. Save some "headadmins auth in external db or even in script"...

@Anooxy First of all, I never said that my script is good. Even if it was perfect, sometimes it happens that there are no admins (the real ones, saved in MongoDB) and the last one to log off leaves temporary admins for someone in the room in case someone with powers is needed. It has become a habit that we implement, but once (once in months) it happened that we left the powers to the wrong person who set the Score Limit and Time Limit values differently. So, if there was a possibility to include the event (like so many other events already) that triggers when these values are changed, what is the need to go against this simple request? I still don't understand what your problem is guys.

AndreaCasaluci commented 11 months ago

Buuut, why dont u check timeLimit and scoreLimit in onGameStart event? Just check if(room.getScores().timeLimit != 5) room.setTimeLimit(5); of course room.stopGame room.setTimeLimit and then room.startGame...

@Anooxy Yes, this would definitely work, but I personally requested the events described in the post because they would allow the user who did this to be traced and having an automated warning script, it would be possible to send a direct warning to this user with these events. The warning script works with DB and sends the Warning Message to the user if he's in room, or whenever the user enters again (even with a clone). When the user gets an X number of warnings he'll get banned. The main reason is this.