Author Topic: Random voting,not working  (Read 846 times)

0 Members and 1 Guest are viewing this topic.

Offline Underworld

  • Camper
  • ***
  • Posts: 338
  • Mapper
Random voting,not working
« on: August 27, 2007, 07:33:52 pm »
Hi i just added the script to vote random maps.
i using script core 2.0 and i put the script in  a seperate folder whit instruction.txt
after hat i made the maplist so it can vote maps from that
but when i vote a map using !ranmap it shows up crap like

map : []9[]]][[
voter : name here
reason : o[]q^[[

why ??? this is the script im using

Code: [Select]
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 = '!ranmap') then begin
   
    VoteMap(cText, StrToInt(Name));
  end;
end;
I don't understand
do you mean that there is a /faceplam commmand ?
and this command should drop a random item ?

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Random voting,not working
« Reply #1 on: August 28, 2007, 02:07:21 am »
Sorry but that script is not valid at all. Ask the author to create it again, because its as old as the hills and is not compatible with any dedicated server version released after 1.3.1. OnPlayerSpeak does not have "Name: String" anymore and hasn't for a long time.

Offline Underworld

  • Camper
  • ***
  • Posts: 338
  • Mapper
Re: Random voting,not working
« Reply #2 on: August 28, 2007, 04:20:27 am »
Sorry but that script is not valid at all. Ask the author to create it again, because its as old as the hills and is not compatible with any dedicated server version released after 1.3.1. OnPlayerSpeak does not have "Name: String" anymore and hasn't for a long time.
then could  u remake this script and pm it to me if u find it in ure time ? :(
I don't understand
do you mean that there is a /faceplam commmand ?
and this command should drop a random item ?