Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit playerFunctions;
- { function damagemod(damage,maxhp:integer):integer;
- // This function will return a modified value of damage depending on a theoretical
- // amount of maximum health the victim has. The actually dealt damage is
- // proportionally decreased in case of maximum health above 150 and decreased in
- // case of lower maximum health. Please note that maximum health is a theoretical
- // value and actual damage a real value.
- function getids(ishuman:boolean):array of byte;
- // This function will return an array consisting of IDs of either all human players
- // or all bots.
- function getstr(input:string; part:byte):string;
- // A short version of getpiece(), that always uses one space as the delimiter. Use the
- // normal version of getpiece() if you divide parts with a different delimiter.
- function getint(input:string):integer;
- // Short version of intToStr()
- function getbyte(input:string):byte;
- // Will return a byte instead of an integer.
- }
- interface
- // ******
- function isregistered(id:byte) :boolean;
- function isflagger(id:byte) :boolean;
- function isground(id:byte) :boolean;
- function isactive(id:byte) :boolean;
- function isalive(id:byte) :boolean;
- function ishuman(id:byte) :boolean;
- function getdeaths(id:byte) :integer;
- function getkills(id:byte) :integer;
- function gethp(id:byte) :integer;
- function getping(id:byte) :integer;
- function getvest(id:byte) :integer;
- function gettime(id:byte) :integer;
- function getping(id:byte) :integer;
- function getport(id:byte) :integer;
- function getjets(id:byte) :integer;
- function getsecondary(id:byte) :byte;
- function getgrenades(id:byte) :byte;
- function getprimary(id:byte) :byte;
- function getid(name:string) :byte;
- function getteam(id:byte) :byte;
- function getammo1(id:byte) :byte;
- function getammo2(id:byte) :byte;
- function getvelx(id:byte) :single;
- function getvely(id:byte) :single;
- function getx(id:byte) :single;
- function gety(id:byte) :single;
- function getdirection(id:byte) :string;
- function gettagid(id:byte) :string;
- function gethwid(id:byte) :string;
- function getname(id:byte) :string;
- function getip(id:byte) :string;
- function getstr(input:string; part:byte):string;
- function getbyte(input:string) :byte;
- function getint(input:string) :integer;
- function damagemod(damage,maxhp:integer):integer;
- function getids(human:boolean) :array of byte;
- implementation
- // ******
- function isalive(id:byte):boolean;
- begin
- try result := getplayerstat(id,'alive');
- except
- writeln('ERROR: playerFunctions -> isalive() : ID not found');
- end;
- end;
- function isground(id:byte):boolean;
- begin
- try result := getplayerstat(id,'ground');
- except
- writeln('ERROR: playerFunctions -> isground() : ID not found');
- end;
- end;
- function ishuman(id:byte):boolean;
- begin
- try result := getplayerstat(id,'human');
- except
- writeln('ERROR: playerFunctions -> ishuman() : ID not found');
- end;
- end;
- function isactive(id:byte):boolean;
- begin
- result := getplayerstat(id,'active');
- end;
- function damagemod(damage,maxhp:integer):integer;
- begin
- try result := damage * 150 / maxhp;
- except
- writeln('ERROR: playerFunctions -> damagemod() : Division by zero');
- end;
- end;
- function gethp(id:byte):integer;
- begin
- try result := getplayerstat(id,'health');
- except
- writeln('ERROR: playerFunctions -> gethp() : ID not found');
- end;
- end;
- function getteam(id:byte):byte;
- begin
- try result := getplayerstat(id,'team');
- except
- writeln('ERROR: playerFunctions -> getteam() : ID not found');
- end;
- end;
- function getkills(id:byte):integer;
- begin
- try result := getplayerstat(id,'kills');
- except
- writeln('ERROR: playerFunctions -> getkills() : ID not found');
- end;
- end;
- function getdeaths(id:byte):integer;
- begin
- try result := getplayerstat(id,'deaths');
- except
- writeln('ERROR: playerFunctions -> getdeaths() : ID not found');
- end;
- end;
- function getx(id:byte):single;
- begin
- try result := getplayerstat(id,'x');
- except
- writeln('ERROR: playerFunctions -> getx() : ID not found');
- end;
- end;
- function gety(id:byte):single;
- begin
- try result := getplayerstat(id,'y');
- except
- writeln('ERROR: playerFunctions -> gety() : ID not found');
- end;
- end;
- function gethwid(id:byte):string;
- begin
- try result := getplayerstat(id,'hwid');
- except
- writeln('ERROR: playerFunctions -> gethwid() : ID not found');
- end;
- end;
- function getname(id:byte):string;
- begin
- try result := getplayerstat(id,'name');
- except
- writeln('ERROR: playerFunctions -> getname() : ID not found');
- end;
- end;
- function getid(name:string):byte;
- var i:byte;
- begin
- result := 0;
- for i := 1 to 32 do
- if getplayerstat(i,'active') = true then
- if getplayerstat(i,'name') = name then begin
- result := i;
- break;
- end;
- if result = 0 then writeln('ERROR: playerFunctions -> getid() : Name not found in game');
- end;
- function getstr(text:string; part:byte):string;
- begin
- result := getpiece(text,' ',part);
- if result = '' then writeln('ERROR: playerFunctions -> getstr() : Part = NIL');
- end;
- function getint(input:string):integer;
- begin
- try result := strtoint(input);
- except
- result := 0;
- writeln('ERROR: playerFunctions -> getint() : Invalid string input');
- end;
- end;
- function getbyte(input:string):byte;
- begin
- try result := strtoint(input);
- except
- result := 0;
- writeln('ERROR: playerFunctions -> getint() : Invalid string input');
- end;
- end;
- function getprimary(id:byte):byte;
- begin
- try result := getplayerstat(id,'primary');
- except
- result := 77;
- writeln('ERROR: playerFunctions -> getprimary() : ID not found');
- end;
- end;
- function getsecondary(id:byte):byte;
- begin
- try result := getplayerstat(id,'secondary');
- except
- result := 77;
- writeln('ERROR: playerFunctions -> getsecondary() : ID not found');
- end;
- end;
- function getammo1(id:byte):byte;
- begin
- try result := getplayerstat(id,'ammo');
- except
- result := 0;
- writeln('ERROR: playerFunctions -> getammo1() : ID not found');
- end;
- end;
- function getammo2(id:byte):byte;
- begin
- try result := getplayerstat(id,'secammo');
- except
- result := 0;
- writeln('ERROR: playerFunctions -> getammo2() : ID not found');
- end;
- end;
- function getping(id:byte):integer;
- begin
- try result := getplayerstat(id,'ping');
- except
- result := 0;
- writeln('ERROR: playerFunctions -> getping() : ID not found');
- end;
- end;
- function getport(id:byte):integer;
- begin
- try result := getplayerstat(id,'port');
- except
- result := 0;
- writeln('ERROR: playerFunctions -> getport() : ID not found');
- end;
- end;
- function getjets(id:byte):integer;
- begin
- try result := getplayerstat(id,'jets');
- except
- result := 0;
- writeln('ERROR: playerFunctions -> getjets() : ID not found');
- end;
- end;
- function getgrenades(id:byte):byte;
- begin
- try result := getplayerstat(id,'grenades');
- except
- result := 0;
- writeln('ERROR: playerFunctions -> getgrenades() : ID not found');
- end;
- end;
- function isflagger(id:byte):boolean;
- begin
- try result := getplayerstat(id,'flagger');
- except
- result := false;
- writeln('ERROR: playerFunctions -> isflagger() : ID not found');
- end;
- end;
- function gettime(id:byte):integer;
- begin
- try result := getplayerstat(id,'time');
- except
- result := 0;
- writeln('ERROR: playerFunctions -> gettime() : ID not found');
- end;
- end;
- function getvelx(id:byte):single;
- begin
- try result := getplayerstat(id,'velx');
- except
- result := 0;
- writeln('ERROR: playerFunctions -> getvelx() : ID not found');
- end;
- end;
- function getvely(id:byte):single;
- begin
- try result := getplayerstat(id,'vely');
- except
- result := 0;
- writeln('ERROR: playerFunctions -> getvely() : ID not found');
- end;
- end;
- function getvest(id:byte):integer;
- begin
- try result := getplayerstat(id,'vest');
- except
- result := 0;
- writeln('ERROR: playerFunctions -> getvest() : ID not found');
- end;
- end;
- function getdirection(id:byte):string;
- begin
- try result := getplayerstat(id,'direction');
- except
- result := '';
- writeln('ERROR: playerFunctions -> getdirection() : ID not found');
- end;
- end;
- function isregistered(id:byte):boolean;
- begin
- try result := getplayerstat(id,'registered');
- except
- result := false;
- writeln('ERROR: playerFunctions -> isregistered() : ID not found');
- end;
- end;
- function gettagid(id:byte):string;
- begin
- try result := getplayerstat(id,'tagid');
- except
- result := '';
- writeln('ERROR: playerFunctions -> gettagid() : ID not found');
- end;
- end;
- function getids(ishuman:boolean):array of byte;
- var i:byte; len:integer;
- begin
- for i := 1 to 32 do
- if (getplayerstat(i,'active') = true) and (getplayerstat(i,'human') = ishuman) then begin
- inc(len,1);
- setarraylength(result,len);
- result[len-1] := i;
- end;
- if len = 0 then writeln('ERROR: playerFunctions -> getids() : Server does not hold any '+iif(ishuman,'players','bots'));
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement