Author Topic: Hoverrace Script 1.0  (Read 4125 times)

0 Members and 1 Guest are viewing this topic.

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Hoverrace Script 1.0
« on: January 27, 2007, 11:04:22 am »
Script Name:
Script Description: Saves besttimes for Hoverraces with exact round times in milliseconds + anti speedhack and scoreboard function
Original Author(s): Avarax
Core Version: 2.5.2, contains procedures of Core.pas and NetWork.pas
Code:
Code: [Select]
const
//Teams
ALPHA = 1;
BRAVO = 2;
CHARLIE = 3;
DELTA = 4;
SPECTATOR = 5;
//Game Modes
DEATHMATCH = 0;
POINTMATCH = 1;
TEAMMATCH = 2;
CTF = 3;
RAMBO = 4;
INF = 5;
HTF = 6;

SERVER = 255;

             
var
sms,sec,ms,player,time: integer;
score,played: array[1..32] of integer;
playa: string;
timekill: boolean;


procedure ActivateServer();
begin
  timekill:=false;
  time:=0;
end;

procedure AppOnIdle(Ticks: integer);
begin
  if(TimeLeft+1=TimeLimit*60) then
    sms  := strtoint(FormatDate('z'));
  if timekill then
    begin
      time:=time+1;
      If time>8 then
        begin
          Command('/kill ' + inttostr(player));
          timekill:=false;
          time:=0;
        end;
    end;
end;

procedure OnCommand(ID: integer;Text: string);
var  maps: string;
     mapsarray: array[0..50] of string;
     i: integer;
begin

  //'/erase' erases highscore of currently played map
  if(Text='/erase') then
    begin
      Writefile('h' + CurrentMap + '.ini','');
      Command('/pm ' + inttostr(ID) + ' Highscore of ' + Currentmap + ' erased.');
    end;
   
  //'/eraseall' erases all highscores (windows only)
  {if (Text='/eraseall') then
    begin
      maps:= ReadFile('mapslist.txt');
      mapsarray:= split(maps,chr(13)+chr(10));
      for i:=0 to 50 do
        Writefile('h' + mapsarray[i] + '.ini','');
      Command('/pm ' + inttostr(ID) + ' All highscores erased.');       
    end;}
end;

function OnRequestGame(IP: string;State: integer):integer;
begin
Result := State;
end;

procedure OnJoinGame(IP, Nickname: string;Team: byte);
begin
end;

procedure OnJoinTeam(IP, Nickname: string;Team: byte);
begin
  score[IPtoID(IP)]:=0;
  played[IPtoID(IP)]:=0;
  If Team=2 then
    Command('/setteam1 ' + inttostr(IPtoID(IP)));
end;

procedure OnLeaveGame(IP, Nickname: string;Team: byte);
begin
end;

procedure OnFlagGrab(ID: integer;TeamFlag: byte;GrabbedInBase: boolean);
begin
  playa:=IDToName(ID);
  player:=ID;
  timekill:=true;
end;

procedure OnFlagReturn(ID: integer;TeamFlag: byte);
begin
end;

procedure OnFlagScore(ID: integer;TeamFlag: byte);
var i: integer;
    nl: string;
    write: boolean;
begin 
  timekill:=false;
  time:=0;
  sec:=TimeLimit*60-Timeleft;
  If strtoint(FormatDate('z')) < sms then
    begin
      sec:=sec-1;
      ms:=1000+strtoint(FormatDate('z'))-sms;
    end
  else
    ms:=strtoint(FormatDate('z'))-sms;
   
  Command('/say ' + playa + ' wins with a time of:');
  Command('/say ' + inttostr(sec) + ',' + inttostr(ms) + ' seconds!');
  score[player]:=score[player]+1;
  for i:=1 to 32 do
    played[i]:=played[i]+1;

  nl:=chr(13)+chr(10);

  If strtoint(ReadINI('hover_minimum.ini','Minimum',CurrentMap,'0'))>sec then
    Command('/kick ' + inttostr(player))
  else
    If strtoint(ReadINI('h' + CurrentMap + '.ini',CurrentMap,'seconds','5000'))>sec then
      begin
        write:=WriteFile('h' + Currentmap + '.ini','[' + CurrentMap + ']' + nl + 'seconds=' + inttostr(sec) + nl + 'milliseconds=' + inttostr(ms) + nl + 'player=' + playa);
        Command('/say Congratulations, you established a');                                                             
        Command('/say new record on ' + CurrentMap + '!');               
      end
    else
      If strtoint(ReadINI('h' + CurrentMap + '.ini',CurrentMap,'seconds','5000'))=sec then
        If strtoint(ReadINI('h' + CurrentMap + '.ini',CurrentMap,'milliseconds','999'))>ms then
          begin                                                                                                     
            write:=WriteFile('h' + Currentmap + '.ini','[' + CurrentMap + ']' + nl + 'seconds=' + inttostr(sec) + nl + 'milliseconds=' + inttostr(ms) + nl + 'player=' + playa);
            Command('/say Congratulations, you established a');                                                             
            Command('/say new record on ' + CurrentMap + '!');                                                                         
          end;   






end;

procedure OnPlayerKill(Killer,Victim,Weapon: string);
begin
end;

procedure OnPlayerRespawn(ID: integer);
begin
end;

procedure OnPlayerSpeak(Name,Text: string);
begin
  if Text='!score' then
  Command('/say ' + Name + ' current score is ' + inttostr(score[NametoID(Name)]) + ' having played ' + inttostr(played[NametoID(Name)]) + ' rounds.');
  if Text='!high' then
    begin
      Command('/say The record on ' + CurrentMap + ' is:');
      Command('/say ' + ReadINI('h' + Currentmap + '.ini',CurrentMap,'seconds','5000') + ',' + ReadINI('h' + Currentmap + '.ini',CurrentMap,'milliseconds','999') + ' by ' + ReadINI('h' + Currentmap + '.ini',CurrentMap,'player','N/A'));
    end;
end;
[/b]



Functions:
- Shows exact roundtime in milliseconds after one finished round.
- Compares and saves the fastest times for each map in INIs
- Contains minimum values for the roundtimes of each map which are impossible without hax or bugabuse. Players that reach these impossible times are autokicked and the score is not saved.
- Scoreboard function
- Autokills lamers that cap but not score the flag.

Commands
!score: Shows your rounds won and your rounds played
!high: Shows besttime for current map including the person who made it
/erase: Admins only: Erases besttime of current map
/eraseall: Admins only: Erases besttime of all maps in the maplist (Windows only)

Thanks to cooz for introducing me to some Soldat coding basics and spending time on fixing my first syntax bugs ;P


CAUTION: This script only works with a file included in the Hoverpack v1.0
For all of you who dont know hoverrace, click the link above.
« Last Edit: January 27, 2007, 06:48:52 pm by Avarax »
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline Cube

  • Camper
  • ***
  • Posts: 314
  • Go Cube go!
    • Cube&amp;#039;s Portal
Re: Hoverrace Script 1.0
« Reply #1 on: January 28, 2007, 10:51:19 am »
wow, i love the Hoverrace, and thx for making it public now
Hmm, any idea what to write here?

Offline Laser Guy

  • Veteran
  • *****
  • Posts: 1679
Re: Hoverrace Script 1.0
« Reply #2 on: March 29, 2007, 09:27:39 am »
I like it 2
Text goes here...

Offline deguix

  • Major
  • *
  • Posts: 79
Re: Hoverrace Script 1.0
« Reply #3 on: April 22, 2007, 06:24:13 am »
btw, could you make it to restart the race after someone is "disqualified" for haxing and scoring before the minimum time?