Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: zyxstand on April 21, 2007, 09:44:03 pm

Title: !nextmap
Post by: zyxstand on April 21, 2007, 09:44:03 pm
Sry this is my first time posting in this section so here it goes:
It would be great to have a !nextmap feature that one can type during anytime of a round and the person's count would be added to how many this vote there alreayd are.  So if like the map ctf_death is played and people don't like it 3 of them would !nextmap immediately and eventually 2 more would !nextmap and (say) 5 is needed to pass the vote.  Of course if a player leaves, his vote would be removed - and of course there's a server-defined passrate of, for example 75% or more.
Often I've played a map that most of the players disliked but the map that was voted for some didn't like either so it didn't get through.  Also, it sometimes takes a while until more people get tired of the map so they'll !nextmap and add to the vote-pool.  Plus, this is really ez to implement I'm sure...
Title: Re: !nextmap
Post by: mikembm on April 21, 2007, 11:10:12 pm
It's simple to make really, but unfortunately the OnleaveGame always returns an ID of 0.
So it looks like a 2.6 script.
Title: Re: !nextmap
Post by: Avarax on April 22, 2007, 04:40:33 am
you dont need the OnLeaveGame ID, just reduce the counter by 1.
Title: Re: !nextmap
Post by: zyxstand on April 22, 2007, 09:17:15 am
you dont need the OnLeaveGame ID, just reduce the counter by 1.

of course only if a person who voted actually leaves...
Title: Re: !nextmap
Post by: iftach on April 25, 2007, 11:15:21 am
I fail to see the problem. You have the leaving player nickname, meaning, you can do NameToID.

here is my code:
http://forums.soldat.pl/index.php?topic=13382.0
Title: Re: !nextmap
Post by: zyxstand on April 26, 2007, 03:23:44 pm
hey yeah - honestly I don't see what the problem is either but then again, I'm not familiar with how to server-script...  In any case, I thought it would be as simple as (in simplified c++ code):

Code: [Select]
if (thisplayer.mapvoted == 0)  // if player has not already voted
  nextmapvote (thisplayer);  // call function
if (mapvote >= players * votepass)  // if enough votes for nextmap
  nextmap ();
if (player.left && player.mapvoted == 1)
  mapvote --;

function nextmapvote (playername) {
  playername.mapvoted = 1;
  mapvote += 1;
}

Don't be hatin' bout my simplificatin'