voting for a map
#1

can anyone possilby give me a template for a voting system. i have searched just nothing decent comes up, oh and possibly with dialog? xd
Reply
#2

I would if I could :P

Maybe just go edit one you found and make it Decent
Reply
#3

The very basic method would be:

What you need:
pawn Код:
new votesleft;
new bool:voted[MAX_PLAYERS];
new votefor[32]; //String if voting for a mapname or just without the [32] if you use mapindexes
new votetimer = -1;

stock GetOnlinePlayers()    //Search the forum or just make one yourself, should be no big problem
Then make a command with whatever system you use like this: /vote <for>

if someone calls it, check if votetimer is > 0 (=there already is a active vote)
if not, go on, else break the cmd.
Set provotes to GetOnlinePlayers() / 5 or 2 or whatever. That number is the number of players that need to vote for it to pass. Put the <for> into votefor to store what the vote is about.
Also set all elements of voted to false with a for-loop.

Then set the votetimer, make it call a function, that ends the vote (sets votetimer to -1) in any time you want. This will be the expire time of the vote.

At last make another cmd like: /voteyes. If someone types it, check if voted[playerid] is true (he already voted) or votetimer == -1 (no vote in progress). if yes, break the cmd, else go on. Set voted[playerid] to true. Decrease votesleft by 1, then check if it is 0 or lower.
If it is, the vote has passed. Set votetimer to -1 to end the vote. Now do whatever should happen (e.g. change the map to the saved votefor string).

I hope it helps, i know the text is quite ugly, but thats all i could do for the moment
Reply
#4

Do you mean just a vote or a vote that actually changes the map automatically?

For the latter, the scripter would need to know which maps you want to present - or how you plan to list them.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)