SphereCommunity
Tags Comparison & Region - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Tags Comparison & Region (/Thread-Tags-Comparison-Region)



Tags Comparison & Region - pinku - 03-09-2014 08:54 PM

Hey!

Two different but quick questions. Every help is appreciated, as usual!

I'm making a simple election process based on votes.
I got 10 tags (1 for each candidate) and for the election to be completed, I need the player who was voted the highest.

Is there an easy way to compare those 10 tags to find the person who got the most votes? Something that won't make me compare 100 times manually.. lol
I can't find the right way to do this..

Second question;

Is there a way I can add new EVENTS to an AREA without having to restart the server? Like making it reload or something.. Tongue

Thanks a lot! Smile


RE: Tags Comparison & Region - Feeh - 03-09-2014 11:16 PM

The best way to find who was the player with most votes is by checking one by one, luckily the FOR statement is here to help us

Code:
local.mostVotedPlayer=1 //always assume the first tag is the one with most votes
local.mostVotes=<dtag.Player_1_Votes>
FOR x 1 10 // loop from 1 to 10, assuming your tags index is 1 based
  IF (<tag.Player_<dlocal.x>_Votes> > <dlocal.mostVotes>)
    local.mostVotedPlayer=<dlocal.x>
    local.mostVotes=<dtag.Player_<dlocal.x>_Votes>
  ENDIF
ENDFOR
//the player with most votes was the candidate <dlocal.mostVotedPlayer> with <dlocal.mostVotes> votes

If there is a draw, the first player who signed to the vote list will be elected


---

You could try to resync the server, it should re-load your scripts


RE: Tags Comparison & Region - pinku - 03-10-2014 04:25 PM

Ooooh. Thanks Feeh.
I got your logic, I was thinking the long way. LOL
I feel completely stupid now. Sad

Thanks again!