Author Topic: NextMap Vote  (Read 3518 times)

0 Members and 1 Guest are viewing this topic.

Offline iftach

  • Major(1)
  • Posts: 16
NextMap Vote
« on: April 25, 2007, 11:11:03 am »
Script Name: NextMap Vote
Script Description: Players can vote to skip to next map by writing !nextmap.
Vote % set on 60% for default.
Original Author(s): Iftach
Core Version: 2.6.0

Please alert me on any bug you find.

Code: [Select]
var 
  NextMapArray: array[1..32] of Boolean;
  NextMapVote: Byte;

procedure ResetMapVote();
var
i: integer;
begin
NextMapVote:=0;
for i := 1 to 32 do begin
NextMapArray[i] := False;
end;
end;

procedure OnMapChange(NewMap: string);
begin
ResetMapVote()
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
if NextMapArray[ID] then begin
 NextMapArray[ID]:=false;
 NextMapVote:=NextMapVote-1;
end;
end;

procedure NextMapV(ID: integer);
var
VotePrec: Double;
begin
   NextMapArray[ID]:=true;
   NextMapVote:=NextMapVote+1;
   command('/say Voters for Next Map: ' + inttostr(NextMapVote)+'/'+inttostr(NumPlayers));
   VotePrec:=NextMapVote/NumPlayers;
  {the 0.6 means 60% vote percentage needed. (changeable)}
   if (VotePrec>0.6) then Begin
    Command('/say Next Map Vote Had Passed');
    Command('/nextmap');
   End;
End;

procedure OnPlayerSpeak(ID: byte; Text: string);
begin
  if (Text = '!nextmap') and (NextMapArray[ID]=false) then NextMapV(ID);
End;
« Last Edit: May 11, 2007, 03:48:46 am by iftach »

Offline Laser Guy

  • Veteran
  • *****
  • Posts: 1679
Re: NextMap Vote
« Reply #1 on: April 25, 2007, 11:14:11 am »
and how do i use this?
Text goes here...

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: NextMap Vote
« Reply #2 on: April 25, 2007, 11:38:49 am »
you cant use this, the "nickname" and "IP" parameter of OnLeaveGame are corrupt in most cases
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: NextMap Vote
« Reply #3 on: April 25, 2007, 11:48:33 am »
Yeah so pretty much if you hate the map just vote/leave/join/vote until it changes.
Wouldn't recommend using until 1.4

Offline iftach

  • Major(1)
  • Posts: 16
Re: NextMap Vote
« Reply #4 on: May 04, 2007, 09:02:10 am »
ok, now its working good.  :)