lzinga / TTTWeightedTraitorSelection

A Garrys Mod TTT addon that improves the traitor selection process
Other
11 stars 6 forks source link

Add Log menu to admin ttt_weightlogs #15

Open lzinga opened 7 years ago

lzinga commented 7 years ago

Had an idea for the admin menu Admin Menu

Adding a "Logs" tab which gives information on how much weight was given to each user, and who was given more for group permissions. Which could help in debugging as well as see exactly what the addon is doing and how much weight people are getting. Could add the logs to the database for historical purposes. Giving admins extra information about what is happening.

This is just an idea and wondering what other peoples thoughts who have been using the addon.

janesth commented 7 years ago

How is the player weight being calculated? Sorry if that's a stupid question but I've never looked that much inside the code.

And what do you mean by "[a player] who was given more for group permission"?

Thanks. :)

lzinga commented 7 years ago

Players weights are just added or removed depending what role they get chosen to be.

If they are selected as traitor it sets them back to a default weight. If they are not selected they get a regular amount of weight added, if the ttt_karma_increase_weight setting is set it will give people extra weight depending on if they have good karma or not. Lastly it will look for people in group permissions defined in groupweights.txt and give them extra weight depending if they are in a special group, if the owner wants to use that feature. Which you can read more in depth in the readme.

The way it selects the person to be traitor is it shuffles a table of all players and their weights, adds all their weights together and selects a random number between 1 and all the weight. If a persons weight causes the random number to equal 0 or go under 0 it will choose them to be a traitor, so a person with 75 weight while everyone else has 10 will give him a much higher chance to become traitor, but not give him a 100% chance. The code for it is here

For example: Player 1 has 10 weight, Player 2 has 20, and player 3 has 50. Multiple scenarios could happen. TotalWeight = 80 RandomNumberToBeat = math.random(1, TotalWeight)

So if the RandomNumberToBeat is 1, whoever the first person in the shuffled table is able to beat a score of 1 gets selected as traitor. However say the RandomNumberToBeat is 30 and the shuffled table starts with Player 1. It will subtract 10 from 30 and there will still be 20 more to beat, if player 2 was next it would subtract 20 from 20 and it would equal 0 in which case he would win and be selected as traitor and his weight would be set back to default. But if player 3 had been in any of the other spots he would of won instantly because 30-50 would instantly take it below 0.

So just because you have a higher weight doesn't mean you will be selected as traitor, there is still a randomness to it that someone who just became traitor can be traitor again.

Hope all that makes sense lol, so for the sense of this enhancement, in the admin weightlogs you would be able to something like "Player 1 was given 6 normal weight, 0 karma weight, and 3 group weight for a total of 9 extra weight. Putting him at 25 total weight."

LaurenceKaye commented 7 years ago

Anything to help with debugging, or just people complaining that they think they aren't getting 'heavier' sounds good to me :)