Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const // ___ ___ ___ ___ ___ ___ ___
- ZitroVersion = 'v1.0.0 - Lite'; //Code: 421`291 end = 617 Build=1.2.0.26 // /\ \ ___ /\ \ /\ \ /\ \ /\ \ /\__\ /\__\
- PointsForStart = '1000'; // \:\ \ /\ \ \:\ \ /::\ \ /::\ \ /::\ \ /:/ / /::| |
- YouInfo = 'Script Forum: http://polish-oneshoot.esy.es/'; // \:\ \ \:\ \ \:\ \ /:/\:\ \ /:/\:\ \ /:/\:\ \ /:/ / /:|:| |
- GOOD = $EE00FF00; // \:\ \ /::\__\ /::\ \ /::\~\:\ \ /:/ \:\ \ /::\~\:\ \ /:/ / ___ /:/|:| |__
- BAD = $ff0033; // _______\:\__\ __/:/\/__/ /:/\:\__\ /:/\:\ \:\__\ /:/__/ \:\__\ /:/\:\ \:\__\ /:/__/ /\__\ /:/ |:| /\__\
- CRLF = #13#10; // \::::::::/__/ /\/:/ / /:/ \/__/ \/_|::\/:/ / \:\ \ /:/ / \/__\:\ \/__/ \:\ \ /:/ / \/__|:|/:/ /
- rank_store = 10; // \:\~~\~~ \::/__/ /:/ / |:|::/ / \:\ /:/ / \:\__\ \:\ /:/ / |:/:/ /
- MaxPointGive = 50; // \:\ \ \:\__\ \/__/ |:|\/__/ \:\/:/ / \/__/ \:\/:/ / |::/ /
- precision = 6; // Precision calculation powers for point ELO-Point system // \:\__\ \/__/ |:| | \::/ / \::/ / /:/ /
- type // \/__/ \|__| \/__/ \/__/ \/__/
- TRank = record
- Points: integer;
- HWID: string;
- end;
- type
- TStats = record
- Kills, TeamKills, Deaths, DeathsByTeam, SelfKills, Points: string;
- end;
- var
- nickStatus: array [1..32] of boolean;
- PlayerStats: array [1..32] of TStats;
- ranks: array of TRank;
- FriendlyFire: boolean; Liczba, Tysieczna: integer;
- function Explode(Source: string; const Delimiter: string): array of string;
- var Position, DelLength, ResLength: integer;
- begin
- DelLength := Length(Delimiter);
- Source := Source + Delimiter;
- repeat
- Position := Pos(Delimiter, Source);
- SetArrayLength(Result, ResLength + 1);
- Result[ResLength] := Copy(Source, 1, Position - 1);
- ResLength := (ResLength + 1);
- Delete(Source, 1, Position + DelLength - 1);
- until (Position = 0);
- SetArrayLength(Result, ResLength - 1);
- end;
- procedure LoadNickname(ID: byte);
- var temparray: TStringArray;
- begin
- if (FileExists('nickreg/'+GetPlayerStat(ID,'HWID')+'.txt') = true) then begin
- temparray := Explode(ReadFile('nickreg/'+GetPlayerStat(ID,'HWID')+'.txt'),CRLF);
- PlayerStats[ID].Kills := temparray[0]; PlayerStats[ID].TeamKills := temparray[1]; PlayerStats[ID].Deaths := temparray[2]; PlayerStats[ID].DeathsByTeam:= temparray[3]; PlayerStats[ID].SelfKills := temparray[4];
- PlayerStats[ID].Points := temparray[5];
- end else
- begin
- NickStatus[ID] := false; PlayerStats[ID].Points := PointsForStart;
- end;
- end;
- procedure ResetVar(b: byte);
- begin
- NickStatus[b] := false; PlayerStats[b].Points := PointsForStart; PlayerStats[b].DeathsByTeam := '0';
- PlayerStats[b].Kills := '0'; PlayerStats[b].TeamKills := '0'; PlayerStats[b].Deaths := '0'; PlayerStats[b].SelfKills := '0';
- end;
- function StrToID(s: string): byte;
- var i: byte;
- begin
- Result := 254;
- try
- if GetPlayerStat(StrToInt(s), 'active') then Result := StrToInt(s);
- except
- s := LowerCase(s);
- for i := 1 to 32 do if GetPlayerStat(i, 'active') then if ContainsString(LowerCase(IDToName(i)), s) then begin
- Result := i;
- break;
- end;
- end;
- end;
- function WowSuchASpeed(a: double; b: integer): double;
- var c: double;
- begin
- if (b = 0) then result := 1 else if b mod 2 = 1 then result := (WowSuchASpeed(a, b-1) * a) else begin
- c := WowSuchASpeed(a, b div 2);
- result := (c * c);
- end;
- end;
- function WowItsEvenFaster(a: double; b: longint): double;
- var l, r, s, p: int64; AlgorithmsAreSoEZ: double;
- begin
- p := round(WowSuchASpeed(10, precision));
- l := 0;
- r := p;
- while(l<r) do begin
- s := (l+r) div 2;
- AlgorithmsAreSoEZ := s;
- if (WowSuchASpeed(AlgorithmsAreSoEZ, b) > a) then r := s else l := (s + 1);
- end;
- result := (l-1);
- l := 0;
- r := (p-1);
- while(l<r) do begin
- s := (l+r) div 2;
- AlgorithmsAreSoEZ := s;
- AlgorithmsAreSoEZ := (AlgorithmsAreSoEZ / p);
- AlgorithmsAreSoEZ := (AlgorithmsAreSoEZ + result);
- if (WowSuchASpeed(AlgorithmsAreSoEZ, b) > a) then r := s else l := (s + 1);
- end;
- AlgorithmsAreSoEZ := (l - 1);
- AlgorithmsAreSoEZ := (AlgorithmsAreSoEZ / p);
- result := (result + AlgorithmsAreSoEZ);
- end;
- procedure ABP(c: double);
- var c1, c2: string; i, b: byte;
- begin
- if (c<>0) then begin
- c1 := FloatToStr(c);
- c1 := GetPiece(c1, '.', 1);
- for i := 1 to Length(c1) do if (strtoint(c1[i]) <> 0) then begin
- Liczba := strtoint(c1[i]);
- c2 := '1';
- for b := 1 to i do c2 := c2 + '0';
- Tysieczna := strtoint(c2);
- break;
- end;
- end else
- begin
- Liczba := 0;
- Tysieczna := 0;
- end;
- end;
- function Punkty(Killer, Victim: byte): integer;
- var c: double; c1: string; c4: integer; x, x2, x3: double;
- begin
- c := (single(strtoint(PlayerStats[Killer].Points)-strtoint(PlayerStats[Victim].Points))/1000);
- if (c >= 1) or (c <= -1) then begin
- c1 := FloatToStr(c);
- if (c > 0) then x := WowSuchASpeed(10,strtoint(Copy(c1,1,1))) else x := WowSuchASpeed(10,strtoint(Copy(c1,1,2)));
- ABP(c);
- if (Liczba >= 1) or (Liczba <= -1) then x2 := Round(WowItsEvenFaster(WowSuchASpeed(10, Liczba), Tysieczna)) else x2 := 0;
- x3 := (single(x)*single(x2));
- c4 := Round(MaxPointGive/single(1+x3));
- Result := c4;
- end else
- begin
- ABP(c);
- if (Liczba >= 1) or (Liczba <= -1) then c4 := Round(WowItsEvenFaster(WowSuchASpeed(10, Liczba), Tysieczna)) else c4 := 0;
- c4 := Round(MaxPointGive/single(1+c4));
- Result := c4;
- end;
- end;
- procedure UpdateNickname(ID: byte);
- var outdata: string;
- begin
- if (NickStatus[ID] = true) then begin
- outdata := PlayerStats[ID].Kills+CRLF+PlayerStats[ID].TeamKills+CRLF+PlayerStats[ID].Deaths+CRLF+PlayerStats[ID].DeathsByTeam+CRLF+PlayerStats[ID].SelfKills+CRLF+PlayerStats[ID].Points;
- WriteFile('nickreg/'+GetPlayerStat(ID,'HWID')+'.txt',outdata);
- LoadNickname(ID);
- end;
- end;
- procedure AutoSaveNickname(ID: byte);
- var outdata: string;
- begin
- if (FileExists('nickreg/'+GetPlayerStat(ID,'HWID')+'.txt') = false) then begin
- outdata := '0'+CRLF+'0'+CRLF+'0'+CRLF+'0'+CRLF+'0'+CRLF+PointsForStart;
- WriteFile('nickreg/'+GetPlayerStat(ID,'HWID')+'.txt',outdata);
- WriteLnFile('nickreg/server/players.db',GetPlayerStat(ID,'HWID'));
- end else WriteConsole(ID,'Nickname already exists!',BAD);
- end;
- procedure LoadRanks();
- var i: word; data: array of string;
- begin
- ranks := [];
- if (FileExists('nickreg/server/rankpoint.db')) then begin
- data := Explode(ReadFile('nickreg/server/rankpoint.db'), CRLF);
- SetArrayLength(ranks, GetArrayLength(data) div 2);
- if (GetArrayLength(ranks) > 0) then for i := 0 to GetArrayLength(ranks) - 1 do begin
- ranks[i].HWID := data[i * 2];
- ranks[i].Points := StrtoInt(data[i * 2 + 1]);
- end;
- end;
- end;
- procedure DeleteInRank(ID:byte);
- var i:word; outdata:string;
- begin
- outdata := '';
- if (GetArrayLength(ranks) > 0) then begin
- for i := 0 to GetArrayLength(ranks) - 1 do begin
- if (ranks[i].HWID = GetPlayerStat(ID,'HWID')) then if (GetArrayLength(ranks)<=1) then begin
- outdata := '';
- break;
- end else i:=i+1;
- outdata := outdata + ranks[i].HWID + CRLF + inttostr(ranks[i].Points) + CRLF;
- end;
- Delete(outdata, Length(outdata) - 1, 2);
- end;
- WriteFile('nickreg/server/rankpoint.db', outdata);
- LoadRanks();
- end;
- procedure RestartRank();
- var i: word; outdata: string; gracze, temparray: TStringArray; b: byte; n, n3: integer; n2: double;
- begin
- gracze := Explode(ReadFile('nickreg/server/players.db'),CRLF);
- n := 1;
- n3 := ((GetArrayLength(gracze)-1)+(GetArrayLength(ranks)-2));
- for i:= 2 to (GetArrayLength(gracze)-1) do begin
- if (FileExists('nickreg/'+gracze[i-1]+'.txt') = true) then begin
- n := n+1;
- temparray := Explode(ReadFile('nickreg/'+gracze[i-1]+'.txt'),CRLF);
- outdata := temparray[0]+CRLF+temparray[1]+CRLF+temparray[2]+CRLF+temparray[3]+CRLF+temparray[4]+CRLF+PointsForStart;
- WriteFile('nickreg/'+gracze[i-1]+'.txt',outdata);
- n2 := ((single(n)/single(n3))*100);
- DrawTextEx(0,73,'Restart Ranks: '+FormatFloat('0.00',n2)+'%',120,$FF0000,0.065,48,400);
- end;
- end;
- for b := 1 to 32 do if (GetPlayerStat(b, 'Active')=true) then LoadNickname(b);
- outdata := '';
- if (GetArrayLength(ranks) > 0) then begin
- for i := 0 to GetArrayLength(ranks) - 1 do begin
- n := n+1;
- outdata := outdata+ranks[i].HWID+CRLF+PointsForStart+CRLF;
- n2 := ((single(n)/single(n3))*100);
- DrawTextEx(0,73,'Restart Ranks: '+FormatFloat('0.00',n2)+'%',120,$FF0000,0.065,48,400);
- end;
- Delete(outdata, Length(outdata) - 1, 2);
- end;
- WriteFile('nickreg/server/rankpoint.db', outdata);
- LoadRanks();
- DrawTextEx(0,73,'Restart Ranks: Completed!',260,$FF0000,0.065,48,400);
- end;
- procedure SaveRanks();
- var i: word; buffer: string;
- begin
- buffer := '';
- if (GetArrayLength(ranks) > 0) then begin
- for i := 0 to GetArrayLength(ranks) - 1 do buffer := buffer + ranks[i].HWID + CRLF + InttoStr(ranks[i].Points) + CRLF;
- Delete(buffer, Length(buffer) - 1, 2);
- end;
- WriteFile('nickreg/server/rankpoint.db', buffer);
- end;
- procedure UpdateRanks(ID: byte);
- var i, j, lowpoints: integer;
- begin
- if (GetArrayLength(ranks) = 0) then lowpoints := 0 else lowpoints := ranks[GetArrayLength(ranks) - 1].Points;
- if ((strtoint(PlayerStats[ID].Points) > lowpoints) or (GetArrayLength(ranks) < rank_store)) then begin
- for i := 0 to GetArrayLength(ranks) - 1 do if (ranks[i].HWID = GetPlayerStat(ID, 'HWID')) then begin
- if (GetArrayLength(ranks) >= i + 2) then for j := i + 1 to GetArrayLength(ranks) - 1 do begin
- ranks[j - 1].HWID := ranks[j].HWID;
- ranks[j - 1].Points := ranks[j].Points;
- end;
- SetArrayLength(ranks, GetArrayLength(ranks) - 1);
- break;
- end;
- for i := 0 to GetArrayLength(ranks) - 1 do if (strtoint(PlayerStats[ID].Points) > ranks[i].Points) then break;
- SetArrayLength(ranks, GetArrayLength(ranks) + 1);
- if (GetArrayLength(ranks) >= i + 2) then for j := GetArrayLength(ranks) - 1 downto i + 1 do begin
- ranks[j].HWID := ranks[j - 1].HWID;
- ranks[j].Points := ranks[j - 1].Points;
- end;
- ranks[i].HWID := GetPlayerStat(ID, 'HWID');
- ranks[i].Points := strtoint(PlayerStats[ID].Points);
- end;
- end;
- procedure ResetPlayerStats(ID: byte);
- var outdata: string;
- begin
- outdata := '0'+CRLF+'0'+CRLF+'0'+CRLF+'0'+CRLF+'0'+CRLF+PointsForStart;
- WriteFile('nickreg/'+GetPlayerStat(ID,'HWID')+'.txt',outdata);
- LoadNickname(ID);
- DeleteInRank(ID);
- end;
- procedure RestartAllPlayerStats();
- var gracze, temparray: TStringArray; i, n, n3: word; outdata: string; b: byte; n2: double;
- begin
- gracze := Explode(ReadFile('nickreg/server/players.db'),CRLF);
- n := 1;
- n3 := ((GetArrayLength(gracze)-1)+(GetArrayLength(ranks)-2));
- for i:= 1 to (GetArrayLength(gracze)-1) do begin
- if (FileExists('nickreg/'+gracze[i-1]+'.txt') = true) then begin
- n := n+1;
- temparray := Explode(ReadFile('nickreg/'+gracze[i-1]+'.txt'),CRLF);
- outdata := '0'+CRLF+'0'+CRLF+'0'+CRLF+'0'+CRLF+'0'+CRLF+PointsForStart;
- WriteFile('nickreg/'+gracze[i-1]+'.txt',outdata);
- n2 := ((single(n)/single(n3))*100); //Dominik
- DrawTextEx(0,73,'Restart all players stats: '+FormatFloat('0.00',n2)+'%',120,$FF0000,0.065,48,400);
- end;
- end;
- for b := 1 to 32 do if (GetPlayerStat(b, 'Active')=true) then LoadNickname(b);
- outdata := '';
- if (GetArrayLength(ranks) > 0) then begin
- for i := 0 to GetArrayLength(ranks) - 1 do begin
- n := n+1;
- outdata := outdata + ranks[i].HWID + CRLF + PointsForStart + CRLF;
- n2 := ((single(n)/single(n3))*100);
- DrawTextEx(0,73,'Restart all players stats: '+FormatFloat('0.00',n2)+'%',120,$FF0000,0.065,48,400);
- end;
- Delete(outdata, Length(outdata) - 1, 2);
- end;
- WriteFile('nickreg/server/rankpoint.db', outdata);
- LoadRanks();
- DrawTextEx(0,73,'Restart all players stats: Completed!',260,$FF0000,0.065,48,400);
- end;
- function OnCommand(ID: Byte; Text: string): boolean;
- var i: byte;
- begin
- if (lowercase(Text) = lowercase('/ResetAllPlayerStats')) then begin
- RestartAllPlayerStats();
- WriteConsole(0,'Restarted statistics of all players.',GOOD);
- end;
- if (lowercase(Text) = lowercase('/UpdateStats')) then begin
- for i := 1 to 32 do if (GetPlayerStat(i, 'Active') = true) then begin
- UpdateNickname(i);
- if (GetPlayerStat(i, 'Human') = true) then UpdateRanks(i);
- SaveRanks();
- WriteConsole(i,'Update Stats!',GOOD);
- end;
- end;
- if MaskCheck(lowercase(Text),'/ResetStatsID *') then begin
- if (GetPiece(Text,' ',1) <> '') then begin
- try
- if (GetPlayerStat(strtoint(GetPiece(Text,' ',1)),'Active') = true) then begin
- if (FileExists('nickreg/'+GetPlayerStat(strtoint(GetPiece(Text,' ',1)),'HWID')+'.txt') = true) then begin
- ResetPlayerStats(strtoint(GetPiece(Text,' ',1)));
- WriteConsole(ID,'Restarted player statistics '+GetPlayerStat(strtoint(GetPiece(Text,' ',1)),'Name')+'.',GOOD);
- end else WriteConsole(ID,'The player does not have an account.',BAD);
- end else WriteConsole(ID,'None such player.',BAD);
- except WriteConsole(ID,'ID an incorrect.',BAD);
- end;
- end else WriteConsole(ID,'Not given ID.',BAD);
- end;
- if (lowercase(Text) = lowercase('/AdminCommands')) then begin
- WriteConsole(ID,'___Admin Commands:______________________________________',GOOD);
- WriteConsole(ID,'/UpdateStats - Quick update statistics |',GOOD);
- WriteConsole(ID,'/ResetRanks - Restarts ranks |',GOOD);
- WriteConsole(ID,'/ResetAllPlayerStats - Restarts all players stats |',GOOD);
- WriteConsole(ID,'/ResetStatsID <ID> - Reset stats player (ID) |',GOOD);
- WriteConsole(ID,'_______________________________________________________|',GOOD);
- end;
- if (lowercase(Text) = lowercase('/ResetRanks')) then begin
- RestartRank();
- WriteConsole(0,'Restart ranks!',GOOD);
- end;
- Result := false;
- end;
- function OnPlayerCommand(ID: Byte; Text: string): boolean;
- begin
- if regExpMatch('^/(resetstats|restartstats)$',lowercase(Text)) then begin
- if (NickStatus[ID] = true) then begin
- ResetPlayerStats(ID);
- WriteConsole(ID,'Restarted your stats!',GOOD);
- end else WriteConsole(ID,'Login to restart your stats!',GOOD);
- end;
- Result := false;
- end;
- procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
- var x: integer;
- begin
- if (Killer = Victim) then PlayerStats[Victim].SelfKills := inttostr(strtoint(PlayerStats[Victim].SelfKills) + 1);
- if (killer <> victim) then begin
- if (GetPlayerStat(Killer, 'Active') = true) then begin
- if (GetPlayerStat(Killer,'team')<>GetPlayerStat(Victim,'team')) then begin
- PlayerStats[Killer].Kills := inttostr(strtoint(PlayerStats[Killer].Kills) + 1);
- x := Punkty(Killer, Victim);
- PlayerStats[Killer].Points := inttostr(strtoint(PlayerStats[Killer].Points) + x);
- PlayerStats[Victim].Points := inttostr(strtoint(PlayerStats[Victim].Points) - x);
- end;
- if (GetPlayerStat(Killer,'team')=GetPlayerStat(Victim,'team')) then begin
- if (GameStyle = 1) and (GetPlayerStat(Killer, 'Flagger')) then PlayerStats[Killer].TeamKills := inttostr(strtoint(PlayerStats[Killer].TeamKills) +2) else PlayerStats[Killer].TeamKills := inttostr(strtoint(PlayerStats[Killer].TeamKills) + 1);
- if (GameStyle = 0) or (GameStyle = 1) or (GameStyle = 4) then begin
- x := Punkty(Killer, Victim);
- PlayerStats[Killer].Points := inttostr(strtoint(PlayerStats[Killer].Points) + x);
- PlayerStats[Victim].Points := inttostr(strtoint(PlayerStats[Victim].Points) - x);
- end;
- end;
- end;
- if (GetPlayerStat(victim, 'Active') = true) then begin
- PlayerStats[Victim].Deaths := inttostr(strtoint(PlayerStats[Victim].Deaths) + 1);
- if (GameStyle = 2) or (GameStyle = 3) or (GameStyle = 5) or (GameStyle = 6) then if (GetPlayerStat(Victim,'Team') = GetPlayerStat(Killer,'Team')) then PlayerStats[Victim].DeathsByTeam := inttostr(strtoint(PlayerStats[Victim].DeathsByTeam) + 1);
- end;
- end;
- UpdateNickname(Killer);
- UpdateNickname(Victim);
- if (GetPlayerStat(killer, 'Active') = true) then if (NickStatus[Killer]) then begin
- if (GetPlayerStat(killer, 'Human') = true) then UpdateRanks(killer);
- SaveRanks();
- end;
- if (GetPlayerStat(Victim, 'Active') = true) then if (NickStatus[Victim]) then begin
- if (GetPlayerStat(Victim, 'Human') = true) then UpdateRanks(Victim);
- SaveRanks();
- end;
- end;
- procedure OnMapChange(NewMap: String);
- var i: byte;
- begin
- for i := 1 to 32 do if (GetPlayerStat(i, 'Active') = true) then begin
- if (NickStatus[i]) then begin
- if (GetPlayerStat(i,'Human') = true) then UpdateRanks(i);
- SaveRanks();
- UpdateNickname(i);
- end;
- end;
- end;
- procedure PokazTop(const ID: byte);
- var i, High: integer;
- begin
- if (GetArrayLength(ranks) > 0) then begin
- if (GetArrayLength(ranks) < 5) then high := GetArrayLength(ranks) - 1 else high := 5 - 1;
- WriteConsole(0, 'Top ' + InttoStr(high + 1) + ' ranked players:', GOOD);
- for i := 0 to high do WriteConsole(0, InttoStr(i + 1) + '. ' + ranks[i].HWID + ' - ' + InttoStr(ranks[i].Points) + ' pts.', GOOD); //By
- end else WriteConsole(ID, 'No players are ranked yet.', BAD);
- end;
- procedure PokazTopID(ID: byte; csa: integer);
- var b, High: integer;
- begin
- if (GetArrayLength(ranks) > 0) then begin
- if (csa<=30) and (csa>0) then begin
- if (GetArrayLength(ranks) < csa) then high := GetArrayLength(ranks) - 1 else high := csa - 1;
- WriteConsole(ID, 'Top ' + InttoStr(high + 1) + ' ranked players:', GOOD);
- for b := 0 to high do WriteConsole(ID, InttoStr(b + 1) + '. ' + ranks[b].HWID + ' - ' + InttoStr(ranks[b].Points) + ' pts.', GOOD);
- end else WriteConsole(ID,'The maximum top is 30 players.',BAD);
- end else WriteConsole(ID, 'No players are ranked yet.', BAD);
- end;
- procedure RankTXT(ID: byte; text: string);
- var b, op: integer; tr: byte;
- begin
- if (text = '') then begin
- if (FileExists('nickreg/'+GetPlayerStat(ID, 'HWID')+'.txt') = true) then begin
- if (NickStatus[ID] = true) then begin
- if (GetArrayLength(ranks) > 0) then for b := 0 to GetArrayLength(ranks) - 1 do if (ranks[b].HWID = GetPlayerStat(ID, 'HWID')) then begin
- WriteConsole(0,'Player '+GetPlayerStat(ID,'name')+' is a '+InttoStr(b + 1)+' in the ranking of '+PlayerStats[ID].Points+' pts.', GOOD);
- exit;
- end;
- end else WriteConsole(ID,'Login to see the stats!',BAD);
- end else WriteConsole(ID,'Please register! For instructions type: !reginfo',BAD);
- end else
- begin
- op := StrToID(Text); tr := 0;
- if (FileExists('nickreg/'+Text+'.txt') = true) then tr := 1 else if (op = 254) then WriteConsole(ID,'Player not found ('+Text+')',BAD) else if (FileExists('nickreg/'+getPlayerStat(op,'HWID')+'.txt') = true) then tr := 2;
- if (tr = 1) or (tr = 2) then begin
- if (GetArrayLength(ranks) > 0) then for b := 0 to GetArrayLength(ranks) - 1 do if (ranks[b].HWID = iif(tr=1,text,getPlayerStat(op,'HWID'))) then begin
- if (GetArrayLength(ranks) > b) and (b >= 0) then WriteConsole(ID,'Player '+ranks[b].HWID+' is a '+inttostr(b+1)+' in the ranking of '+InttoStr(ranks[b].Points)+' pts.', GOOD) else WriteConsole(ID,'There is no player in that position in the ranking.',BAD);
- end;
- end;
- end;
- end;
- Procedure Stats(ID: byte);
- var i: integer; KD: double;
- begin
- if (GameStyle = 2) or (GameStyle = 3) or (GameStyle = 5) or (GameStyle = 6) then begin
- if (strtoint(PlayerStats[ID].Kills) <> 0) and (strtoint(PlayerStats[ID].Deaths) <> 0) then begin
- if (GetArrayLength(ranks) > 0) then for i := 0 to GetArrayLength(ranks) - 1 do if (ranks[i].HWID = GetPlayerStat(ID, 'HWID')) then begin
- KD := single(strtoint(PlayerStats[ID].Kills)) / single(strtoint(PlayerStats[ID].Deaths));
- WriteConsole(0,'Rank: ' + InttoStr(i + 1) + '/' + InttoStr(GetArrayLength(ranks)) + ', Points: '+PlayerStats[ID].Points+', K/D: '+FormatFloat('0.00',KD), GOOD);
- WriteConsole(0,'Kills: '+PlayerStats[ID].Kills+', Death: '+PlayerStats[ID].Deaths+', Selfkills: '+PlayerStats[ID].SelfKills,GOOD);
- if (FriendlyFire) then WriteConsole(0,'Teamkills: '+PlayerStats[ID].TeamKills+', Killed By Friend: '+PlayerStats[ID].DeathsByTeam,GOOD);
- exit;
- end;
- end else WriteConsole(ID,'We are sorry for the moment we have too little information about you.',BAD);
- end;
- if (GameStyle = 0) or (GameStyle = 1) or (GameStyle = 4) then begin
- if (strtoint(PlayerStats[ID].TeamKills) <> 0) and (strtoint(PlayerStats[ID].Deaths) <> 0) then begin
- if (GetArrayLength(ranks) > 0) then for i := 0 to GetArrayLength(ranks) - 1 do if (ranks[i].HWID = GetPlayerStat(ID, 'HWID')) then begin
- KD := single(strtoint(PlayerStats[ID].TeamKills)) / single(strtoint(PlayerStats[ID].Deaths));
- WriteConsole(0, 'Rank: ' + InttoStr(i + 1) + '/' + InttoStr(GetArrayLength(ranks)) + ', Points: '+PlayerStats[ID].Points+', K/D: '+FormatFloat('0.00',KD), GOOD);
- WriteConsole(0,'Kills: '+PlayerStats[ID].TeamKills+', Death: '+PlayerStats[ID].Deaths+', Selfkills: '+PlayerStats[ID].SelfKills,GOOD);
- exit;
- end;
- end else WriteConsole(ID,'We are sorry for the moment we have too little information about you.',BAD);
- end;
- end;
- Procedure StatsOther(ID:byte; Text:string);
- var op: integer; temparray: TStringArray; KD: double; i: word;
- begin
- op := StrToID(Text);
- if (op = 254) then WriteConsole(ID,'Player not found ('+Text+')',BAD) else begin
- temparray := Explode(ReadFile('nickreg/'+GetPlayerStat(op,'HWID')+'.txt'),CRLF);
- if (GameStyle = 2) or (GameStyle = 3) or (GameStyle = 5) or (GameStyle = 6) then begin
- if (strtoint(temparray[0]) <> 0) and (strtoint(temparray[2]) <> 0) then begin
- if (GetArrayLength(ranks) > 0) then for i := 0 to GetArrayLength(ranks) - 1 do if (ranks[i].HWID = GetPlayerStat(op,'HWID')) then begin
- WriteConsole(ID,'Player statistics '+getPlayerStat(op,'Name')+':',GOOD);
- KD := single(strtoint(temparray[0])) / single(strtoint(temparray[2]));
- WriteConsole(ID,'Rank: ' + InttoStr(i + 1) + '/' + InttoStr(GetArrayLength(ranks)) + ', Points: '+temparray[5], GOOD);
- WriteConsole(ID,'Kills: '+temparray[0]+', Death: '+temparray[2]+', Selfkills: '+temparray[4]+', K/D: '+FormatFloat('0.00',KD),GOOD);
- if (FriendlyFire) then WriteConsole(ID,'Teamkills: '+temparray[1]+', Killed By Friend: '+temparray[3],GOOD);
- exit;
- end;
- end else WriteConsole(ID,'Have too enough information about this player.',BAD);
- end;
- if (GameStyle = 0) or (GameStyle = 1) or (GameStyle = 4) then begin
- if (strtoint(temparray[1]) <> 0) AND (strtoint(temparray[2]) <> 0) then begin
- if (GetArrayLength(ranks) > 0) then for i := 0 to GetArrayLength(ranks) - 1 do if (ranks[i].HWID = GetPlayerStat(op,'HWID')) then begin
- WriteConsole(ID,'Player statistics '+getPlayerStat(op,'Name')+':',GOOD);
- KD := single(strtoint(temparray[1])) / single(strtoint(temparray[2]));
- WriteConsole(ID,'Rank: ' + InttoStr(i + 1) + '/' + InttoStr(GetArrayLength(ranks)) + ', Points: '+temparray[5],GOOD);
- WriteConsole(ID,'Kills: '+temparray[1]+', Death: '+temparray[2]+', Selfkills: '+temparray[4]+', K/D: '+FormatFloat('0.00',KD),GOOD);
- exit;
- end;
- end else WriteConsole(ID,'Have too enough information about this player.',BAD);
- end;
- end;
- end;
- procedure AppOnIdle(Ticks: integer);
- begin
- if Ticks mod (3600 * 6) = 0 then WriteConsole(0, 'Enter !reginfo to see command. Information: !contact', GOOD);
- end;
- procedure OnPlayerSpeak(ID: byte; Text: string);
- var gracze: TStringArray;
- begin
- if regExpMatch('^!(top)$',lowercase(Text)) then PokazTop(ID) else if MaskCheck(lowercase(Text),'!top *') then PokazTopID(ID,strtoint(Copy(Text,6,Length(Text))));
- if regExpMatch('^!(rank)$',lowercase(Text)) then RankTXT(ID,Copy(Text,7,Length(Text))) else if MaskCheck(lowercase(Text),'!rank *') then RankTXT(ID,Copy(Text,7,Length(Text)));
- if regExpMatch('^!(stats|raning|statystyki)$',lowercase(Text)) then Stats(ID) else if MaskCheck(Text,'!stats *') then StatsOther(ID,Copy(Text,8,Length(Text)));
- if regExpMatch('^!(reginfo)$',lowercase(Text)) then begin
- WriteConsole(ID,'____Stats Commands___________________________________________',GOOD);
- WriteConsole(ID,'!stats | !stats <ID,Name,PartName> | !top | !top <number> |',GOOD);
- WriteConsole(ID,'!rank | !rank <ID,Name,PartName | !zitro | /resetstats |',GOOD);
- WriteConsole(ID,'_______|___________________________|________|_______________|',GOOD);
- end;
- if regExpMatch('^!(autor|author|credit|credits|contact|tworca|info|help|zitrofun|zitro|fun)$',lowercase(Text)) then begin
- WriteConsole(ID,'Author scripts: dominikk26',GOOD);
- WriteConsole(ID,'E-mail: dominikk262@wp.pl',GOOD);
- WriteConsole(ID,YouInfo,GOOD);
- WriteConsole(ID,'Script Version: '+ZitroVersion,GOOD);
- gracze := Explode(ReadFile('nickreg/server/players.db'),CRLF);
- WriteConsole(ID,'Registered players: '+inttostr(GetArrayLength(gracze)-2),GOOD);
- end;
- end;
- Procedure OnJoinTeam(ID, Team: byte);
- var i: byte;
- begin
- if (GetPlayerStat(ID,'Human') = true) then begin
- for i := 1 to 32 do if (GetPlayerStat(i,'Active') = true) then if (GetPlayerStat(i,'HWID') = GetPlayerStat(ID,'HWID')) and (i<>ID) then begin
- WriteConsole(ID,'Please stop buggs! You can not, go two accounts per server at a time.',BAD);
- WriteConsole(0,'[ZitroFUN] I detected two players with the same HWID, '+GetPlayerStat(i,'Name')+' and '+GetPlayerStat(ID,'Name'),BAD);
- KickPlayer(ID);
- end;
- end;
- end;
- Procedure AutoRegLog(ID: byte);
- begin
- if (FileExists('nickreg/'+GetPlayerStat(ID,'HWID')+'.txt') = false) and (GetPlayerStat(ID,'Human') = true) then begin
- AutoSaveNickname(ID);
- LoadNickname(ID);
- WriteConsole(ID,'HWID: ' + GetPlayerStat(ID,'HWID') + ' successfully registered!',GOOD);
- WriteConsole(ID,'Type !reginfo to see the available commands!',GOOD);
- WriteLn('HWIDReg: ' + GetPlayerStat(ID,'name') + ' registered from ' + GetPlayerStat(ID,'HWID'));
- NickStatus[ID] := true;
- end;
- end;
- procedure AutoLogin(ID: byte);
- begin
- if (length(getPlayerStat(ID, 'name' )) > 24) then begin
- WriteConsole(ID,'...your name is over 24 characters, please change it.',BAD);
- KickPlayer(ID); Exit;
- end;
- if (FileExists('nickreg/'+GetPlayerStat(ID,'HWID')+'.txt')=true) then begin
- LoadNickname(ID);
- NickStatus[ID] := true;
- WriteConsole(ID,'Welcome back '+GetPlayerStat(ID,'name')+' (HWID: '+GetPlayerStat(ID,'HWID')+')',GOOD);
- if (NickStatus[ID]) then begin
- if (GetPlayerStat(ID,'Human') = true) then UpdateRanks(ID);
- SaveRanks();
- end;
- end else AutoRegLog(ID);
- end;
- procedure OnJoinGame(ID, Team: byte);
- begin
- LoadNickname(ID);
- if (GetPlayerStat(ID,'Human')=True) then AutoLogin(ID);
- end;
- procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
- begin
- if (NickStatus[ID] = true) then begin
- if (GetPlayerStat(ID, 'Human') = true) then UpdateRanks(ID);
- SaveRanks();
- UpdateNickname(ID);
- ResetVar(ID);
- end;
- end;
- procedure ActivateServer();
- var b: byte;
- begin
- if (ReadINI('soldat.ini','GAME','Friendly_Fire','0') = '1') then FriendlyFire:=true else FriendlyFire:=false;
- if (FileExists('nickreg/server/players.db') = false) then WriteLnFile('nickreg/server/players.db','[PlayersList]');
- WriteConsole(0, 'ZitroFun '+ZitroVersion+' recompiled - successfully :)', $FFFFAA00);
- LoadRanks();
- for b := 1 to 32 do begin
- ResetVar(b);
- if (GetPlayerStat(b,'Active')=true) then begin
- LoadNickname(b);
- AutoLogin(b);
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement