Author Topic: help on exp script (super-upgrade on script by Ether22)  (Read 782 times)

0 Members and 2 Guests are viewing this topic.

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
help on exp script (super-upgrade on script by Ether22)
« on: November 16, 2007, 10:51:59 pm »
Code: [Select]
const
  GainPercent=1.00;

type
  PlayerType = record
    EXP: integer;
    Level: integer;
    Team: integer;
    Human: boolean;
    Active: boolean;
    Name: string;
  end;

var
  Player: array[1..32] of PlayerType;

procedure OnRecompile();
var
  i: integer;
begin
  for i:=1 to 32 do begin
    Player[i].Active:=GetPlayerStat(i,'Active');
    if not Player[i].Active then continue else begin
      Player[i].Team:=GetPlayerStat(i,'Team');
      Player[i].Human:=GetPlayerStat(i,'Human');
      if not Player[i].Human then
      Player[i].EXP:=100 else Player[i].EXP:=0;
      Player[i].Name:=GetPlayerStat(i,'Name');
    end;
    WriteLn('Player stats reset.');
  end;
end;

procedure OnJoinTeam(ID, Team: Byte);
begin
  Player[ID].Active:=GetPlayerStat(ID,'Active');
  Player[ID].Team:=Team;
  Player[ID].Human:=GetPlayerStat(ID,'Human');
  if not Player[ID].Human then
  Player[ID].EXP:=100 else Player[ID].EXP:=0;
  Player[ID].Name:=GetPlayerStat(ID,'Name');
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
var
  Gain: array[1..32] of integer;
begin
  if Killer <> Victim then begin
    if Player[Victim].EXP > 0 then begin
      Gain[Killer]:=Round(Player[Victim].EXP*GainPercent);
      inc(Player[Killer].EXP,Gain[Killer]);
    end else begin
      Gain[Killer]:=100;
      inc(Player[Killer].EXP,Gain[Killer]);
    end;
    WriteConsole(Killer,'EXP: '+inttostr(Player[Killer].EXP)+' EXP gained: '+inttostr(Gain[Killer]),$EE81FAA1);
  end;
end;

function OnCommand(ID:Byte;Text:string):boolean;
var
  Temp: array[0..5] of string;
  i: integer;
begin
  Result:=false;
  Temp[0]:=LowerCase(GetPiece(Text, ' ', 0)); //Command
  Case Temp[0] of
    '/recompile': begin
      OnRecompile();
    end;
    '/setexp','/expset': begin
      Temp[1]:=GetPiece(Text, ' ', 1); //Player
      Temp[2]:=GetPiece(Text, ' ', 2); //NewEXP
      if Player[strtoint(Temp[1])].Active=true then begin
        inc(Player[strtoint(Temp[1])].EXP,(strtoint(Temp[2])-Player[strtoint(Temp[1])].EXP));
        WriteConsole(ID,'Player '+Temp[1]+'''s EXP set to '+inttostr(Player[strtoint(Temp[1])].EXP)+'.',$FF20FF20);
      end else WriteConsole(ID,'Player '+Temp[1]+' is inactive.',$FFFF2020);
    end;
  end;
end;

procedure OnLeaveGame(ID,Team:Byte;Kicked:boolean);
begin
  Player[ID].Team:=-1;
  Player[ID].Human:=false;
  Player[ID].EXP:=0;
  Player[ID].Name:=' ';
end;

procedure OnException(ErrorMessage: string);
begin
end;

OnRecompile() does not work (I made it run when player uses /recompile)

(this is just a "skeleton" of a EXP script (with some "Meat" on it... mmm, tasty! :P ))
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."