Thread Rating:
- 0 Votes - 0 Average
- 1
- 2
- 3
- 4
- 5
Tags Comparison & Region
|
Author |
Message |
pinku
Journeyman
Posts: 118
Likes Given: 4
Likes Received: 2 in 2 posts
Joined: Apr 2013
Reputation: 4
|
Tags Comparison & Region
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..
Thanks a lot!
|
|
03-09-2014 08:54 PM |
|
|
Feeh
Sphere Developer
Posts: 156
Likes Given: 6
Likes Received: 40 in 29 posts
Joined: Sep 2012
Reputation: 4
|
RE: Tags Comparison & Region
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
Feeh/Epila - Nightly releases / SphereWiki / Github Issues / Sphere's GitHub
(This post was last modified: 03-09-2014 11:17 PM by Feeh.)
|
|
03-09-2014 11:16 PM |
|
|
pinku
Journeyman
Posts: 118
Likes Given: 4
Likes Received: 2 in 2 posts
Joined: Apr 2013
Reputation: 4
|
RE: Tags Comparison & Region
Ooooh. Thanks Feeh.
I got your logic, I was thinking the long way. LOL
I feel completely stupid now.
Thanks again!
|
|
03-10-2014 04:25 PM |
|
|
User(s) browsing this thread: 4 Guest(s)