Plan B

General => Bug Reports => Fixed => Topic started by: Yash on August 08, 2016, 04:45:52 pm

Title: 2 Presidents and 2 Vice presidents !
Post by: Yash on August 08, 2016, 04:45:52 pm
Most of the time there are 2 president and 2 vice president in game ! Please fix it :)
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: Finisher on August 08, 2016, 11:48:26 pm
Suffered a lot from this issue today, needs a fix asap!
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: Storm on August 09, 2016, 12:19:26 am
If a player is caught bugging the President he should be temp-banned
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: pRiMoZ on August 09, 2016, 12:30:23 am
If a player is caught bugging the President he should be temp-banned
Problem is that this happens due to mistakes too...
like- ''i just joined the game and pres slot seemed free, picked it and bang...2 presis''
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: style! on August 09, 2016, 12:34:20 am
I think the problem is class available isn't updated as fast as needed.
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: Jonne on August 09, 2016, 02:54:48 am
If a player is caught bugging the President he should be temp-banned
Problem is that this happens due to mistakes too...
like- ''i just joined the game and pres slot seemed free, picked it and bang...2 presis''

Yea, it happened mostly by mistake because 2 people picked president at the exact same time.

I think the problem is class available isn't updated as fast as needed.

I think that was the problem, so I moved it up in the 'chain of events', let's see if that makes a difference (Only for President though, not for vice as it isn't that big of a problem). If you still see 2 presis or 2 vices, do /checkpres, and it should auto-fix it.
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: YoMama on August 09, 2016, 10:20:50 am
If a player is caught bugging the President he should be temp-banned
Problem is that this happens due to mistakes too...
like- ''i just joined the game and pres slot seemed free, picked it and bang...2 presis''

Yea, it happened mostly by mistake because 2 people picked president at the exact same time.

I think the problem is class available isn't updated as fast as needed.

I think that was the problem, so I moved it up in the 'chain of events', let's see if that makes a difference (Only for President though, not for vice as it isn't that big of a problem). If you still see 2 presis or 2 vices, do /checkpres, and it should auto-fix it.
Thanks for creating a fix, but I feel like there should be a way of avoiding the problem in the first place. I would look into mutexes (https://en.wikipedia.org/wiki/Mutual_exclusion) for the President/Vice President classes (by the way, it's mistakenly "VicePresident" in the server). Basically, they stop two threads (or players) from using the same part of your code at the same time. From my research, it appears that PAWN doesn't have mutex support built in, but if you'd like help, I could try messing with it and see if I can't slap something together. Also, if you haven't already done this, you could call whatever function you've made for /checkpres ~10 seconds after "<Player> is now President" is printed in the chat and eliminate most cases as well.
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: Jonne on August 11, 2016, 01:01:01 pm
Thanks for creating a fix, but I feel like there should be a way of avoiding the problem in the first place. I would look into mutexes (https://en.wikipedia.org/wiki/Mutual_exclusion) for the President/Vice President classes (by the way, it's mistakenly "VicePresident" in the server). Basically, they stop two threads (or players) from using the same part of your code at the same time. From my research, it appears that PAWN doesn't have mutex support built in, but if you'd like help, I could try messing with it and see if I can't slap something together. Also, if you haven't already done this, you could call whatever function you've made for /checkpres ~10 seconds after "<Player> is now President" is printed in the chat and eliminate most cases as well.

I just made it a command for now, I'll look into a permanent solution that prevents the problem from happening first. I think I've found one now, I'll test it tonight. If I can't find a solution that completely fixes the problem, I'll add it in a timer.
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: Altus_Demens on August 11, 2016, 03:12:29 pm
Thanks for creating a fix, but I feel like there should be a way of avoiding the problem in the first place. I would look into mutexes (https://en.wikipedia.org/wiki/Mutual_exclusion) for the President/Vice President classes (by the way, it's mistakenly "VicePresident" in the server). Basically, they stop two threads (or players) from using the same part of your code at the same time. From my research, it appears that PAWN doesn't have mutex support built in, but if you'd like help, I could try messing with it and see if I can't slap something together. Also, if you haven't already done this, you could call whatever function you've made for /checkpres ~10 seconds after "<Player> is now President" is printed in the chat and eliminate most cases as well.
Sorry if my post will be irrelevant, but I guess that creating mutex interface using pawn where we can't even work normally with threads would be a lot of hard and ungrateful work, and it probably will cause a lot of new troubles like thread blocking and performance issues (in the best case it would be like "synchronized" block in Java which is almost deprecated). I am sure that there's better and easier solution but it's hard to tell not seeing the code. Anyways, if you want to mess with the threads, it's better use things like samgdk (http://forum.sa-mp.com/showthread.php?t=421090) and work with "complete" programming language with threads, mutexes and others things built-in.
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: YoMama on August 12, 2016, 10:50:31 am
Thanks for creating a fix, but I feel like there should be a way of avoiding the problem in the first place. I would look into mutexes (https://en.wikipedia.org/wiki/Mutual_exclusion) for the President/Vice President classes (by the way, it's mistakenly "VicePresident" in the server). Basically, they stop two threads (or players) from using the same part of your code at the same time. From my research, it appears that PAWN doesn't have mutex support built in, but if you'd like help, I could try messing with it and see if I can't slap something together. Also, if you haven't already done this, you could call whatever function you've made for /checkpres ~10 seconds after "<Player> is now President" is printed in the chat and eliminate most cases as well.
Sorry if my post will be irrelevant, but I guess that creating mutex interface using pawn where we can't even work normally with threads would be a lot of hard and ungrateful work, and it probably will cause a lot of new troubles like thread blocking and performance issues (in the best case it would be like "synchronized" block in Java which is almost deprecated). I am sure that there's better and easier solution but it's hard to tell not seeing the code. Anyways, if you want to mess with the threads, it's better use things like samgdk (http://forum.sa-mp.com/showthread.php?t=421090) and work with "complete" programming language with threads, mutexes and others things built-in.
How would it be irrelevant? You make a valid point. I know very little about PAWN, so I'm glad to learn more about it.
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: Skyfire on August 12, 2016, 10:53:50 am
It's easy to speculate about the problem without seeing the code. If you need a hand debugging the code Jonne drop me a PM with relevant lines
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: DrPepper on August 15, 2016, 04:08:36 am
Thanks for creating a fix, but I feel like there should be a way of avoiding the problem in the first place. I would look into mutexes (https://en.wikipedia.org/wiki/Mutual_exclusion) for the President/Vice President classes (by the way, it's mistakenly "VicePresident" in the server). Basically, they stop two threads (or players) from using the same part of your code at the same time. From my research, it appears that PAWN doesn't have mutex support built in, but if you'd like help, I could try messing with it and see if I can't slap something together. Also, if you haven't already done this, you could call whatever function you've made for /checkpres ~10 seconds after "<Player> is now President" is printed in the chat and eliminate most cases as well.

I just made it a command for now, I'll look into a permanent solution that prevents the problem from happening first. I think I've found one now, I'll test it tonight. If I can't find a solution that completely fixes the problem, I'll add it in a timer.

I feel like adding a timer or using OnPlayerUpdate can be easily used to fix the problem. But I have no idea what the code is like, just a suggestion given on the idea what you said.
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: Jonne on August 16, 2016, 10:41:53 pm
If you see it happen again, please post it here (with the name of who the presidents were and around what time it happened, so I can look into it). It should be fixed now (It wasn't happening because they took pres at the same time, I was just an idiot and forgot a check). 2 vices might still happen, but that's not that big of an issue, if this solutions works for presidents I'll add it for vices too.
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: Messy. on August 27, 2016, 05:59:32 pm
Its fixed
Title: Re: 2 Presidents and 2 Vice presidents !
Post by: Finisher on August 29, 2016, 08:25:17 pm
No it's not.. happened again today