Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: DorkeyDear on August 18, 2007, 08:58:03 pm

Title: !nextmap Voting
Post by: DorkeyDear on August 18, 2007, 08:58:03 pm
Script Name: !nextmap Voting
Script Description: When a player types '!nextmap', voting has started for the next map. When enough players have '!nextmap'ed, then the server '/nextmap's.
Original Author: Curt
Core Version: 2.6.3
In request from miketh2005.

Latest update: Aug 30, 2008
Title: Re: !nextmap Voting
Post by: mikembm on August 18, 2007, 09:49:26 pm
To answer your question it's because when you divide an integer by a float for some reason it treats the answer as an integer. I don't know why but I do know that you need to have the integer be a float by adding a .0 at the end.
Title: Re: !nextmap Voting
Post by: Ttil_Np.csWoW on August 19, 2007, 02:54:42 am
Defently like this script as it gives the people there power
Title: Re: !nextmap Voting
Post by: SirJamesaford on August 19, 2007, 02:58:37 am
now if only avarax will use this for his eC hexer server.....
Title: Re: !nextmap Voting
Post by: Ttil_Np.csWoW on August 19, 2007, 03:06:36 am

now if only avarax will use this for his eC hexer server.....
I second that!

i would put this on my server....if i had one.....
Title: Re: !nextmap Voting
Post by: Tosty on August 19, 2007, 03:36:31 am
I hope you dont mind but i took your script and made a wep.ini vote

The only thing i cant figure out is how to add a second vote command so that you can vote back and forth between the normal and the moded one


Heres the mod vote
Code: [Select]
const
  Color = $FFFFFFFF;
  VotePerc = 50;
  VoteTime = 30;

var
  Go: boolean;
  VFor,Time: byte;
  Voted: array[1..32] of boolean;

procedure AppOnIdle(Ticks: integer);
var
  i: byte;
begin
  if Time > 0 then Time := Time - 1 else if Go then begin
    Go := false;
    for i := 1 to 32 do Voted[i] := false;
    VFor := 50;
    Time := 30;
    WriteConsole(0,'Map vote failed.',Color);
  end;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  Voted[ID] := false;
end;

procedure OnPlayerSpeak(ID: byte; Text: string);
var
  i: byte;
begin
  if Text = '!vote-m1' then if Voted[ID] = false then begin
    Go := true;
    Voted[ID] := true;
    VFor := VFor + 1;
    if VFor / NumPlayers * 100 >= VotePerc then begin
      Go := false;
      for i := 1 to 32 do Voted[i] := false;
      VFor := 0;
      Time := 30;
      WriteConsole(0,'Map vote passed.',Color);
      Command('/loadwep ?'); //HERE YOU REPLACE THE ? WITH THE NAME OF THE WEP.INI FILE THAT YOU WANT THE VOTE TO LOAD
    end else WriteConsole(0,'Voting percentage of needed people: ' + FloattoStr(RoundTo(VFor / NumPlayers * 100,2)) + '% / ' + InttoStr(VotePerc) + '%.',Color);
  end else WriteConsole(ID,'You have already voted.',Color);
  end;

Title: Re: !nextmap Voting
Post by: miketh2005 on August 21, 2007, 11:47:21 am
wow I like the wep.ini vote too, bythewat btw the guy with <------- in his name is me :) lol thanx
Title: Re: !nextmap Voting
Post by: DorkeyDear on August 21, 2007, 02:01:39 pm
If we could disable voting all together, then I would create a more customizable voting system for kicking and voting specific maps. I might do that anyways...
Is there an actual command /votemap or /votekick?
Title: Re: !nextmap Voting
Post by: miketh2005 on August 21, 2007, 03:11:18 pm
there is a /votemap i know
Title: Re: !nextmap Voting
Post by: Leo on August 23, 2007, 06:55:50 am
Script doesn´t work. You do !nextmap, it says something like "Voting percentage of needed people" and  then next moment vote failed. No time for other people to vote too.
Title: Re: !nextmap Voting
Post by: Toumaz on August 24, 2007, 05:52:19 am
It obviously doesn't work because you never even set Time to VoteTime, thus having the vote immediately finish on the next AppOnIdle call.

Just fix OnPlayerSpeak up a bit and it should work (added the bolded code):

Quote
procedure OnPlayerSpeak(ID: byte; Text: string);
var
   i: byte;
begin
   if Text = '!nextmap' then if Voted[ID] = false then begin
      Go := true;
      Voted[ID] := true;
      VFor := VFor + 1;
      if VFor = 1 then
         Time:=VoteTime;

      if VFor / NumPlayers * 100 >= VotePerc then begin
         Go := false;
         for i := 1 to 32 do Voted := false;
         VFor := 0;
         Time := 0;
         WriteConsole(0,'Map vote passed.',Color);
         Command('/nextmap');
       end else WriteConsole(0,'Voting percentage of needed people: ' + FloattoStr(RoundTo(VFor / NumPlayers * 100,2)) + '% / ' + InttoStr(VotePerc) + '%.',Color);
   end else WriteConsole(ID,'You have already voted.',Color);
end;
Title: Re: !nextmap Voting
Post by: DorkeyDear on April 05, 2008, 09:11:26 am
I can't believe I did that. I must have copied the wrong .pas file sense I did test it, lol.
I added a line that should make it work.
Code: [Select]
    if Go = false then Time := VoteTime;

Date Posted: August 25, 2007, 10:31:31 AM
And while I was at it, I added a new feature.. More time will be added to the count-down ever time a player votes. Set it to 0 if you don't want it.

Date Posted: August 25, 2007, 10:35:11 AM
I made it so the scripts resets when the map changes.
Code: [Select]
procedure OnMapChange(NewMap: String);
var
  i: byte;
begin
  Go := false;
  for i := 1 to 32 do Voted[i] := false;
  VFor := 0;
  Time := 0;
end;


Date Posted: August 25, 2007, 10:41:06 AM
Update:

Note to server owners: If there are other scripts that changes the maps, it muts call the DisableVoteNext procedure before it changes the map if you wish to disable the voting until the next map starts.
Title: Re: !nextmap Voting
Post by: Mr on May 18, 2008, 11:46:49 am
I know, this topic is old, but the script won't work. I saw a lot servers with such a script, but i tested it on my own today:

I hade 3 players, 2 voted for yes -> 66% / 51% ... and i didn't passed. tried it again, didn't worked again
just after the 3rd player typed !nextmap (so 100% / 51 %), it passed. if someone leavs after we got 66%, it passes too

i already tried to fix this, but i can't get it to work :(
Title: Re: !nextmap Voting
Post by: falcon. on October 12, 2008, 01:41:18 pm
exceelent scrip :)