RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Gump Help / Choice Recording

ThatDudeJBob

Sorceror
I need a little help on something I've been working on.
I have the workable gump, all the buttons and everything work like they should.
I'm just wondering how i could record something like 'Yes' and 'No' Votes and add them together to get a Vote % for the players to see after they make a choice.


PHP:
                case (int)Buttons.ButtonYes:
                {
                    sender.Mobile.CloseGump( typeof( VoteMainGump ) );
                    sender.Mobile.SendMessage( "Thank You! Your vote has been recorded." );
                    //ToDo: Record The Vote & If Player Already Voted, Vote Won't Count
                    break;
                }
                case (int)Buttons.ButtonNo:
                {
                    sender.Mobile.CloseGump( typeof( VoteMainGump ) );
                    sender.Mobile.SendMessage( "Thank You! Your vote has been recorded." );
                    //ToDo: Record The Vote & If Player Already Voted, Vote Won't Count
                    break;
                }
 

pooka01

Sorceror
Can take a look at the ballot box script.

or using that example.

using variables such as:
private int m_VotesYes;
private int m_VotesNo;

then when a player hits yes, ++m_VotesYes, if no, ++m_VotesNo.

then to show the result:
ex: yes = 1250 * 100 / 1250 + 2250 = 35.71% if i'm correct.
"yes: " + (double)(m_VotesYes * 100 / (m_VotesYes + m_VotesNo))
"no: " + (double)(m_VotesNo * 100 / (m_VotesYes + m_VotesNo))

may aswell want to change those variables to static if you need to keep it in only one instance.
 

daat99

Moderator
Staff member
What pooka01 suggested will work great.
I will go with the static variables in your case though.
If you won't use static variables than each gump instance will have its own counter and they won't combine together.
 
Top