Script Name: Vote random map
Script Description: Players can vote a random map by !voterandom. If they vote, they can't vote again until the time you have set is over. When map is changed the time will be reseted.
Original Author(s): DhD (DieHardDie)
Core Version: 2.6.1
If you want the script to work, you have to make a .txt file and edit the name in the script. Standard the name is randmaplist.txt
You can also adjust the time that the players have to wait before they can vote again.
const
iTimer = (3*60); {time in seconds that the players have to wait before voting}
sRanMap = 'randmaplist.txt'; {text file where the list of maps to choose from is}
var
aPlayer: array[1..32] of Integer;
function OnRequestGame(IP: string; State: integer): integer;
begin
Result := State;
end;
procedure OnMapChange(NewMap: string);
var
iFor: integer;
begin
for iFor := 1 to 32 do begin
aPlayer[iFor] := TimeLeft;
end;
end;
procedure OnJoinTeam(ID, Team: byte);
begin
aPlayer[ID] := TimeLeft;
end;
function xSplit(const source: string; const delimiter: string):TStringArray;
var
i,x,d:integer;
s:string;
begin
d:=length(delimiter);
x:=0;
i:=1;
SetArrayLength(Result,1);
while(i<=length(source)) do begin
s:=Copy(source,i,d);
if(s=delimiter) then begin
inc(i,d);
inc(x,1);
SetArrayLength(result,x+1);
end
else begin
result[x]:= result[x]+Copy(s,1,1);
inc(i,1);
end;
end;
end;
procedure VoteMap(cText: string; Name: integer);
var
iList: Integer;
iRep: Integer;
aList: TStringArray;
sMap: String;
begin
iList := 1;
if ((aPlayer[Name]-iTimer) >= TimeLeft) then begin
if (FileExists(sRanMap)) then begin
aList := xSplit(ReadFile(sRanMap), (chr(13)+chr(10)));
iList := ArrayHigh(aList);
sMap := aList[random(0, iList)]
repeat
sMap := aList[random(0, iList)]
iRep := iRep+1;
until (sMap <> CurrentMap) or (iRep = 10);
StartVoteMap(Name, sMap);
aPlayer[Name] := TimeLeft;
end
else begin
Command('/say Map list is not found.');
end;
end
else begin
Command('/say You have to wait ' + IntToStr(TimeLeft - (aPlayer[Name]-iTimer)) + ' seconds till next vote.');
end;
end;
function OnPlayerSpeak(Name: string; Text: string): boolean;
var
cText: String;
begin
cText := LowerCase(Text);
if (cText = '!voterandom') then begin
VoteMap(cText, StrToInt(Name));
end;
end;
Thanks to all the scripts on this site and enesce!