Author Topic: !nextmap Voting  (Read 9286 times)

0 Members and 3 Guests are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
!nextmap Voting
« 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
« Last Edit: August 30, 2008, 12:55:13 pm by DorkeyDear »

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: !nextmap Voting
« Reply #1 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.
« Last Edit: August 18, 2007, 09:51:00 pm by mikembm »

Offline Ttil_Np.csWoW

  • Major
  • *
  • Posts: 55
  • The Berserkers Are Coming....
Re: !nextmap Voting
« Reply #2 on: August 19, 2007, 02:54:42 am »
Defently like this script as it gives the people there power
I will be back to play soldat, just not now , but i will....... some day.

Offline SirJamesaford

  • Flagrunner
  • ****
  • Posts: 763
  • SirJamesaford is still in the early Beta stage.
Re: !nextmap Voting
« Reply #3 on: August 19, 2007, 02:58:37 am »
now if only avarax will use this for his eC hexer server.....
And if the dam breaks open many years too soon
And if there is no room upon the hill
And if your head explodes with dark forebodings too
Ill see you on the dark side of the moon

Offline Ttil_Np.csWoW

  • Major
  • *
  • Posts: 55
  • The Berserkers Are Coming....
Re: !nextmap Voting
« Reply #4 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.....
I will be back to play soldat, just not now , but i will....... some day.

Offline Tosty

  • Soldier
  • **
  • Posts: 172
  • Ultimate TW Medic
    • Just Click it
Re: !nextmap Voting
« Reply #5 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;




Offline miketh2005

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 668
  • What's the URL for www.microsoft.com?
Re: !nextmap Voting
« Reply #6 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
Quote from: 'Ando.' pid='12999178' dateline='1309046898'
My new password is secure as shit :)
Mate, I am not sure Shit is even secured nowadays.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: !nextmap Voting
« Reply #7 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?

Offline miketh2005

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 668
  • What's the URL for www.microsoft.com?
Re: !nextmap Voting
« Reply #8 on: August 21, 2007, 03:11:18 pm »
there is a /votemap i know
Quote from: 'Ando.' pid='12999178' dateline='1309046898'
My new password is secure as shit :)
Mate, I am not sure Shit is even secured nowadays.

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: !nextmap Voting
« Reply #9 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.

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: !nextmap Voting
« Reply #10 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;

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: !nextmap Voting
« Reply #11 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:
  • When a person leaves, if they have not voted, the script rechecks the voting percentages

    Date Posted: September 01, 2007, 03:52:37 pm
    Update:
     
  • Temporarily disables voting before map change

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.

Offline Mr

  • Inactive Soldat Developer
  • Soldier
  • ******
  • Posts: 166
Re: !nextmap Voting
« Reply #12 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 :(

Offline falcon.

  • Major(1)
  • Posts: 20
  • quak!!!
Re: !nextmap Voting
« Reply #13 on: October 12, 2008, 01:41:18 pm »
exceelent scrip :)