Created
June 15, 2017 17:06
-
-
Save anonymous/0f9784d0e5b3c101a926da7eee1bb76c to your computer and use it in GitHub Desktop.
ZitroFUN 2.0.0 Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit ZitroStats; | |
interface | |
implementation | |
const | |
DefaultAutoLogin = 'HWID'; //Default: HWID, string; To choose HWID, IP, NAME, OFF, NAME - Means that everyone with that name will be able to login, OFF - Player will always have to login manually using /login <password>. | |
PatchCore = 'nickreg\'; //Default: 'nickreg\', string; Data storage path. Remember to finish "\". | |
BackupPatch = 'nickreg\backup\'; //Default: 'nickreg\backup\', string; Backup storage path. Remember to finish "\". | |
ScriptVersion = '1.9.4 - Beta'; // !DONT EDIT! | |
YouInfo = 'https://forums.soldat.pl/'; //Default: ''; string; Your line of text that appears after typing !contact !zitro !zitrofun. | |
RegInfoTime = 4; //Default: 4; non-negative integer; Time in minutes. Time as much information will appear to type !reginfo. | |
TopLines = 15; //Default: 15; non-negative integer; How many players will be displayed after typing !top or !top <num>. | |
MaxCreatedAccounts = 2; //Default: 2; non-negative integer; How many accounts can create up. 0 to off. | |
GOOD = $66CC66; //Default: $66CC66, longint; Good color. | |
BAD = $CC3300; //Default: $CC3300, longint; Bad color. | |
Top1PlayerC = $FFD700; //Default: $FFD700, longint; Top 1 lines display color. | |
Top2PlayerC = $C0C0C0; //Default: $C0C0C0, longint; Top 2 lines display color. | |
Top3PlayerC = $cc6633; //Default: $cc6633, longint; Top 3 lines display color. | |
YourPosCollorInTop = $33FF33; //Default: $33FF33, longint; Your poss lines display color. | |
MidEndCollor = $99FF99; //Default: $99FF99, longint; Center lines in top color. | |
IndicatedCollor = $99FF00; //Default: $99FF00, longint; Indicated lines in top color. | |
MinimalKills = 25; //Default: 25, non-negative integer; The minimum number of killings to be ranked and be able to view your statistics. 0 to off. | |
AutoRegister = 1; //Default: 1, integer in range 0..1; Automatic registration 0 - off, 1 - on. | |
DeepSearch = 1; //Default: 1, integer in range 0..1; Shows all player accounts when they can not register, or 0 = only shows value of MaxCreatedAccounts other accounts. | |
KickTime = 15; //Default: 15, non-negative integer; Time in seconds. Time after which the player is not logged kick from the game. | |
MaxSearchLines = 4; //Default: 4, non-negative integer; Maximum number of lines to display search results after using /search <phrase>. | |
DataLinesNum = 10; //Default: 10; non-negative integer; !DONT EDIT! !DONT EDIT! !DONT EDIT! Dont read iff you can not program --> Or change if you added some own statistics using the new dataline. | |
ServerLogsLostPack = 99; //Default: 99; non-negative integer; Set high if the server frequently reboots 99 means that less than <=99 times a day. | |
AutoBackupTime = 1440; //Default: 1440; non-negative integer; Value given in minutes 60 = 1h, 1440 = 1day, 10080 = 7 day, 40320 = 1 month. | |
SaveMemoryPriority = 1; //Default: 1; integer in range 0..5; 0 - If map change. 1 - If player leave (Using 0). 2 - If flag score (Using 0, 1), 3 - If player kill (Using 0, 1, 2). 4 - If player damage (Using 1, 2, 3). 5 - If players shoot (Using 1, 2, 3, 4). | |
HyperSafePass = false; //Default: false, true or false; If true this clear logs from player confidential data and passwords. Cleans at specified times specified in HyperSafePassTime or if map change. | |
HyperSafePassTime = 120; //Default: 120; Time in seconds to clear logs as from player confidential data and passwords. | |
HyperSafePassOnlyMapChange = false; //Default: false, true or false; If true this clear logs only if map is change. If true time clearlogs is off. | |
BigTextLayer = 10; //Default 10, byte in range 1..255; All time is +5 example 10 is 10+5 and result using 10-15 layers. Change if bites with other scripts. | |
BigTextTime = 200; //Default 200, non-negative integer; Time to appear for temporary big text on screen. | |
BigTextTimeScreenInfo = 132; //Default 132, non-negative integer; Time in ticket (1~0.06sec 60=1sec). The time that will be displayed on-screen text. It is better not to move unless you want to produce a longer effect or transparancy effect. | |
SelfKillLostOnPlayer = 1; //Default: 1, non-negative integer; That player loses points for every enemy logged if committed selfkill. Points go into the pot and are distributed to the opposing team. | |
SaviorTime = 3; //Default: 3, non-negative integer; Time in seconds. If you kill an enemy who has attacked friendly and savior time >0 you give savior kill. This is the time after which the opportunity expires if this friendly doesn`t get hurt. | |
AvengerTime = 2; //Default: 2, non-negative integer; Time in seconds. Time after which the enemy who killed your friendly, after this time kill this enemy you can not gave avenger. | |
AssistMinimumDamagePercent = 65; //Default: 65, integer in range 1..100, The percentage of health that a player has to hurt the enemy, to get assit, if someone else kills him. | |
AssistTime = 8; //Default: 8, non-negative integer; Time in seconds. Time after which the last injury, expires to be assist. | |
CapGivePointsForEnemy = 4; //Default: 4, non-negative integer; Points that go to the pot for each enemy that is logged. | |
CapperPointsPrecent=70; //Default: 70, integer in range 1..100; the percentage value of how many points from the pot will be awarded to the person who cap. The rest of the pool is divided and awarded to the team. | |
PointsForStart = 1000; //Default: 1000, non-negative integer; Starting points, points that the player receives after registration. | |
MaxPointGive = 75; //Default: 75, non-negative integer; Maximum number of points that can be earned. | |
DzielnaElo = 1000; //Formuła ELO. Points = MaxPointGive / (MinimalElo + (DzielnaElox2 ^ ((Player_Killer_Points - Player_Victim_Points) / DzielnaElo))) | |
DzielnaElox2 = 10; //Default: 10, non-negative integer; | |
MinimalElo = 1; //Default: 1, non-negative integer; | |
Multiplier = 100; //Default: 100, non-negative integer; Accuracy of player rating. | |
PlayerRateRankCountMin = 10;//Default: 10, non-negative integer; The required number of players in the ranking to use points and the number of players in the ranking in the player rating. | |
CheckOnLeave = false; //Default: false (because it would balance too often on public servers), true or false; If true, it will check balance when someone leaves the server. | |
KeepTeamScore = false; //Default: false, true or false; If true, it restore team's score after all its players leave (Soldat clears it by default). | |
SwapCountsFlags = false; //Default: false, true or false; If true, player's captures are counted, and players with one or more caps are not preferred during choosing. If false, automatic swap will ignore number of caps the chosen player has, and just choose whoever fits the balance. | |
SwapLimit = 2; //Default: 2, non-negative integer; Specifies the maximum number of swaps per map. If it's reached and current status would result in another swap, it will say that teams are balanced. Set 0 for unlimited swaps. | |
TriggerLimit = 2; //Default: 2, integer; Specifies the maximum number of team-changing trigger uses (e.g. !alpha, !2). Only affects the built-in triggers, so using the Esc-menu isn't limited. Resets after map change. Set -1 to disable those triggers. Set 0 for no limits. | |
Interval = 3; //Default: 3, non-negative integer; Time in minutes between automatic balance checks. If someone manually requested the balance check, timer is reset. Set 0 to disable automatic balance checks. | |
ImmuneTime = 20; //Default: 20, non-negative integer; Time in minutes, specifying the immunity from balance. The player won't be moved again during this time, except it's really necessary (e.g. all other players have been moved recently). Set 0 to disable immunity time. Bad idea. | |
LockTime = 2; //Default: 2, non-negative integer; Time in minutes, during which the recently moved player can't change the team again. They still can go to spec, or join the weaker team out of their own will. It just won't let them go back to the stronger team. Set 0 to disable. | |
HardBalTimes = 8; //Default: 8, non-negative integer; Time in minutes, time limitation for the command !hardbal, which mixes and distributes teams so that the score is evenly matched. | |
Method = 8; //Default: 8, integer in range 1..9, Specifies the default method of choosing players to move. Possible options: | |
// 1: Completely random player. 2: Player with fewest kills. 3: Player with fewest caps. | |
// 4: Player with worst K/D ratio. 5: Player with fewest kills and no caps. 6: Player with worst K/D and no caps. | |
// 7: Random player with no caps. 8: Player with fewest zitrofun points. 9: Player with fewest zitrofun points AND no caps. | |
type TPlayerInfo = record | |
AssistDamageMade: array[1..32] of single; | |
SaviorTimer, AvengerTimer, AssistCooldown: array[1..32] of integer; | |
EventsDisplay: array of string; | |
Revenge: array[1..32] of boolean; | |
KickTimer, lock, immune: integer; | |
NickStatus, movedByScript: boolean; | |
Ammo, prevteam, triggers: byte; | |
end; | |
type tbal = record | |
mode, restoreDelay: shortint; | |
justLeft: boolean; | |
numberGlobal, lastbalance, lastcheck, hardbaltime: integer; | |
numberMap, swaps, tempAlphaScore, tempBravoScore, maxBalances, smallerTeam: byte; | |
end; | |
var | |
Memory, TempRank, AllPlayers, TempPlayersList: TStringList; | |
PlayerInfo: array [1..32] of TPlayerInfo; | |
bal: tbal; | |
MaxHealth: single; | |
MinDiff, SwapDiff: byte; | |
function Exp(X: double): double; | |
var m, n: integer; r, fac, pow: double; | |
begin | |
m:=Round(Abs(X/10)); | |
if m >= 2 then X:=X/m; | |
Result:=1+X; | |
fac:=1; | |
pow:=X; | |
n:=2; | |
r:=1; | |
while r>1e-8 do begin | |
fac:=fac*n; | |
pow:=pow*X; | |
n:=n+1; | |
r:=pow/fac; | |
Result:=Result+r; | |
end; | |
if m >= 2 then begin | |
pow:=Result; | |
for n:=2 to m do Result:=Result*pow; | |
end; | |
end; | |
function Power(Base: double; Exponent: double): double; | |
begin | |
Result:=Exp(LogN(2.71828182846, Base)*Exponent); | |
end; | |
function MD5Issue(const S: string): string; | |
begin | |
while (not(ExecRegExpr('^[0-9a-f]{32}$', Result))) do begin | |
Result:= MD5String(S); | |
end; | |
end; | |
procedure CreateMemory(); | |
var Temp: TStringList; | |
begin | |
Temp := File.CreateStringList(); | |
Temp.SaveToFile(PatchCore+'accounts.db'); | |
Temp.Free; | |
Memory := File.CreateStringListFromFile(PatchCore+'accounts.db'); | |
end; | |
procedure AddNewPlayerToMemory(Player: TActivePlayer; Password:string); | |
var i, TempIndexID: int64; Len:integer; | |
begin | |
Memory.Append('%name%'+Player.Name); | |
Memory.Append(Password); | |
Memory.Append(Player.HWID+'%ip%'+Player.IP); | |
Memory.Append(inttostr(PointsForStart)); | |
Memory.Append(FormatDate('dd mmmm yyyy')+' at: '+FormatDate('hh:nn:ss')+'%lp%'+FormatDate('dd mmmm yyyy')+' at: '+FormatDate('hh:nn:ss')); //Register date:Last play date | |
Memory.Append('0%first%0%autologin%'+lowercase(DefaultAutoLogin)+'%mail%'); //FirstUseageCommand !login:AutoLoginType:Mail | |
Memory.Append('0%k%0%d%0%s%0%t%0%dt%0%p%0%a%0%r%0%z%0%w%0'); //Kills:Deaths:SelfKills:TeamKills:DeathsByTeam:PostromusKill:Assist:RevengeKills:Avenger:Wybawiel:FlagerKills | |
Memory.Append('0%fg%0%fr%0%fs%0%fd%0%ac%0%bc%0%ir%0%ib%0%hr%0%ft%0'); //FlagGrab:FlagReturn:FlagScore:FlagDrop:AlphaCaps:BravoCaps:INF_Red:INF_Blue:HTF_Red:HTF_Blue:FlagThrown | |
Memory.Append('0%w%0%l%0%r%0%aw%0%al%0%bw%0%bl%0%cw%0%cl%0%dw%0'); //Win:Lose:Remis:AlphaWins:AlphaLose:BravoWins:BravoLose:CharlieWin:CharlieLose:DeltaWin:DeltaLose | |
Memory.Append('0%s%0%sh%0'); //Shoots:ShootHits:ShootFriendly | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
Len := Length(Player.Name); | |
for i := TempPlayersList.Count-1 downto 0 do if (strtoint(GetPiece(TempPlayersList[i],':',0))=Len) then begin | |
TempPlayersList.Insert(i,inttostr(Len)+':'+inttostr(TempIndexID)+'%name%'+LowerCase(Player.Name)); | |
break; | |
end; | |
end; | |
function ReadPlayer(Num:int64;What:string):string; | |
begin | |
Result:='null'; | |
What:=lowercase(what); | |
case What of | |
'name' : Result:=GetPiece(Memory[Num],'%name%',1); | |
'password' : Result:=Memory[Num+1]; | |
'hwid' : Result:=GetPiece(Memory[Num+2],'%ip%',0); | |
'ip' : Result:=GetPiece(Memory[Num+2],'%ip%',1); | |
'points' : Result:=Memory[Num+3]; | |
'registerdate' : Result:=GetPiece(Memory[Num+4],'%lp%',0); | |
'lastplay' : Result:=GetPiece(Memory[Num+4],'%lp%',1); | |
'bigtext' : Result:=GetPiece(Memory[Num+5],'%first%',0); | |
'firstuse' : Result:=GetPiece(GetPiece(Memory[Num+5],'%first%',1),'%autologin%',0); | |
'autologin' : Result:=GetPiece(GetPiece(Memory[Num+5],'%autologin%',1),'%mail%',0); | |
'mail' : Result:=GetPiece(Memory[Num+5],'%mail%',1); | |
'kills' : Result:=GetPiece(Memory[Num+6],'%k%',0); | |
'deaths' : Result:=GetPiece(GetPiece(Memory[Num+6],'%k%',1),'%d%',0); | |
'selfkills' : Result:=GetPiece(GetPiece(Memory[Num+6],'%d%',1),'%s%',0); | |
'teamkills' : Result:=GetPiece(GetPiece(Memory[Num+6],'%s%',1),'%t%',0); | |
'deathsbyteam' : Result:=GetPiece(GetPiece(Memory[Num+6],'%t%',1),'%dt%',0); | |
'postromuskill' : Result:=GetPiece(GetPiece(Memory[Num+6],'%dt%',1),'%p%',0); | |
'assist' : Result:=GetPiece(GetPiece(Memory[Num+6],'%p%',1),'%a%',0); | |
'revengekills' : Result:=GetPiece(GetPiece(Memory[Num+6],'%a%',1),'%r%',0); | |
'avenger' : Result:=GetPiece(GetPiece(Memory[Num+6],'%r%',1),'%z%',0); | |
'wybawiel' : Result:=GetPiece(GetPiece(Memory[Num+6],'%z%',1),'%w%',0); | |
'flagerkills' : Result:=GetPiece(Memory[Num+6],'%w%',1); | |
'flaggrab' : Result:=GetPiece(Memory[Num+7],'%fg%',0); | |
'flagreturn' : Result:=GetPiece(GetPiece(Memory[Num+7],'%fg%',1),'%fr%',0); | |
'flagscore' : Result:=GetPiece(GetPiece(Memory[Num+7],'%fr%',1),'%fs%',0); | |
'flagdrop' : Result:=GetPiece(GetPiece(Memory[Num+7],'%fs%',1),'%fd%',0); | |
'alphacaps' : Result:=GetPiece(GetPiece(Memory[Num+7],'%fd%',1),'%ac%',0); | |
'bravocaps' : Result:=GetPiece(GetPiece(Memory[Num+7],'%ac%',1),'%bc%',0); | |
'inf_red' : Result:=GetPiece(GetPiece(Memory[Num+7],'%bc%',1),'%ir%',0); | |
'inf_blue' : Result:=GetPiece(GetPiece(Memory[Num+7],'%ir%',1),'%ib%',0); | |
'htf_red' : Result:=GetPiece(GetPiece(Memory[Num+7],'%ib%',1),'%hr%',0); | |
'htf_blue' : Result:=GetPiece(GetPiece(Memory[Num+7],'%hr%',1),'%ft%',0); | |
'flagthrown' : Result:=GetPiece(Memory[Num+7],'%ft%',1); | |
'wins' : Result:=GetPiece(Memory[Num+8],'%w%',0); | |
'lose' : Result:=GetPiece(GetPiece(Memory[Num+8],'%w%',1),'%l%',0); | |
'remis' : Result:=GetPiece(GetPiece(Memory[Num+8],'%l%',1),'%r%',0); | |
'alphawins' : Result:=GetPiece(GetPiece(Memory[Num+8],'%r%',1),'%aw%',0); | |
'alphalose' : Result:=GetPiece(GetPiece(Memory[Num+8],'%aw%',1),'%al%',0); | |
'bravowins' : Result:=GetPiece(GetPiece(Memory[Num+8],'%al%',1),'%bw%',0); | |
'bravolose' : Result:=GetPiece(GetPiece(Memory[Num+8],'%bw%',1),'%bl%',0); | |
'charliewin' : Result:=GetPiece(GetPiece(Memory[Num+8],'%bl%',1),'%cw%',0); | |
'charlielose' : Result:=GetPiece(GetPiece(Memory[Num+8],'%cw%',1),'%cl%',0); | |
'deltawin' : Result:=GetPiece(GetPiece(Memory[Num+8],'%cl%',1),'%dw%',0); | |
'deltalose' : Result:=GetPiece(Memory[Num+8],'%dw%',1); | |
'shoots' : Result:=GetPiece(Memory[Num+9],'%s%',0); | |
'shoothits' : Result:=GetPiece(GetPiece(Memory[Num+9],'%s%',1),'%sh%',0); | |
'shootfriendly' : Result:=GetPiece(Memory[Num+9],'%sh%',1); | |
end; | |
end; | |
Procedure ChangeState(Num:int64; What,NewStat:string); | |
begin | |
What:=lowercase(what); | |
case What of | |
'name' : Memory[Num] := '%name%'+NewStat; | |
'password' : Memory[Num+1] := MD5Issue(NewStat); | |
'hwid' : Memory[Num+2] := NewStat+'%ip%'+ReadPlayer(num,'ip'); | |
'ip' : Memory[Num+2] := ReadPlayer(num,'hwid')+'%ip%'+NewStat; | |
'points' : Memory[Num+3] := NewStat; | |
'lastplay' : Memory[Num+4] := ReadPlayer(num,'registerdate')+'%lp%'+NewStat; | |
'bigtext' : Memory[Num+5] := NewStat+'%first%'+ReadPlayer(num,'firstuse')+'%autologin%'+ReadPlayer(num,'autologin')+'%mail%'+ReadPlayer(num,'mail'); | |
'firstuse' : Memory[Num+5] := ReadPlayer(num,'bigtext')+'%first%'+NewStat+'%autologin%'+ReadPlayer(num,'autologin')+'%mail%'+ReadPlayer(num,'mail'); | |
'autologin' : Memory[Num+5] := ReadPlayer(num,'bigtext')+'%first%'+ReadPlayer(num,'firstuse')+'%autologin%'+NewStat+'%mail%'+ReadPlayer(num,'mail'); | |
'mail' : Memory[Num+5] := ReadPlayer(num,'bigtext')+'%first%'+ReadPlayer(num,'firstuse')+'%autologin%'+ReadPlayer(num,'autologin')+'%mail%'+NewStat; | |
'kills' : Memory[Num+6] := NewStat+'%k%'+ReadPlayer(num,'deaths')+'%d%'+ReadPlayer(num,'selfkills')+'%s%'+ReadPlayer(num,'teamkills')+'%t%'+ReadPlayer(num,'deathsbyteam')+'%dt%'+ReadPlayer(num,'postromuskill')+'%p%'+ReadPlayer(num,'assist')+'%a%'+ReadPlayer(num,'revengekills')+'%r%'+ReadPlayer(num,'avenger')+'%z%'+ReadPlayer(num,'wybawiel')+'%w%'+ReadPlayer(num,'flagerkills'); | |
'deaths' : Memory[Num+6] := ReadPlayer(num,'kills')+'%k%'+NewStat+'%d%'+ReadPlayer(num,'selfkills')+'%s%'+ReadPlayer(num,'teamkills')+'%t%'+ReadPlayer(num,'deathsbyteam')+'%dt%'+ReadPlayer(num,'postromuskill')+'%p%'+ReadPlayer(num,'assist')+'%a%'+ReadPlayer(num,'revengekills')+'%r%'+ReadPlayer(num,'avenger')+'%z%'+ReadPlayer(num,'wybawiel')+'%w%'+ReadPlayer(num,'flagerkills'); | |
'selfkills' : Memory[Num+6] := ReadPlayer(num,'kills')+'%k%'+ReadPlayer(num,'deaths')+'%d%'+NewStat+'%s%'+ReadPlayer(num,'teamkills')+'%t%'+ReadPlayer(num,'deathsbyteam')+'%dt%'+ReadPlayer(num,'postromuskill')+'%p%'+ReadPlayer(num,'assist')+'%a%'+ReadPlayer(num,'revengekills')+'%r%'+ReadPlayer(num,'avenger')+'%z%'+ReadPlayer(num,'wybawiel')+'%w%'+ReadPlayer(num,'flagerkills'); | |
'teamkills' : Memory[Num+6] := ReadPlayer(num,'kills')+'%k%'+ReadPlayer(num,'deaths')+'%d%'+ReadPlayer(num,'selfkills')+'%s%'+NewStat+'%t%'+ReadPlayer(num,'deathsbyteam')+'%dt%'+ReadPlayer(num,'postromuskill')+'%p%'+ReadPlayer(num,'assist')+'%a%'+ReadPlayer(num,'revengekills')+'%r%'+ReadPlayer(num,'avenger')+'%z%'+ReadPlayer(num,'wybawiel')+'%w%'+ReadPlayer(num,'flagerkills'); | |
'deathsbyteam' : Memory[Num+6] := ReadPlayer(num,'kills')+'%k%'+ReadPlayer(num,'deaths')+'%d%'+ReadPlayer(num,'selfkills')+'%s%'+ReadPlayer(num,'teamkills')+'%t%'+NewStat+'%dt%'+ReadPlayer(num,'postromuskill')+'%p%'+ReadPlayer(num,'assist')+'%a%'+ReadPlayer(num,'revengekills')+'%r%'+ReadPlayer(num,'avenger')+'%z%'+ReadPlayer(num,'wybawiel')+'%w%'+ReadPlayer(num,'flagerkills'); | |
'postromuskill' : Memory[Num+6] := ReadPlayer(num,'kills')+'%k%'+ReadPlayer(num,'deaths')+'%d%'+ReadPlayer(num,'selfkills')+'%s%'+ReadPlayer(num,'teamkills')+'%t%'+ReadPlayer(num,'deathsbyteam')+'%dt%'+NewStat+'%p%'+ReadPlayer(num,'assist')+'%a%'+ReadPlayer(num,'revengekills')+'%r%'+ReadPlayer(num,'avenger')+'%z%'+ReadPlayer(num,'wybawiel')+'%w%'+ReadPlayer(num,'flagerkills'); | |
'assist' : Memory[Num+6] := ReadPlayer(num,'kills')+'%k%'+ReadPlayer(num,'deaths')+'%d%'+ReadPlayer(num,'selfkills')+'%s%'+ReadPlayer(num,'teamkills')+'%t%'+ReadPlayer(num,'deathsbyteam')+'%dt%'+ReadPlayer(num,'postromuskill')+'%p%'+NewStat+'%a%'+ReadPlayer(num,'revengekills')+'%r%'+ReadPlayer(num,'avenger')+'%z%'+ReadPlayer(num,'wybawiel')+'%w%'+ReadPlayer(num,'flagerkills'); | |
'revengekills' : Memory[Num+6] := ReadPlayer(num,'kills')+'%k%'+ReadPlayer(num,'deaths')+'%d%'+ReadPlayer(num,'selfkills')+'%s%'+ReadPlayer(num,'teamkills')+'%t%'+ReadPlayer(num,'deathsbyteam')+'%dt%'+ReadPlayer(num,'postromuskill')+'%p%'+ReadPlayer(num,'assist')+'%a%'+NewStat+'%r%'+ReadPlayer(num,'avenger')+'%z%'+ReadPlayer(num,'wybawiel')+'%w%'+ReadPlayer(num,'flagerkills'); | |
'avenger' : Memory[Num+6] := ReadPlayer(num,'kills')+'%k%'+ReadPlayer(num,'deaths')+'%d%'+ReadPlayer(num,'selfkills')+'%s%'+ReadPlayer(num,'teamkills')+'%t%'+ReadPlayer(num,'deathsbyteam')+'%dt%'+ReadPlayer(num,'postromuskill')+'%p%'+ReadPlayer(num,'assist')+'%a%'+ReadPlayer(num,'revengekills')+'%r%'+NewStat+'%z%'+ReadPlayer(num,'wybawiel')+'%w%'+ReadPlayer(num,'flagerkills'); | |
'wybawiel' : Memory[Num+6] := ReadPlayer(num,'kills')+'%k%'+ReadPlayer(num,'deaths')+'%d%'+ReadPlayer(num,'selfkills')+'%s%'+ReadPlayer(num,'teamkills')+'%t%'+ReadPlayer(num,'deathsbyteam')+'%dt%'+ReadPlayer(num,'postromuskill')+'%p%'+ReadPlayer(num,'assist')+'%a%'+ReadPlayer(num,'revengekills')+'%r%'+ReadPlayer(num,'avenger')+'%z%'+NewStat+'%w%'+ReadPlayer(num,'flagerkills'); | |
'flagerkills' : Memory[Num+6] := ReadPlayer(num,'kills')+'%k%'+ReadPlayer(num,'deaths')+'%d%'+ReadPlayer(num,'selfkills')+'%s%'+ReadPlayer(num,'teamkills')+'%t%'+ReadPlayer(num,'deathsbyteam')+'%dt%'+ReadPlayer(num,'postromuskill')+'%p%'+ReadPlayer(num,'assist')+'%a%'+ReadPlayer(num,'revengekills')+'%r%'+ReadPlayer(num,'avenger')+'%z%'+ReadPlayer(num,'wybawiel')+'%w%'+NewStat; | |
'flaggrab' : Memory[Num+7] := NewStat+'%fg%'+ReadPlayer(num,'flagreturn')+'%fr%'+ReadPlayer(num,'flagscore')+'%fs%'+ReadPlayer(num,'flagdrop')+'%fd%'+ReadPlayer(num,'alphacaps')+'%ac%'+ReadPlayer(num,'bravocaps')+'%bc%'+ReadPlayer(num,'inf_red')+'%ir%'+ReadPlayer(num,'inf_blue')+'%ib%'+ReadPlayer(num,'htf_red')+'%hr%'+ReadPlayer(num,'htf_blue')+'%ft%'+ReadPlayer(num,'flagthrown'); | |
'flagreturn' : Memory[Num+7] := ReadPlayer(num,'flaggrab')+'%fg%'+NewStat+'%fr%'+ReadPlayer(num,'flagscore')+'%fs%'+ReadPlayer(num,'flagdrop')+'%fd%'+ReadPlayer(num,'alphacaps')+'%ac%'+ReadPlayer(num,'bravocaps')+'%bc%'+ReadPlayer(num,'inf_red')+'%ir%'+ReadPlayer(num,'inf_blue')+'%ib%'+ReadPlayer(num,'htf_red')+'%hr%'+ReadPlayer(num,'htf_blue')+'%ft%'+ReadPlayer(num,'flagthrown'); | |
'flagscore' : Memory[Num+7] := ReadPlayer(num,'flaggrab')+'%fg%'+ReadPlayer(num,'flagreturn')+'%fr%'+NewStat+'%fs%'+ReadPlayer(num,'flagdrop')+'%fd%'+ReadPlayer(num,'alphacaps')+'%ac%'+ReadPlayer(num,'bravocaps')+'%bc%'+ReadPlayer(num,'inf_red')+'%ir%'+ReadPlayer(num,'inf_blue')+'%ib%'+ReadPlayer(num,'htf_red')+'%hr%'+ReadPlayer(num,'htf_blue')+'%ft%'+ReadPlayer(num,'flagthrown'); | |
'flagdrop' : Memory[Num+7] := ReadPlayer(num,'flaggrab')+'%fg%'+ReadPlayer(num,'flagreturn')+'%fr%'+ReadPlayer(num,'flagscore')+'%fs%'+NewStat+'%fd%'+ReadPlayer(num,'alphacaps')+'%ac%'+ReadPlayer(num,'bravocaps')+'%bc%'+ReadPlayer(num,'inf_red')+'%ir%'+ReadPlayer(num,'inf_blue')+'%ib%'+ReadPlayer(num,'htf_red')+'%hr%'+ReadPlayer(num,'htf_blue')+'%ft%'+ReadPlayer(num,'flagthrown'); | |
'alphacaps' : Memory[Num+7] := ReadPlayer(num,'flaggrab')+'%fg%'+ReadPlayer(num,'flagreturn')+'%fr%'+ReadPlayer(num,'flagscore')+'%fs%'+ReadPlayer(num,'flagdrop')+'%fd%'+NewStat+'%ac%'+ReadPlayer(num,'bravocaps')+'%bc%'+ReadPlayer(num,'inf_red')+'%ir%'+ReadPlayer(num,'inf_blue')+'%ib%'+ReadPlayer(num,'htf_red')+'%hr%'+ReadPlayer(num,'htf_blue')+'%ft%'+ReadPlayer(num,'flagthrown'); | |
'bravocaps' : Memory[Num+7] := ReadPlayer(num,'flaggrab')+'%fg%'+ReadPlayer(num,'flagreturn')+'%fr%'+ReadPlayer(num,'flagscore')+'%fs%'+ReadPlayer(num,'flagdrop')+'%fd%'+ReadPlayer(num,'alphacaps')+'%ac%'+NewStat+'%bc%'+ReadPlayer(num,'inf_red')+'%ir%'+ReadPlayer(num,'inf_blue')+'%ib%'+ReadPlayer(num,'htf_red')+'%hr%'+ReadPlayer(num,'htf_blue')+'%ft%'+ReadPlayer(num,'flagthrown'); | |
'inf_red' : Memory[Num+7] := ReadPlayer(num,'flaggrab')+'%fg%'+ReadPlayer(num,'flagreturn')+'%fr%'+ReadPlayer(num,'flagscore')+'%fs%'+ReadPlayer(num,'flagdrop')+'%fd%'+ReadPlayer(num,'alphacaps')+'%ac%'+ReadPlayer(num,'bravocaps')+'%bc%'+NewStat+'%ir%'+ReadPlayer(num,'inf_blue')+'%ib%'+ReadPlayer(num,'htf_red')+'%hr%'+ReadPlayer(num,'htf_blue')+'%ft%'+ReadPlayer(num,'flagthrown'); | |
'inf_blue' : Memory[Num+7] := ReadPlayer(num,'flaggrab')+'%fg%'+ReadPlayer(num,'flagreturn')+'%fr%'+ReadPlayer(num,'flagscore')+'%fs%'+ReadPlayer(num,'flagdrop')+'%fd%'+ReadPlayer(num,'alphacaps')+'%ac%'+ReadPlayer(num,'bravocaps')+'%bc%'+ReadPlayer(num,'inf_red')+'%ir%'+NewStat+'%ib%'+ReadPlayer(num,'htf_red')+'%hr%'+ReadPlayer(num,'htf_blue')+'%ft%'+ReadPlayer(num,'flagthrown'); | |
'htf_red' : Memory[Num+7] := ReadPlayer(num,'flaggrab')+'%fg%'+ReadPlayer(num,'flagreturn')+'%fr%'+ReadPlayer(num,'flagscore')+'%fs%'+ReadPlayer(num,'flagdrop')+'%fd%'+ReadPlayer(num,'alphacaps')+'%ac%'+ReadPlayer(num,'bravocaps')+'%bc%'+ReadPlayer(num,'inf_red')+'%ir%'+ReadPlayer(num,'inf_blue')+'%ib%'+NewStat+'%hr%'+ReadPlayer(num,'htf_blue')+'%ft%'+ReadPlayer(num,'flagthrown'); | |
'htf_blue' : Memory[Num+7] := ReadPlayer(num,'flaggrab')+'%fg%'+ReadPlayer(num,'flagreturn')+'%fr%'+ReadPlayer(num,'flagscore')+'%fs%'+ReadPlayer(num,'flagdrop')+'%fd%'+ReadPlayer(num,'alphacaps')+'%ac%'+ReadPlayer(num,'bravocaps')+'%bc%'+ReadPlayer(num,'inf_red')+'%ir%'+ReadPlayer(num,'inf_blue')+'%ib%'+ReadPlayer(num,'htf_red')+'%hr%'+NewStat+'%ft%'+ReadPlayer(num,'flagthrown'); | |
'flagthrown' : Memory[Num+7] := ReadPlayer(num,'flaggrab')+'%fg%'+ReadPlayer(num,'flagreturn')+'%fr%'+ReadPlayer(num,'flagscore')+'%fs%'+ReadPlayer(num,'flagdrop')+'%fd%'+ReadPlayer(num,'alphacaps')+'%ac%'+ReadPlayer(num,'bravocaps')+'%bc%'+ReadPlayer(num,'inf_red')+'%ir%'+ReadPlayer(num,'inf_blue')+'%ib%'+ReadPlayer(num,'htf_red')+'%hr%'+ReadPlayer(num,'htf_blue')+'%ft%'+NewStat; | |
'wins' : Memory[Num+8] := NewStat+'%w%'+ReadPlayer(num,'lose')+'%l%'+ReadPlayer(num,'remis')+'%r%'+ReadPlayer(num,'alphawins')+'%aw%'+ReadPlayer(num,'alphalose')+'%al%'+ReadPlayer(num,'bravowins')+'%bw%'+ReadPlayer(num,'bravolose')+'%bl%'+ReadPlayer(num,'charliewin')+'%cw%'+ReadPlayer(num,'charlielose')+'%cl%'+ReadPlayer(num,'deltawin')+'%dw%'+ReadPlayer(num,'deltalose'); | |
'lose' : Memory[Num+8] := ReadPlayer(num,'wins')+'%w%'+NewStat+'%l%'+ReadPlayer(num,'remis')+'%r%'+ReadPlayer(num,'alphawins')+'%aw%'+ReadPlayer(num,'alphalose')+'%al%'+ReadPlayer(num,'bravowins')+'%bw%'+ReadPlayer(num,'bravolose')+'%bl%'+ReadPlayer(num,'charliewin')+'%cw%'+ReadPlayer(num,'charlielose')+'%cl%'+ReadPlayer(num,'deltawin')+'%dw%'+ReadPlayer(num,'deltalose'); | |
'remis' : Memory[Num+8] := ReadPlayer(num,'wins')+'%w%'+ReadPlayer(num,'lose')+'%l%'+NewStat+'%r%'+ReadPlayer(num,'alphawins')+'%aw%'+ReadPlayer(num,'alphalose')+'%al%'+ReadPlayer(num,'bravowins')+'%bw%'+ReadPlayer(num,'bravolose')+'%bl%'+ReadPlayer(num,'charliewin')+'%cw%'+ReadPlayer(num,'charlielose')+'%cl%'+ReadPlayer(num,'deltawin')+'%dw%'+ReadPlayer(num,'deltalose'); | |
'alphawins' : Memory[Num+8] := ReadPlayer(num,'wins')+'%w%'+ReadPlayer(num,'lose')+'%l%'+ReadPlayer(num,'remis')+'%r%'+NewStat+'%aw%'+ReadPlayer(num,'alphalose')+'%al%'+ReadPlayer(num,'bravowins')+'%bw%'+ReadPlayer(num,'bravolose')+'%bl%'+ReadPlayer(num,'charliewin')+'%cw%'+ReadPlayer(num,'charlielose')+'%cl%'+ReadPlayer(num,'deltawin')+'%dw%'+ReadPlayer(num,'deltalose'); | |
'alphalose' : Memory[Num+8] := ReadPlayer(num,'wins')+'%w%'+ReadPlayer(num,'lose')+'%l%'+ReadPlayer(num,'remis')+'%r%'+ReadPlayer(num,'alphawins')+'%aw%'+NewStat+'%al%'+ReadPlayer(num,'bravowins')+'%bw%'+ReadPlayer(num,'bravolose')+'%bl%'+ReadPlayer(num,'charliewin')+'%cw%'+ReadPlayer(num,'charlielose')+'%cl%'+ReadPlayer(num,'deltawin')+'%dw%'+ReadPlayer(num,'deltalose'); | |
'bravowins' : Memory[Num+8] := ReadPlayer(num,'wins')+'%w%'+ReadPlayer(num,'lose')+'%l%'+ReadPlayer(num,'remis')+'%r%'+ReadPlayer(num,'alphawins')+'%aw%'+ReadPlayer(num,'alphalose')+'%al%'+NewStat+'%bw%'+ReadPlayer(num,'bravolose')+'%bl%'+ReadPlayer(num,'charliewin')+'%cw%'+ReadPlayer(num,'charlielose')+'%cl%'+ReadPlayer(num,'deltawin')+'%dw%'+ReadPlayer(num,'deltalose'); | |
'bravolose' : Memory[Num+8] := ReadPlayer(num,'wins')+'%w%'+ReadPlayer(num,'lose')+'%l%'+ReadPlayer(num,'remis')+'%r%'+ReadPlayer(num,'alphawins')+'%aw%'+ReadPlayer(num,'alphalose')+'%al%'+ReadPlayer(num,'bravowins')+'%bw%'+NewStat+'%bl%'+ReadPlayer(num,'charliewin')+'%cw%'+ReadPlayer(num,'charlielose')+'%cl%'+ReadPlayer(num,'deltawin')+'%dw%'+ReadPlayer(num,'deltalose'); | |
'charliewin' : Memory[Num+8] := ReadPlayer(num,'wins')+'%w%'+ReadPlayer(num,'lose')+'%l%'+ReadPlayer(num,'remis')+'%r%'+ReadPlayer(num,'alphawins')+'%aw%'+ReadPlayer(num,'alphalose')+'%al%'+ReadPlayer(num,'bravowins')+'%bw%'+ReadPlayer(num,'bravolose')+'%bl%'+NewStat+'%cw%'+ReadPlayer(num,'charlielose')+'%cl%'+ReadPlayer(num,'deltawin')+'%dw%'+ReadPlayer(num,'deltalose'); | |
'charlielose' : Memory[Num+8] := ReadPlayer(num,'wins')+'%w%'+ReadPlayer(num,'lose')+'%l%'+ReadPlayer(num,'remis')+'%r%'+ReadPlayer(num,'alphawins')+'%aw%'+ReadPlayer(num,'alphalose')+'%al%'+ReadPlayer(num,'bravowins')+'%bw%'+ReadPlayer(num,'bravolose')+'%bl%'+ReadPlayer(num,'charliewin')+'%cw%'+NewStat+'%cl%'+ReadPlayer(num,'deltawin')+'%dw%'+ReadPlayer(num,'deltalose'); | |
'deltawin' : Memory[Num+8] := ReadPlayer(num,'wins')+'%w%'+ReadPlayer(num,'lose')+'%l%'+ReadPlayer(num,'remis')+'%r%'+ReadPlayer(num,'alphawins')+'%aw%'+ReadPlayer(num,'alphalose')+'%al%'+ReadPlayer(num,'bravowins')+'%bw%'+ReadPlayer(num,'bravolose')+'%bl%'+ReadPlayer(num,'charliewin')+'%cw%'+ReadPlayer(num,'charlielose')+'%cl%'+NewStat+'%dw%'+ReadPlayer(num,'deltalose'); | |
'deltalose' : Memory[Num+8] := ReadPlayer(num,'wins')+'%w%'+ReadPlayer(num,'lose')+'%l%'+ReadPlayer(num,'remis')+'%r%'+ReadPlayer(num,'alphawins')+'%aw%'+ReadPlayer(num,'alphalose')+'%al%'+ReadPlayer(num,'bravowins')+'%bw%'+ReadPlayer(num,'bravolose')+'%bl%'+ReadPlayer(num,'charliewin')+'%cw%'+ReadPlayer(num,'charlielose')+'%cl%'+ReadPlayer(num,'deltawin')+'%dw%'+NewStat; | |
'shoots' : Memory[Num+9] := NewStat+'%s%'+ReadPlayer(num,'shoothits')+'%sh%'+ReadPlayer(num,'shootfriendly'); | |
'shoothits' : Memory[Num+9] := ReadPlayer(num,'shoots')+'%s%'+NewStat+'%sh%'+ReadPlayer(num,'shootfriendly'); | |
'shootfriendly' : Memory[Num+9] := ReadPlayer(num,'shoots')+'%s%'+ReadPlayer(num,'shoothits')+'%sh%'+NewStat; | |
end; | |
end; | |
function abs2(val: integer): integer; | |
begin | |
result := iif(val<0, -val, val); | |
end; | |
function CalcWeakerTeam(noswap: boolean): byte; // 0: teams are balanced, 1, 31: alpha is smaller, 2, 32: bravo is smaller, | |
var intAlphaPlayers, intAlphaScore: integer; // 11: swap best bravo with worst alpha, 12: swap best alpha with worst bravo, | |
begin // 21: move worst bravo to alpha, 22: move worst alpha to bravo. | |
result := 0; | |
intAlphaPlayers := Game.Teams[1].Count; | |
intAlphaScore := Game.Teams[1].Score; | |
if (not noswap) and (intAlphaPlayers = Game.Teams[2].Count) then begin | |
if (abs2(intAlphaScore-Game.Teams[2].Score) >= SwapDiff) then begin | |
if (intAlphaScore > Game.Teams[2].Score) then result := 12 else result := 11; | |
end else | |
begin | |
if (intAlphaScore > Game.Teams[2].Score) then result := 42 else if (intAlphaScore < Game.Teams[2].Score) then result := 41; | |
end; | |
end else if (abs2(intAlphaPlayers-Game.Teams[2].Count) >= 2) then begin | |
if (abs2(intAlphaScore-Game.Teams[2].Score) >= SwapDiff) then begin | |
if (intAlphaPlayers > Game.Teams[2].Count) and (intAlphaScore < Game.Teams[2].Score) then result := 22 else if (intAlphaPlayers < Game.Teams[2].Count) and (intAlphaScore > Game.Teams[2].Score) then result := 21 else if (intAlphaPlayers > Game.Teams[2].Count) then result := 2 else result := 1; | |
end else begin | |
if (intAlphaPlayers > Game.Teams[2].Count) then result := 2 else result := 1; | |
end; | |
end else if (abs2(intAlphaPlayers-Game.Teams[2].Count) = 1) then begin | |
if (abs2(intAlphaScore-Game.Teams[2].Score) < MinDiff) then begin | |
if (intAlphaPlayers > Game.Teams[2].Count) then result := 32 else result := 31; | |
end else if (intAlphaPlayers > Game.Teams[2].Count) and (intAlphaScore > Game.Teams[2].Score) then result := 2 else if (intAlphaPlayers < Game.Teams[2].Count) and (intAlphaScore < Game.Teams[2].Score) then result := 1; | |
end; | |
end; | |
procedure msg(id: byte; text: string; goods: boolean); | |
begin | |
if (id = 255) then writeln('[ZitroFUN] '+text) else begin | |
if (goods) then Players[id].WriteConsole(text, GOOD) else Players[id].writeconsole(text, BAD); | |
end; | |
end; | |
procedure BalanceSettingDisplay(caller: byte); | |
begin | |
if (SwapCountsFlags) then msg(caller, 'SwapCntFlags = true (swap will ignore players who capped the flag)', true); | |
if (KeepTeamScore) then msg(caller, 'KeepTeamScr = true (even if team is empty, its score is kept)', true); | |
case Method of | |
1: msg(caller, 'Method = 1 (random player will be moved)', true); | |
2: msg(caller, 'Method = 2 (player with the fewest kills will be moved)', true); | |
3: msg(caller, 'Method = 3 (player with the fewest caps will be moved)', true); | |
4: msg(caller, 'Method = 4 (player with the worst k/d ratio will be moved)', true); | |
5: msg(caller, 'Method = 5 (player with fewest kills and no caps will be moved)', true); | |
6: msg(caller, 'Method = 6 (player with worst k/d and no caps will be moved)', true); | |
7: msg(caller, 'Method = 7 (random player with no caps will be moved)', true); | |
8: msg(caller, 'Method = 8 (player with the fewest points will be moved)', true); | |
9: msg(caller, 'Method = 9 (player with fewest points and no caps will be moved)', true); | |
else msg(caller, 'Method = '+inttostr(Method)+' (ERROR: unknown method, balance won''t work!)', false); | |
end; | |
msg(caller, 'Interval = '+iif(Interval>9, '', ' ')+inttostr(Interval)+iif(Interval>0, ' min (time between automatic balances)', ' (automatic balance is disabled)'), true); | |
msg(caller, 'ImmuneTime = '+iif(ImmuneTime>9, '', ' ')+inttostr(ImmuneTime)+iif(ImmuneTime>0, ' min (player won''t be moved again until '+inttostr(ImmuneTime)+' min pass)', ' (disabled)'), true); | |
msg(caller, 'LockTime = '+iif(LockTime>9, '', ' ')+inttostr(LockTime)+ iif(LockTime>0, ' min (locking team of moved player for '+inttostr(LockTime)+' min)', ' (disabled)'), true); | |
msg(caller, 'Balances this run: ' + inttostr(bal.numberGlobal)+' ('+inttostr(bal.numberMap)+' on prev map)'+iif(bal.numberGlobal>0,' | Last one was '+iif(bal.lastbalance=32767, 'over 9 hours ago', inttostr(bal.lastbalance div 60) + ' min ' + inttostr(bal.lastbalance mod 60) + ' s ago'), ''), false); | |
end; | |
procedure RecompileBalance(); | |
var i: byte; | |
begin | |
case Game.GameStyle of | |
3: begin | |
MinDiff := 2; | |
SwapDiff := 6; | |
end; | |
5: begin | |
MinDiff := 30; | |
SwapDiff := 75; | |
end; | |
else begin | |
writeln('[ZitroFUN] Not supported GameStyle. Balance is disabled.'); | |
exit; | |
end; | |
end; | |
bal.mode := 0; bal.restoreDelay := 0; bal.numberGlobal := 0; bal.maxBalances := 0; bal.lastbalance := 5; bal.smallerTeam := CalcWeakerTeam(true) mod 10; bal.justLeft := false; bal.hardbaltime := 0; | |
if (KeepTeamScore) then begin | |
bal.tempAlphaScore := Game.Teams[1].Score; | |
bal.tempBravoScore := Game.Teams[2].Score; | |
end; | |
if (Interval > 0) then bal.lastcheck := Interval * 60 else bal.lastcheck := -1; | |
for i := 1 to 32 do begin | |
PlayerInfo[i].immune := 0; | |
PlayerInfo[i].lock := 0; | |
PlayerInfo[i].triggers := 0; | |
PlayerInfo[i].movedByScript := false; | |
if (Players[i].Active) then PlayerInfo[i].prevteam := Players[i].Team else PlayerInfo[i].prevteam := 0; | |
end; | |
BalanceSettingDisplay(255); | |
end; | |
function CheckTeamChange(Player: TActivePlayer; team: byte): boolean; | |
var temp: string; | |
begin | |
result := false; | |
if (TriggerLimit < 0) then begin | |
Player.WriteConsole('Team-change triggers are disabled on this server.', BAD); | |
result := true; | |
exit; | |
end; | |
if (TriggerLimit > 0) then if (PlayerInfo[Player.ID].triggers >= TriggerLimit) then if (team < 5) then begin | |
Player.WriteConsole('You''ve reached the trigger limit ('+inttostr(TriggerLimit)+'). Wait for map change.', BAD); | |
result := true; | |
exit; | |
end; | |
if (Player.Team = team) then begin | |
case team of | |
1: temp := 'Alpha'; | |
2: temp := 'Bravo'; | |
5: temp := 'Spectator'; | |
else temp := '*error*'; | |
end; | |
Player.WriteConsole('You are already in '+temp+' Team!', BAD); | |
result := true; | |
exit; | |
end; | |
if (team <> 5) then begin | |
if ((CalcWeakerTeam(true) mod 10) = Player.Team) then begin | |
Player.WriteConsole('Your team is weaker - please stay where you are.', BAD); | |
result := true; | |
end else if (CalcWeakerTeam(true) = 0) then begin | |
Player.WriteConsole('Teams are balanced - please don''t ruin it.', BAD); | |
result := true; | |
end; | |
end; | |
end; | |
function ChoosePlayer(team, choosingmethod: byte): byte; | |
var i: byte; j, maxval, temp: integer; player: array [1..32] of byte; TempIndexID:int64; | |
begin | |
result := 0; j := 0; | |
for i := 1 to 32 do if (Players[i].Active) then if (PlayerInfo[i].immune = 0) then if (Players[i].Team = Team) then if (Players[i].Flagger = false) then if (Players[i].Human) then begin | |
if (choosingmethod = 7) and (Players[i].Flags > 0) then continue; | |
j := (j+1); | |
player[j] := i; | |
end; | |
if (choosingmethod = 7) then choosingmethod := 1; | |
if (j > 0) then case choosingmethod of | |
// method 0: choose the player with the most kills AND no caps. if it fails, fewest caps (used for swapping best and weakest players) | |
0: begin | |
maxval := 0; | |
for i := 1 to j do if ((not SwapCountsFlags) or (GetPlayerStat(player[i], 'Flags') = 0)) then begin | |
temp := GetPlayerStat(player[i], 'Kills'); | |
if (temp >= maxval) then begin | |
maxval := temp; | |
result := player[i]; | |
end; | |
end; | |
if (maxval = 0) then for i := 1 to j do begin | |
temp := GetPlayerStat(player[i], 'Flags'); | |
if (temp <= maxval) then begin | |
maxval := temp; | |
result := player[i]; | |
end; | |
end; | |
end; | |
// method 1: choose the player randomly | |
1: result := iif(j=1, player[1], player[random(1, j+1)]); | |
// method 2: choose the player with fewest kills | |
2: begin | |
maxval := 32767; | |
for i := 1 to j do begin | |
temp := GetPlayerStat(player[i], 'Kills'); | |
if (temp <= maxval) then begin | |
maxval := temp; | |
result := player[i]; | |
end; | |
end; | |
end; | |
// method 3: choose the player with fewest flag captures | |
3: begin | |
maxval := 32767; | |
for i := 1 to j do begin | |
temp := GetPlayerStat(player[i], 'Flags'); | |
if (temp <= maxval) then begin | |
maxval := temp; | |
result := player[i]; | |
end; | |
end; | |
end; | |
// method 4: choose the player with the worst kills/deaths ratio | |
4: begin | |
maxval := 32767; | |
for i := 1 to j do begin | |
temp := round(50 * (GetPlayerStat(player[i], 'Kills') / iif(GetPlayerStat(player[i], 'Deaths')=0, 1, GetPlayerStat(player[i], 'Deaths')))); | |
if (temp <= maxval) then begin | |
maxval := temp; | |
result := player[i]; | |
end; | |
end; | |
end; | |
// method 5: fewest kills AND no caps. if it fails, fewest caps | |
5: begin | |
maxval := 32767; | |
for i := 1 to j do if (GetPlayerStat(player[i], 'Flags') = 0) then begin | |
temp := GetPlayerStat(player[i], 'Kills'); | |
if (temp <= maxval) then begin | |
maxval := temp; | |
result := player[i]; | |
end; | |
end; | |
if (maxval = 32767) then for i := 1 to j do begin | |
temp := GetPlayerStat(player[i], 'Flags'); | |
if (temp <= maxval) then begin | |
maxval := temp; | |
result := player[i]; | |
end; | |
end; | |
end; | |
// method 6: worst k/d ratio AND no caps. if it fails, fewest caps | |
6: begin | |
maxval := 32767; | |
for i := 1 to j do if (GetPlayerStat(player[i], 'Flags') = 0) then begin | |
temp := round(50 * (GetPlayerStat(player[i], 'Kills') / iif(GetPlayerStat(player[i], 'Deaths')=0, 1, GetPlayerStat(player[i], 'Deaths')))); | |
if (temp <= maxval) then begin | |
maxval := temp; | |
result := player[i]; | |
end; | |
end; | |
if (maxval = 32767) then for i := 1 to j do begin | |
temp := GetPlayerStat(player[i], 'Flags'); | |
if (temp <= maxval) then begin | |
maxval := temp; | |
result := player[i]; | |
end; | |
end; | |
end; | |
// method 8: choose the player with fewest points | |
8: begin | |
maxval := 32767; | |
for i := 1 to j do begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[player[i]].Name); | |
if (TempIndexID>-1) and (PlayerInfo[player[i]].NickStatus) then temp := strtoint(ReadPlayer(TempIndexID,'points')) else temp := PointsForStart; | |
if (temp <= maxval) then begin | |
maxval := temp; | |
result := player[i]; | |
end; | |
end; | |
end; | |
// method 9: fewest points AND no caps. if it fails, fewest caps | |
9: begin | |
maxval := 32767; | |
for i := 1 to j do if (GetPlayerStat(player[i], 'Flags') = 0) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[player[i]].Name); | |
if (TempIndexID>-1) and (PlayerInfo[player[i]].NickStatus) then temp := strtoint(ReadPlayer(TempIndexID,'points')) else temp := PointsForStart; | |
if (temp <= maxval) then begin | |
maxval := temp; | |
result := player[i]; | |
end; | |
end; | |
if (maxval = 32767) then for i := 1 to j do begin | |
temp := GetPlayerStat(player[i], 'Flags'); | |
if (temp <= maxval) then begin | |
maxval := temp; | |
result := player[i]; | |
end; | |
end; | |
end; | |
else writeln('[ZitroFUN] ERROR - Please check "Method" (should be 1..9)'); | |
end else | |
begin | |
j := (ImmuneTime * 60); | |
for i := 1 to 32 do if (Players[i].Active) then if (Players[i].Team = team) then if (PlayerInfo[i].immune <= j) then if (Players[i].Human) then begin | |
j := PlayerInfo[i].immune; | |
result := i; | |
end; | |
end; | |
if (ImmuneTime > 0) then PlayerInfo[result].immune := (ImmuneTime*60); | |
if (LockTime > 0) then PlayerInfo[result].lock := 0; | |
end; | |
function ShowPlayers(): string; | |
var TempIndexID: int64; apoint,bpoint: integer; i: byte; | |
begin | |
for i := 1 to 32 do if (Players[i].Active) then begin | |
case Players[i].Team of | |
1: begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[i].Name); | |
if (TempIndexID>-1) and (PlayerInfo[i].NickStatus) then apoint := apoint+strtoint(ReadPlayer(TempIndexID,'points')) else apoint := apoint+PointsForStart; | |
end; | |
2: begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[i].Name); | |
if (TempIndexID>-1) and (PlayerInfo[i].NickStatus) then bpoint := bpoint+strtoint(ReadPlayer(TempIndexID,'points')) else bpoint := bpoint+PointsForStart; | |
end; | |
end; | |
end; | |
result := '['+inttostr(Game.Teams[1].Count)+'v'+inttostr(Game.Teams[2].Count)+' Score '+inttostr(Game.Teams[1].Score)+':'+inttostr(Game.Teams[2].Score)+' Points '+inttostr(apoint)+':'+inttostr(bpoint)+']'; | |
end; | |
procedure Swap(caller, id1, id2: byte); | |
var i: byte; | |
begin | |
if (TimeLeft <= 10) then begin | |
if (caller < 33) then Players[caller].WriteConsole('Less than 10 seconds left. Swap is blocked.', BAD); | |
exit; | |
end; | |
if (id1 = 0) and (id2 = 0) then begin | |
for i := 1 to 32 do if (Players[i].Active) then if (Players[i].Team <= 2) then begin | |
PlayerInfo[i].lock := 0; | |
PlayerInfo[i].movedByScript := true; | |
Players[i].Team := iif(Players[i].Team=1,2,1); | |
end; | |
Players.WriteConsole('Teams swapped!', GOOD); | |
end else if (id1 <> 0) and (id2 <> 0) then try | |
if (Players[id1].Active = false) or (Players[id2].Active = false) then begin | |
if (caller < 33) then Players[caller].WriteConsole('One or both players you specified ain''t present.', BAD); | |
exit; | |
end; | |
i := Players[id1].Team; | |
if (i = 5) or (Players[id2].Team = 5) then begin | |
if (caller < 33) then Players[caller].WriteConsole('Can''t swap spectators.', BAD); | |
exit; | |
end; | |
if (Players[id2].Team = i) then begin | |
if (caller < 33) then Players[caller].WriteConsole('No point in swapping players from the same team.', BAD); | |
exit; | |
end; | |
PlayerInfo[id1].lock := 0; PlayerInfo[id2].lock := 0; | |
PlayerInfo[id1].movedByScript := true; PlayerInfo[id2].movedByScript := true; | |
Players[id2].Team := i; Players[id1].Team := iif(i=1,2,1); | |
Players[id1].writeconsole('Swapped teams with '+Players[id2].Name+'.', GOOD); Players[id2].writeconsole('Swapped teams with '+Players[id1].Name+'.', GOOD); | |
if (caller < 33) then Players[caller].WriteConsole('Successfully swapped teams of chosen players.', GOOD); | |
except | |
if (caller < 33) then Players[caller].WriteConsole('Something went wrong. Check the command and try again.', GOOD); | |
exit; | |
end else | |
begin | |
if (caller < 33) then Players[caller].WriteConsole('Something went wrong. Check the command and try again.', GOOD); | |
end; | |
if (caller = 33) then Players.WriteConsole('Teams balanced by swapping two players. '+ShowPlayers(), GOOD); | |
end; | |
procedure Balance(auto, noswap: boolean); | |
var intAlphaPlayers, intAlphaScore: integer; stopBalance: boolean; temp, pl1, pl2: byte; | |
begin | |
if (Game.GameStyle <> 3) and (Game.GameStyle <> 5) then exit; | |
if (Interval > 0) then bal.lastcheck := Interval * 60; | |
intAlphaPlayers := Game.Teams[1].Count; | |
intAlphaScore := Game.Teams[1].Score; | |
stopBalance := false; | |
bal.smallerTeam := 0; | |
if (Game.NumPlayers-Game.Teams[5].Count < 3) then begin | |
if (not auto) then Players.writeconsole('Too few players. Balance is disabled.',GOOD); | |
exit; | |
end; | |
if (intAlphaScore = Game.ScoreLimit) or (Game.Teams[2].Score = Game.ScoreLimit) then begin | |
if (not auto) then begin | |
Players.writeconsole('The map will change soon. Balance is disabled', BAD); | |
Players.writeconsole('to prevent ''wrong map version'' problems.', BAD); | |
end; | |
exit; | |
end; | |
case bal.mode of | |
0: if (auto) then writeln('[ZitroFUN] Checking balance (automatic check)... '+ShowPlayers()) else writeln('[ZitroFUN] Checking balance (request by player)... '+ShowPlayers()); | |
1: writeln('[ZitroFUN] Performing another balance check... '+ShowPlayers()); | |
2: writeln('[ZitroFUN] Checking balance (after shuffle)... '+ShowPlayers()); | |
3: writeln('[ZitroFUN] Checking balance (player leaving)... '+ShowPlayers()); | |
4: writeln('[ZitroFUN] Checking balance (silent request by player)... '+ShowPlayers()); | |
5: writeln('[ZitroFUN] Checking balance (request by admin)... '+ShowPlayers()); | |
end; | |
if (bal.mode > 2) then bal.mode := 0; | |
temp := CalcWeakerTeam(noswap); | |
if (temp > 30) then temp := 0; | |
if (temp = 0) then begin | |
if (bal.mode = 0) and (not auto) then begin | |
Players.writeconsole('Teams are fine, no need to balance. ' + ShowPlayers(), GOOD); | |
end; | |
exit; | |
end; | |
if (temp < 3) then begin | |
pl1 := ChoosePlayer(iif(temp=1, 2, 1), Method); | |
if (pl1 = 0) then begin | |
Players.writeconsole('Something went wrong. Maybe everyone is excluded from balance?', BAD); | |
Players.writeconsole('Or there are multiple bots, which I can''t move? I quit. *sniff*', BAD); | |
exit; | |
end; | |
PlayerInfo[pl1].movedByScript := true; | |
Players[pl1].Team := iif(temp=1,1,2); | |
if (bal.mode <> 2) then writeconsole(pl1, 'You were moved due to unbalanced teams.', GOOD); | |
if (LockTime > 0) then PlayerInfo[pl1].lock := LockTime * 60; | |
end else if (temp < 20) then begin | |
if (bal.swaps < SwapLimit) or (SwapLimit = 0) then begin | |
pl1 := ChoosePlayer(iif(temp=11, 2, 1), 0); | |
pl2 := ChoosePlayer(iif(temp=11, 1, 2), iif(SwapCountsFlags, 5, 2)); | |
Swap(0, pl1, pl2); | |
if (SwapLimit <> 0) then bal.swaps := bal.swaps + 1; | |
if (LockTime > 0) then begin | |
PlayerInfo[pl1].lock := LockTime * 60; | |
PlayerInfo[pl2].lock := LockTime * 60; | |
end; | |
temp := 250; | |
if (Interval > 0) then bal.lastcheck := Interval * 90; | |
end else | |
begin | |
if (bal.mode = 0) and (not auto) then Players.writeconsole('Teams are fine, no need to balance. '+ShowPlayers(), GOOD); | |
exit; | |
end; | |
end else | |
begin | |
pl1 := ChoosePlayer(iif(temp=21, 2, 1), 2); | |
if (pl1 = 0) then exit; | |
PlayerInfo[pl1].movedByScript := true; | |
Players[pl1].Team := iif(temp=21,1,2); | |
if (bal.mode <> 2) then Players[pl1].writeconsole('You were moved due to unbalanced teams.', GOOD); | |
if (LockTime > 0) then PlayerInfo[pl1].lock := LockTime * 60; | |
end; | |
if (bal.mode = 2) then temp := 250; | |
if (temp = 250) then bal.mode := 0 else bal.mode := 1; | |
bal.numberGlobal := bal.numberGlobal +1; | |
bal.numberMap := bal.numberMap + 1; | |
bal.lastbalance := 0; | |
if (temp > 240) or (stopBalance) then begin | |
bal.maxBalances := 0; | |
exit; | |
end; | |
bal.maxBalances := bal.maxBalances + 1; | |
if (bal.maxBalances >= (intAlphaPlayers + Game.Teams[2].Count)/2 + 1) then exit; | |
Balance(true, true); | |
end; | |
procedure Shuffle(Playera: TActivePlayer); | |
var i, j, numpl, temp: byte; player: array [1..32] of byte; | |
begin | |
if (GameStyle <> 3) and (GameStyle <> 5) and (GameStyle <> 6) then exit; | |
if (Game.NumPlayers-Game.Teams[5].Count <= 3) then begin | |
Playera.WriteConsole('Too few players to shuffle.',BAD); | |
exit; | |
end; | |
numpl := 0; | |
for i := 1 to 32 do if (Players[i].Active) then if (Players[i].Team <> 5) then begin | |
numpl := (numpl+1); | |
player[numpl] := i; | |
PlayerInfo[i].lock := 0; | |
end; | |
j := numpl; | |
while j > 1 do begin | |
for i := 1 to j-1 do if (Players[player[i]].Kills < Players[player[i+1]].Kills) then begin | |
temp := player[i]; | |
player[i] := player[i+1]; | |
player[i+1] := temp; | |
end; | |
j := (j-1); | |
end; | |
temp := iif(Game.Teams[1].Score-Game.Teams[2].Score>0, 0, 1); | |
for i := 1 to numpl do begin | |
bal.smallerTeam := 0; | |
PlayerInfo[i].movedByScript := true; | |
if (Players[player[i]].Team <> iif(i mod 2 = temp, 1, 2)) then Players[player[i]].Team := iif(i mod 2 = temp, 1, 2); | |
PlayerInfo[i].movedByScript := false; | |
end; | |
bal.mode := 2; | |
Balance(true, true); | |
end; | |
//END BALANCE | |
function AddNum(First:string; Num:integer):string; | |
begin | |
Result:=inttostr(strtoint(First)+Num); | |
end; | |
function DellNum(First:string; Num:integer):string; | |
begin | |
Result:=inttostr(strtoint(First)-Num); | |
end; | |
function ZeroFill(S: string; Peak: integer; IsEnabled: boolean): string; | |
var i, m: integer; | |
begin | |
if (IsEnabled) then begin | |
m:= Peak - length(S); | |
for i:= 1 to m do S:= '0' + S; | |
end; | |
result:= S; | |
end; | |
function QuickSort3(var AOS: TStringList; Left, Right: integer; Ival: boolean; SortBy: integer): integer; | |
var b, e, Pivot: string; i, l, m, r: integer; | |
begin | |
if (Right > Left) then begin | |
for i:= 0 to Right do begin | |
e:= GetPiece(AOS[i], ':', SortBY); | |
if (length(e) > m) then m:= length(e); | |
end; | |
l:= Left; r:= Right; | |
Pivot:= ZeroFill(GetPiece(AOS[Random(Left, Right)],':', SortBy), m, Ival); | |
repeat | |
while ((ZeroFill(GetPiece(AOS[l], ':', SortBy), m, IVal) > Pivot) and (l < Right)) do Inc(l, 1); | |
while ((ZeroFill(GetPiece(AOS[r], ':', SortBy), m, IVal) < Pivot) and (r > Left)) do Dec(r, 1); | |
if (l <= r) then begin | |
b:= AOS[r]; | |
AOS[r]:= AOS[l]; | |
AOS[l]:= b; | |
Inc(l, 1); | |
Dec(r, 1); | |
Inc(Result, 1); | |
end; | |
until (l >= r); | |
if (Left < r) then QuickSort3(AOS, Left, r, Ival, SortBy); | |
if (Right > l) then QuickSort3(AOS, l, Right, Ival, SortBy); | |
end else exit; | |
end; | |
procedure HardBalance(); | |
var TempIndexID:int64; ab:boolean; i,id:byte; | |
begin | |
AllPlayers := File.CreateStringList(); | |
for i := 1 to 32 do if (Players[i].Active) then begin | |
if (Players[i].Team=1) or (Players[i].Team=2) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[i].Name); | |
if (TempIndexID > -1) then AllPlayers.Append(ReadPlayer(TempIndexID,'points')+':'+inttostr(i)) else AllPlayers.Append(inttostr(PointsForStart)+':'+inttostr(i)); | |
end; | |
end; | |
QuickSort3(AllPlayers, 0, AllPlayers.Count-1, true, 0); | |
id:=strtoint(GetPiece(AllPlayers[0],':',1)); if (Players[id].Team=1) then ab:=false else ab:=true; | |
for i := 0 to AllPlayers.Count-1 do begin | |
id:=strtoint(GetPiece(AllPlayers[i],':',1)); | |
if (ab=false) then begin | |
ab:=true; | |
if (Players[id].Team <> 1) then begin | |
PlayerInfo[id].MovedByScript:=true; | |
Players[id].Team := 1; | |
end; | |
end else | |
begin | |
ab:=false; | |
if (Players[id].Team <> 2) then begin | |
PlayerInfo[id].MovedByScript:=true; | |
Players[id].Team := 2; | |
end; | |
end; | |
end; | |
AllPlayers.Free; | |
bal.hardbaltime := HardBalTimes*60; | |
Players.WriteConsole('Hard Balance! '+ShowPlayers(),GOOD); | |
Balance(true,false); | |
end; | |
procedure LoadList(); | |
var Licznik:int64; | |
begin | |
WriteLn('[ZitroFUN] Load the ranking start..'); | |
if (Memory.Count > 0) then begin | |
TempRank := File.CreateStringList(); | |
repeat | |
if (strtoint(ReadPlayer(Licznik,'kills')) >= MinimalKills) then TempRank.Append(ReadPlayer(Licznik,'points')+':'+ReadPlayer(Licznik,'name')); | |
Licznik:=Licznik+DataLinesNum; | |
until (Licznik>=Memory.Count); | |
QuickSort3(TempRank, 0, TempRank.Count-1, true, 0); | |
end; | |
WriteLn('[ZitroFUN] Load the ranking complete!'); | |
WriteLn('[ZitroFUN] Load search list..'); | |
TempPlayersList := File.CreateStringList(); Licznik := 0; | |
while (Licznik<Memory.Count-1) do begin | |
TempPlayersList.Append(inttostr(Licznik)+LowerCase(Memory[Licznik])); | |
Licznik := (Licznik+DataLinesNum); | |
end; | |
for Licznik := 0 to TempPlayersList.Count-1 do TempPlayersList[Licznik] := inttostr(Length(GetPiece(TempPlayersList[Licznik],'%name%',1)))+':'+TempPlayersList[Licznik]; | |
QuickSort3(TempPlayersList, 0, TempPlayersList.Count-1, true, 0); | |
TempPlayersList.SaveToFile(PatchCore+'cos.txt'); | |
WriteLn('[ZitroFUN] Load search list complete!'); | |
end; | |
Procedure RankSetPos(TempIndexID:int64; LastPoints,NewPoints:integer); | |
var i,TempI,TempIndexID2:int64; name:string; | |
begin | |
name := ReadPlayer(TempIndexID,'name'); TempI:=-1; | |
if (strtoint(ReadPlayer(TempIndexID,'kills'))>=MinimalKills) then begin | |
TempIndexID2 := TempRank.IndexOf(inttostr(LastPoints)+':'+name); | |
if (TempIndexID2>-1) then TempRank.Delete(TempIndexID2); | |
for i := (TempRank.Count-1) downto 0 do if (NewPoints>strtoint(GetPiece(TempRank[i],':',0))) then TempI:=i; | |
if (TempI>-1) then TempRank.Insert(TempI,inttostr(NewPoints)+':'+name); | |
end; | |
end; | |
procedure AddEventDisplay(Player: TActivePlayer; Text: String); | |
var len: integer; | |
begin | |
len := GetArrayLength(PlayerInfo[Player.ID].EventsDisplay); | |
SetArrayLength(PlayerInfo[Player.ID].EventsDisplay,len+1); | |
PlayerInfo[Player.ID].EventsDisplay[len] := Text; | |
end; | |
procedure Give(TempIndexID1, TempIndexID2: int64); | |
var Roznica,CalPower,NumToUp: double; Points, p1p, p2p: integer; | |
begin | |
p1p:=strtoint(ReadPlayer(TempIndexID1,'points')); p2p:=strtoint(ReadPlayer(TempIndexID2,'points')); | |
Roznica := p1p-strtoint(ReadPlayer(TempIndexID2,'points')); CalPower:=DzielnaElo; NumToUp:=DzielnaElox2; //Dominik | |
CalPower := Roznica/single(CalPower); if (CalPower<0) then CalPower := (1/Power(single(NumToUp), abs(CalPower))) else CalPower := Power(single(NumToUp), CalPower); | |
Points := Round(MaxPointGive/(MinimalElo+CalPower)); | |
ChangeState(TempIndexID1,'points',inttostr(p1p+Points)); RankSetPos(TempIndexID1,p1p,p1p+Points); AddEventDisplay(Players[NameToID(ReadPlayer(TempIndexID1,'name'))],'+'+inttostr(Points)+'pts'); | |
ChangeState(TempIndexID2,'points',inttostr(p2p-Points)); RankSetPos(TempIndexID2,p2p,p2p-Points); AddEventDisplay(Players[NameToID(ReadPlayer(TempIndexID1,'name'))],'-'+inttostr(Points)+'pts'); | |
end; | |
function FindPlayer(Player: TActivePlayer; s: string; ForName:boolean): int64; | |
var i: byte; TempIndexID, c: int64; NumNoMinimalKills:integer; | |
begin | |
Result := -1; s := LowerCase(s); | |
try | |
i := StrToInt(s); | |
if (i>0) and (i<33) and (Players[i].Active) then begin | |
c := Memory.IndexOf('%name%'+Players[i].Name); | |
if (c>-1) then begin | |
if (ForName) then begin Result := c; exit; end; | |
if (strtoint(ReadPlayer(c,'kills')) >= MinimalKills) then begin | |
Result := c; | |
exit; | |
end else | |
begin | |
Player.WriteConsole('I found player by id: '+s+', '+Players[i].Name+' but this player dont have required number of kills. ',BAD); | |
Player.WriteConsole('He has: '+ReadPlayer(c,'kills')+'/'+inttostr(MinimalKills)+'. We will try to find someone by part name. ',BAD); | |
end; | |
end else Player.WriteConsole('I found player by id: '+s+', '+Players[i].Name+' but this player don`t have accounts. ',BAD); | |
end; | |
except | |
end; | |
for i := 1 to 32 do if (Players[i].Active) then begin | |
if (ContainsString(LowerCase(Players[i].Name), s)) then begin | |
c := Memory.IndexOf('%name%'+Players[i].Name); | |
if (c>-1) then begin | |
if (ForName) then begin Result := c; exit; end; | |
if (strtoint(ReadPlayer(c,'kills')) >= MinimalKills) then begin | |
Result := c; | |
if (NumNoMinimalKills>0) then Player.WriteConsole('We found '+inttostr(NumNoMinimalKills)+' other players who better match the search phrase but they dont have required number of kills. It is required: '+inttostr(MinimalKills),BAD); | |
exit; | |
end else NumNoMinimalKills := (NumNoMinimalKills+1); | |
end else Player.WriteConsole('I found player by part name: '+s+', '+Players[i].Name+' but this player dont have accounts. ',BAD); | |
end; | |
end; | |
if (NumNoMinimalKills>0) then begin | |
Player.WriteConsole('We found '+inttostr(NumNoMinimalKills)+' matching players on the server, but they dont have required number of kills. It is required: '+inttostr(MinimalKills),BAD); | |
Player.WriteConsole('We are now looking for offline players. ',BAD); | |
NumNoMinimalKills:=0; | |
end; | |
for c := TempPlayersList.Count-1 downto 0 do begin | |
if (ContainsString(GetPiece(TempPlayersList[c],'%name%',1),s)) then begin | |
TempIndexID := strtoint(GetPiece(GetPiece(TempPlayersList[c],':',1),'%name%',0)); | |
if (ForName) then begin Result := TempIndexID; exit; end; | |
if (strtoint(ReadPlayer(TempIndexID,'kills')) >= MinimalKills) then begin | |
Result := TempIndexID; | |
if (NumNoMinimalKills>0) then Player.WriteConsole('We found '+inttostr(NumNoMinimalKills)+' other players who better match the search phrase but they dont have required number of kills. It is required: '+inttostr(MinimalKills),BAD); | |
exit; | |
end else NumNoMinimalKills := (NumNoMinimalKills+1); | |
end; | |
end; | |
Player.WriteConsole('Nothing found ('+s+').',BAD); | |
end; | |
function FindPlayerOld(Player: TActivePlayer; s: string; ForName:boolean): int64; | |
var i: byte; c: int64; Name: string; | |
begin | |
Result := -1; s := LowerCase(s); | |
try | |
i := StrToInt(s); | |
if (i<33) and (Players[i].Active) then begin | |
c := Memory.IndexOf('%name%'+Players[i].Name); | |
if (c>-1) then begin | |
if (ForName) then begin Result := c; exit; end; | |
if (strtoint(ReadPlayer(c,'kills')) >= MinimalKills) then begin | |
Result := c; | |
exit; | |
end else | |
begin | |
Player.WriteConsole('I found player by ID: '+s+', '+Players[i].Name+' but this player dont have required number of kills. ',BAD); | |
Player.WriteConsole('He has: '+ReadPlayer(c,'kills')+'/'+inttostr(MinimalKills)+'. We will try to find someone by part name. ',BAD); | |
end; | |
end else Player.WriteConsole('I found player by ID: '+s+', '+Players[i].Name+' but this player don`t have accounts. ',BAD); | |
end; | |
except | |
end; | |
for i := 1 to 32 do if (Players[i].Active) then begin | |
Name := LowerCase(Players[i].Name); | |
if (ContainsString(Name, s)) then begin | |
c := Memory.IndexOf('%name%'+Players[i].Name); | |
if (c>-1) then begin | |
if (ForName) then begin Result := c; exit; end; | |
if (strtoint(ReadPlayer(c,'kills')) >= MinimalKills) then begin | |
Result := c; | |
exit; | |
end else | |
begin | |
Player.WriteConsole('I found player by part name: '+s+', '+Players[i].Name+' but this player dont have required number of kills. ',BAD); | |
Player.WriteConsole('He has: '+ReadPlayer(c,'kills')+'/'+inttostr(MinimalKills)+'. We will now look at the list of offline players. ',BAD); | |
end; | |
end else Player.WriteConsole('I found player by part name: '+s+', '+Players[i].Name+' but this player dont have accounts. ',BAD); | |
end; | |
end; | |
c:=0; | |
while (true) do begin | |
if (c>=Memory.Count) then break; | |
if (ContainsString(lowercase(Memory[c]),s)) then begin | |
if (ForName) then begin Result := c; exit; end; | |
if (strtoint(ReadPlayer(c,'kills')) >= MinimalKills) then begin | |
Result:=c; | |
exit; | |
end else Player.WriteConsole('Player '+ReadPlayer(c,'name')+' dont have required number of kills. It has: '+ReadPlayer(c,'kills')+'/'+inttostr(MinimalKills),BAD); | |
end; | |
c:=c+DataLinesNum; | |
end; | |
Player.WriteConsole('Nothing found ('+s+').',BAD); | |
end; | |
procedure AutoLogin(Player: TActivePlayer; TempIndexID:int64); | |
begin | |
case (ReadPlayer(TempIndexID,'autologin')) of | |
'hwid': begin | |
if (Player.HWID = ReadPlayer(TempIndexID,'hwid')) then begin | |
PlayerInfo[Player.ID].NickStatus := true; | |
if (ReadPlayer(TempIndexID,'autologin')='hwid') and (Player.HWID <> ReadPlayer(TempIndexID,'hwid')) then begin | |
ChangeState(TempIndexID,'hwid',Player.HWID); | |
Player.WriteConsole('We detect your new computer, now you be autologin on this computer.',GOOD); | |
Player.WriteConsole('We use HWID to autologin, if you login on other computer we change you hwid again after logging.',GOOD); | |
Player.WriteConsole('On the old computer, you will need to again manually login and then will again autologin.',GOOD); | |
end; | |
Player.WriteConsole('Automatic login through HWID - Completed successfully!',GOOD); | |
Player.WriteConsole('Welcome back '+Player.Name+' (HWID: '+Player.HWID+')',GOOD); | |
if (ReadPlayer(TempIndexID,'password') = '') then Player.WriteConsole('To better protect account please add password /addpassword <password>',BAD); | |
end else | |
begin | |
Player.WriteConsole('Automatic login through HWID - The unsuccessful!',BAD); | |
Player.WriteConsole('The nickname '+Player.Name+' is REGISTERED!',BAD); | |
Player.WriteConsole('Use "/login password" to login or you will be kicked in '+inttostr(KickTime)+' seconds',BAD); | |
PlayerInfo[Player.ID].KickTimer := KickTime; | |
end; | |
end; | |
'ip': begin | |
if (Player.IP = ReadPlayer(TempIndexID,'ip')) then begin | |
PlayerInfo[Player.ID].NickStatus := true; | |
if (ReadPlayer(TempIndexID,'autologin')='ip') and (Player.IP <> ReadPlayer(TempIndexID,'ip')) then begin | |
ChangeState(TempIndexID,'ip',Player.IP); | |
Player.WriteConsole('We detect your new IP address, now you be autologin on this computer.',GOOD); | |
Player.WriteConsole('We use IP to autologin, if you login on other computer we change you IP again after logging.',GOOD); | |
Player.WriteConsole('On the old IP address, you will need to again manually login and then will again autologin.',GOOD); | |
end; | |
Player.WriteConsole('Automatic login through IP - Completed successfully!',GOOD); | |
Player.WriteConsole('Welcome back '+Player.Name+' (IP: '+Player.IP+')',GOOD); | |
if (ReadPlayer(TempIndexID,'password') = '') then Player.WriteConsole('To better protect account please add password /addpassword <password>',BAD); | |
end else | |
begin | |
Player.WriteConsole('Automatic login through IP - The unsuccessful!', BAD); | |
Player.WriteConsole('The nickname '+Player.Name+' is REGISTERED!',BAD); | |
Player.WriteConsole('Use "/login password" to login or you will be kicked in '+inttostr(KickTime)+' seconds', BAD); | |
PlayerInfo[Player.ID].KickTimer := KickTime; | |
end; | |
end; | |
'nick': begin | |
if (Player.Name = ReadPlayer(TempIndexID,'name')) then begin | |
PlayerInfo[Player.ID].NickStatus := true; | |
Player.WriteConsole('Automatic login through nick - Completed successfully!', GOOD); | |
Player.WriteConsole('Welcome back '+Player.Name+' (Nick: '+Player.Name+')',GOOD); | |
if (ReadPlayer(TempIndexID,'password') = '') then Player.WriteConsole('To better protect account please add password /addpassword <password>',BAD); | |
end else | |
begin | |
Player.WriteConsole('Automatic login through nick - The unsuccessful!', BAD); | |
Player.WriteConsole('The nickname '+Player.Name+' is REGISTERED!',BAD); | |
Player.WriteConsole('Use "/login password" to login or you will be kicked in '+inttostr(KickTime)+' seconds', BAD); | |
PlayerInfo[Player.ID].KickTimer := KickTime; | |
end; | |
end; | |
'off': begin | |
Player.WriteConsole('Autologin disabled, please login!', BAD); | |
Player.WriteConsole('The nickname '+Player.Name+' is REGISTERED!',BAD); | |
Player.WriteConsole('Use "/login password" to login or you will be kicked in '+inttostr(KickTime)+' seconds', BAD); | |
PlayerInfo[Player.ID].KickTimer := KickTime; | |
end; | |
end; | |
end; | |
Procedure AutoReg(Player: TActivePlayer); | |
var NameCahe: string; MultiAccList: array of string; LostSearch:boolean; i,FindsAcc, TextArrayNum: integer; SearchID: int64; | |
begin | |
if (length(Player.Name) > 24) then begin | |
Player.WriteConsole('...your name is over 24 characters, please change it.',BAD); | |
Player.Kick(TKickConsole); exit; | |
end; | |
if (lowercase(Player.Name) = 'major') then begin | |
Player.WriteConsole('Change the nickname to use statistics.',BAD); | |
exit; | |
end; | |
if (AutoRegister>0) then begin | |
if (MaxCreatedAccounts>0) then begin | |
SearchID := 2; SetArrayLength(MultiAccList, GetArrayLength(MultiAccList)+1); | |
while (true) do begin | |
if (SearchID > Memory.Count-1) then break; | |
if (Player.HWID = GetPiece(Memory[SearchID],'%ip%',0)) then begin | |
NameCahe := Memory[SearchID-2]; delete(NameCahe,1,6); | |
FindsAcc := FindsAcc+1; | |
if (Length(MultiAccList[TextArrayNum]+NameCahe)<115) then MultiAccList[TextArrayNum] := MultiAccList[TextArrayNum]+NameCahe+', ' else | |
begin | |
TextArrayNum := TextArrayNum+1; SetArrayLength(MultiAccList, GetArrayLength(MultiAccList)+1); | |
MultiAccList[TextArrayNum] := MultiAccList[TextArrayNum]+NameCahe+', '; | |
end; | |
if (DeepSearch < 1) then if (FindsAcc = MaxCreatedAccounts) then begin | |
LostSearch := true; | |
break; | |
end; | |
end; | |
SearchID:=SearchID+DataLinesNum; | |
end; | |
if (FindsAcc<MaxCreatedAccounts) then begin | |
AddNewPlayerToMemory(Player,''); PlayerInfo[Player.ID].NickStatus := true; | |
Player.WriteConsole('Nickname '+Player.Name+' successfully auto registered!',GOOD); | |
Player.WriteConsole('To better protect account add password /addpassword <password>',GOOD); | |
Player.WriteConsole('We will automatically you to login via HWID you can change the IP or add a password and disable autologin.',GOOD); | |
if (FindsAcc>0) then begin | |
Player.WriteConsole('We find your '+inttostr(FindsAcc)+' other accounts, if other account is your family nothing happens.',BAD); | |
Player.WriteConsole('The number of accounts is limited. Creating multiaccounts can result ban.',BAD); | |
Player.WriteConsole('Next time try login on old account and use /changenick <password> <newnick>.',BAD); | |
Player.WriteConsole('Your, other accounts names list: ',BAD); | |
if (LostSearch) then Player.WriteConsole('(We can not display all results. If you don`t found, enter the more accurate phrase.) ',BAD); | |
for i := 0 to GetArrayLength(MultiAccList)-1 do begin | |
if (MultiAccList[i]<>'') then begin | |
if (copy(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i]))=', ') or (copy(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i]))=',') then delete(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i])); | |
while (length(MultiAccList[i])<125) do MultiAccList[i]:=MultiAccList[i]+' '; | |
Player.WriteConsole(MultiAccList[i],BAD); | |
end; | |
end; | |
end; | |
end else | |
begin | |
Player.WriteConsole('Was reached the maximum limit accounts.',BAD); | |
Player.WriteConsole('Try login on old account and use /changenick <pass> <newname>',BAD); | |
Player.WriteConsole('Your, other accounts names list: ',BAD); | |
if (LostSearch) then Player.WriteConsole('(We can not display all results. If you don`t found, enter the more accurate phrase.) ',BAD); | |
for i := 0 to GetArrayLength(MultiAccList)-1 do begin | |
if (MultiAccList[i]<>'') then begin | |
if (copy(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i]))=', ') or (copy(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i]))=',') then delete(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i])); | |
while (length(MultiAccList[i])<125) do MultiAccList[i]:=MultiAccList[i]+' '; | |
Player.WriteConsole(MultiAccList[i],BAD); | |
end; | |
end; | |
end; | |
end else | |
begin | |
AddNewPlayerToMemory(Player,''); PlayerInfo[Player.ID].NickStatus := true; | |
Player.WriteConsole('Nickname '+Player.Name+' successfully auto registered!',GOOD); | |
Player.WriteConsole('To better protect account add password /addpassword <password>',GOOD); | |
Player.WriteConsole('We will automatically you to login via HWID you can change the IP or add a password and disable autologin.',GOOD); | |
end; | |
end else | |
begin | |
Player.WriteConsole('The nickname '+Player.Name+' is not registered!',GOOD); | |
Player.WriteConsole('To protect your nickname type: /create <yourpasswordhere>',GOOD); | |
end; | |
end; | |
function RandomPassword(passtype: byte): string; | |
var StrPass: array[1..4] of string; StringToRandom: string; len:byte; | |
begin | |
StrPass[1]:='abcdefghijklmnopqrstuvwxyz'; | |
StrPass[2]:='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | |
StrPass[3]:='1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | |
StrPass[4]:='!#%+{}[]()<>:=?@1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | |
StringToRandom:=StrPass[passtype]; | |
case (passtype) of 1: len := 6; 2: len := 8; 3: len := 10; 4: len := 10; end; | |
Result := ''; repeat Result := Result + StringToRandom[Random(1,Length(StringToRandom) + 1)]; until (Length(Result) = len); | |
end; | |
procedure DisplayTop(Player: TActivePlayer; Text: string); | |
var TopMin,TopMax,SelectID,SaveSearch,Polowa,RandomNum,i,cc,b,MaxNum,MinNum: int64; EasterEgg, TempText:string; MaxLenght:byte; Len:integer; TempIndexID:int64; | |
begin | |
Len:=TempRank.Count-1; | |
if (Len > 0) then begin | |
if (Length(Text)=4) then begin | |
TopMin := 0; TopMax := TopLines-1; | |
SelectID:=trunc(TopLines/2); | |
if (TopMax>Len) then TopMax:=Len; | |
end else | |
begin | |
try | |
delete(Text,1,5); | |
SelectID:=strtoint(text); | |
SaveSearch:=SelectID; | |
except | |
TempIndexID := FindPlayer(Player,text,false); | |
if (TempIndexID>-1) then begin | |
SelectID := TempRank.IndexOf(ReadPlayer(TempIndexID,'points')+':'+ReadPlayer(TempIndexID,'name'))+1; | |
SaveSearch := SelectID; | |
end else | |
begin | |
RandomNum:=Random(1,31); | |
if (RandomNum=14) then EasterEgg := inttostr(Random(1,31))+' (Script create by Dominik)' else EasterEgg := inttostr(RandomNum); | |
Player.WriteConsole('Please enter number, example !top '+EasterEgg+' or !top <partname|fullname>',BAD); | |
exit; | |
end; | |
end; | |
if (SelectID<>0) then begin | |
if (SelectID>0) then begin | |
Polowa := trunc(TopLines/2); | |
if (SelectID+Polowa>len) then SelectID := SelectID+(len+1-SelectID-Polowa); | |
if (SelectID-Polowa<1) then SelectID := SelectID-(SelectID-Polowa); | |
TopMin := (SelectID-1-Polowa); | |
if (TopMin<0) then TopMin:=0; | |
TopMax := (SelectID-1+Polowa); | |
if (TopMax>len) then TopMax:=len; | |
end else | |
begin | |
Player.WriteConsole('The number must be not less than 0.',BAD); | |
exit; | |
end; | |
end else | |
begin | |
Player.WriteConsole('The number can not be 0.',BAD); | |
exit; | |
end; | |
end; | |
Players.WriteConsole('Top '+inttostr(TopMin+1)+'-'+inttostr(TopMax+1)+':',Good); | |
for i := TopMin to TopMax do begin | |
if (Length(inttostr(i+1))>MaxNum) then MaxNum:=Length(inttostr(i+1)); | |
if (Length(GetPiece(TempRank[i],':',1))>MaxLenght) then MaxLenght:=Length(GetPiece(TempRank[i],':',1)); | |
end; | |
MinNum:=Length(inttostr(TopMin+1)); | |
for i := TopMin+1 to TopMax do if (Length(inttostr(i+1))<MinNum) then MinNum:=Length(inttostr(i+1)); | |
for i := TopMin to TopMax do begin | |
if (MaxNum-1>0) and (Length(inttostr(i+1))<MaxNum) then for b := 0 to MaxNum-1-MinNum do temptext:=temptext+' '; | |
cc := Round((MaxLenght-Length(GetPiece(TempRank[i],':',1)))/2); | |
if (cc>0) then for b := 1 to cc do temptext:=temptext+' '; | |
temptext:=temptext+GetPiece(TempRank[i],':',1); | |
if (MinNum<MaxNum) then while Length(temptext)<MaxLenght+(MaxNum-MinNum)-iif(Length(inttostr(i+1))-1=MaxNum-1,1,0) do temptext:=temptext+' '; | |
if (MinNum=MaxNum) then while Length(temptext)<MaxLenght+(MaxNum-MinNum) do temptext:=temptext+' '; | |
temptext:=temptext+' - '+GetPiece(TempRank[i],':',0)+' pts.'; | |
if (i=SaveSearch-1) then begin | |
if (GetPiece(TempRank[i],':',1)=Player.Name) then Players.WriteConsole(inttostr(i+1)+'. '+temptext+' <---YOU---',IndicatedCollor) else Players.WriteConsole(inttostr(i+1)+'. '+temptext,IndicatedCollor); | |
temptext:=''; continue; | |
end; | |
if (i=0) then begin | |
if (GetPiece(TempRank[i],':',1)=Player.Name) then Players.WriteConsole(inttostr(i+1)+'. '+temptext+' <---YOU---',Top1PlayerC) else Players.WriteConsole(inttostr(i+1)+'. '+temptext,Top1PlayerC); | |
temptext:=''; continue; | |
end; | |
if (i=1) then begin | |
if (GetPiece(TempRank[i],':',1)=Player.Name) then Players.WriteConsole(inttostr(i+1)+'. '+temptext+' <---YOU---',Top2PlayerC) else Players.WriteConsole(inttostr(i+1)+'. '+temptext,Top2PlayerC); | |
temptext:=''; continue; | |
end; | |
if (i=2) then begin | |
if (GetPiece(TempRank[i],':',1)=Player.Name) then Players.WriteConsole(inttostr(i+1)+'. '+temptext+' <---YOU---',Top3PlayerC) else Players.WriteConsole(inttostr(i+1)+'. '+temptext,Top3PlayerC); | |
temptext:=''; continue; | |
end; | |
if (GetPiece(TempRank[i],':',1)=Player.Name) then begin | |
Players.WriteConsole(inttostr(i+1)+'. '+temptext+' <---YOU---',YourPosCollorInTop); | |
temptext:=''; continue; | |
end; | |
if (i = TopMin) or (i = topmax) then begin | |
Players.WriteConsole(inttostr(i+1)+'. '+temptext+' ',MidEndCollor); | |
temptext:=''; continue; | |
end; | |
if (i=selectid-1) then begin Players.WriteConsole(inttostr(i+1)+'. '+temptext,MidEndCollor); temptext:=''; end else begin Players.WriteConsole(inttostr(i+1)+'. '+temptext,Good); temptext:=''; end; | |
end; | |
end else Player.WriteConsole('There are no registered players.',BAD); | |
end; | |
procedure RestartAllStats(Player:TActivePlayer); | |
var Licznik, TempIndexID: int64; kd:double; b: byte; | |
begin | |
if (Memory.Count>1) then begin | |
Licznik:=0; | |
repeat | |
Memory[Licznik+3]:=inttostr(PointsForStart); | |
Memory[Licznik+6]:='0%k%0%d%0%s%0%t%0%dt%0%p%0%a%0%r%0%z%0%w%0'; | |
Memory[Licznik+7]:='0%fg%0%fr%0%fs%0%fd%0%ac%0%bc%0%ir%0%ib%0%hr%0'; | |
Memory[Licznik+8]:='0%w%0%l%0%r%0%aw%0%al%0%bw%0%bl%0%cw%0%cl%0%dw%0'; | |
Memory[Licznik+9]:='0%s%0%sh%0'; | |
Licznik:=Licznik+DataLinesNum; | |
kd := ((Licznik*100.0)/single(Memory.Count)); | |
for b := 1 to 32 do if (Players[b].Active) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[b].Name); | |
if (TempIndexID>-1) and (ReadPlayer(TempIndexID,'bigtext')='1') then continue; | |
Players[b].BigText(BigTextLayer+1,'Restarted all statistics: '+formatfloat('0',kd)+'%',BigTextTime,RGB(204-Round((102*KD)/100.0),51+Round((153*KD)/100.0),0+Round((102*KD)/100.0)),0.075,20,410); | |
end; | |
until (Licznik>=Memory.Count); | |
WriteLn('[ZitroFUN] Restarted all statistics: By: '+Player.Name+', HWID: '+Player.HWID+', IP: '+Player.IP); | |
Memory.SaveToFile(PatchCore+'accounts.db'); LoadList(); | |
Player.WriteConsole('Restarted all statistics!',GOOD); | |
end else Player.WriteConsole('No registered accounts.',BAD); | |
end; | |
procedure HyperSafePassword(); | |
var Temp: TStringList; LogFileName: string; CurrTim: TDateTime; kd:double; i: int64; b:byte; TempIndexID:int64; | |
begin | |
CurrTim:=date(); | |
for i := ServerLogsLostPack downto 1 do if (File.Exists('logs/consolelog-'+FormatDateTime('YY-mm-dd',CurrTim)+'-'+iif(i<10,'0'+inttostr(i),inttostr(i))+'.txt')) then begin LogFileName := 'logs/consolelog-'+FormatDateTime('YY-mm-dd',CurrTim)+'-'+iif(i<10,'0'+inttostr(i),inttostr(i))+'.txt'; break; end; | |
Temp := File.CreateStringListFromFile(LogFileName); | |
for i := 0 to Temp.Count-1 do begin | |
if (ContainsString(lowercase(temp[i]),'/create')) or (ContainsString(lowercase(temp[i]),'/login')) or (ContainsString(lowercase(temp[i]),'/changepass')) or (ContainsString(lowercase(temp[i]),'/changenick')) or (ContainsString(lowercase(temp[i]),'/addpassword')) or (ContainsString(lowercase(temp[i]),'/changemail ')) or (ContainsString(lowercase(temp[i]),'/randompass')) then temp.delete(i); | |
kd := ((i*100.0)/single(Temp.Count-1.0)); | |
for b := 1 to 32 do if (Players[b].Active) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[b].Name); | |
if (TempIndexID>-1) and (ReadPlayer(TempIndexID,'bigtext')='1') then continue; | |
Players[b].BigText(BigTextLayer+2,'Clearing logs: '+formatfloat('0',kd)+'%',BigTextTime,RGB(204-Round((102*KD)/100.0),51+Round((153*KD)/100.0),0+Round((102*KD)/100.0)),0.075,20,400); | |
end; // Smoth RGB 204 51 0 ==> 102 204 102 | |
end; | |
Temp.SaveToFile(LogFileName); | |
end; | |
function Commands(Player: TActivePlayer; Text: string): Boolean; | |
var NameCahe, GeneratedPassword: string; MultiAccList: array of string; passtype:byte; LostSearch: boolean; i,FindsAcc,TextArrayNum:integer; SearchID,c,b,TempIndexID:int64; CurrTim,CurrTim2: TDateTime; MailList: TStringList; temp: byte; | |
begin | |
Result := false; | |
if (Copy(Text,1,7)='/create') then begin | |
delete(text,1,8); | |
if (Text <> '') then begin | |
if (Memory.IndexOf('%name%'+Player.Name)=-1) then begin | |
if (PlayerInfo[Player.ID].NickStatus = false) then begin | |
if (Text <> '') then begin | |
if (ExecRegExpr(' ',text)=false) then begin | |
if (length(Text) < 17) then begin | |
if (lowercase(Player.Name) = 'major') then begin | |
Player.WriteConsole('Registration for players with nick major have been disable!',BAD); | |
exit; | |
end else | |
begin | |
if (MaxCreatedAccounts>0) then begin | |
SearchID := 2; SetArrayLength(MultiAccList, GetArrayLength(MultiAccList)+1); | |
while (true) do begin | |
if (SearchID > Memory.Count-1) then break; | |
if (Player.HWID = GetPiece(Memory[SearchID],'%ip%',0)) then begin | |
NameCahe := Memory[SearchID-2]; delete(NameCahe,1,6); | |
FindsAcc := FindsAcc+1; | |
if (Length(MultiAccList[TextArrayNum]+NameCahe)<115) then MultiAccList[TextArrayNum] := MultiAccList[TextArrayNum]+NameCahe+', ' else | |
begin | |
TextArrayNum := TextArrayNum+1; SetArrayLength(MultiAccList, GetArrayLength(MultiAccList)+1); | |
MultiAccList[TextArrayNum] := MultiAccList[TextArrayNum]+NameCahe+', '; | |
end; | |
if (DeepSearch < 1) then if (FindsAcc = MaxCreatedAccounts) then begin | |
LostSearch := true; | |
break; | |
end; | |
end; | |
SearchID:=SearchID+DataLinesNum; | |
end; | |
if (FindsAcc<MaxCreatedAccounts) then begin | |
AddNewPlayerToMemory(Player, MD5Issue(Text)); PlayerInfo[Player.ID].NickStatus := true; | |
Player.WriteConsole('Nickname '+Player.Name+' successfully registered!',GOOD); | |
Player.WriteConsole('Your password is '+Text+' - do not forget it!',GOOD); | |
Player.WriteConsole('To prove that you really are later, use "/login ' + Text + '" to login.',GOOD); | |
if (FindsAcc>0) then begin | |
Player.WriteConsole('We find your '+inttostr(FindsAcc)+' other accounts, if other account is your family nothing happens.',BAD); | |
Player.WriteConsole('The number of accounts is limited. Creating multiaccounts can result ban.',BAD); | |
Player.WriteConsole('Next time try login on old account and use /changenick <password> <newnick>.',BAD); | |
Player.WriteConsole('Your, other accounts names list: ',BAD); | |
if (LostSearch) then Player.WriteConsole('(We can not display all results. If you don`t found, enter the more accurate phrase.) ',BAD); | |
for i := 0 to GetArrayLength(MultiAccList)-1 do begin | |
if (MultiAccList[i]<>'') then begin | |
if (copy(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i]))=', ') or (copy(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i]))=',') then delete(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i])); | |
while (length(MultiAccList[i])<125) do MultiAccList[i]:=MultiAccList[i]+' '; | |
Player.WriteConsole(MultiAccList[i],BAD); | |
end; | |
end; | |
end; | |
end else | |
begin | |
Player.WriteConsole('Was reached the maximum limit accounts.',BAD); | |
Player.WriteConsole('Try login on old account and use /changenick <pass> <newname>',BAD); | |
Player.WriteConsole('Your, other accounts names list: ',BAD); | |
if (LostSearch) then Player.WriteConsole('(We can not display the entire list of players by restricting the view.) ',BAD); | |
for i:= 0 to GetArrayLength(MultiAccList)-1 do begin | |
if (MultiAccList[i]<>'') then begin | |
if (copy(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i]))=', ') or (copy(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i]))=',') then delete(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i])); | |
while (length(MultiAccList[i])<125) do MultiAccList[i]:=MultiAccList[i]+' '; | |
Player.WriteConsole(MultiAccList[i],BAD); | |
end; | |
end; | |
end; | |
end else | |
begin | |
AddNewPlayerToMemory(Player, MD5Issue(Text)); PlayerInfo[Player.ID].NickStatus := true; | |
Player.WriteConsole('Nickname '+Player.Name+' successfully registered!',GOOD); | |
Player.WriteConsole('Your password is '+Text+' - do not forget it!',GOOD); | |
Player.WriteConsole('To prove that you really are later, use "/login '+Text+'" to login.',GOOD); | |
end; | |
end; | |
end else Player.WriteConsole('Max length password is 16 characters!',BAD); | |
end else Player.WriteConsole('Your password can not contain spaces.',BAD); | |
end else Player.WriteConsole('No password found. Please try again.',BAD); | |
end else Player.WriteConsole('You are logged in, please logout and try again.',BAD); | |
end else Player.WriteConsole('You are already a registered user!',BAD); | |
exit; | |
end; | |
Player.WriteConsole('Plese use /create <password>',BAD); exit; | |
end; | |
if (Copy(Text,1,11)='/changepass') then begin | |
delete(Text,1,12); | |
if (Text <> '') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID > -1) then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
if (MD5Issue(GetPiece(Text,' ',0)) = ReadPlayer(TempIndexID,'password')) then begin | |
delete(Text,1,Length(GetPiece(Text,' ',0))+1); | |
if (ExecRegExpr(' ',text) = false) then begin | |
if (length(Text) < 17) then begin | |
ChangeState(TempIndexID,'password',Text); | |
Player.WriteConsole('Password changed to: '+Text+' Remember it!',GOOD); | |
end else Player.WriteConsole('Max length password is 16 characters!',BAD); | |
end else Player.WriteConsole('Your password can not contain spaces.',BAD); | |
end else Player.WriteConsole('Wrong password!',BAD); | |
end else Player.WriteConsole('Please login first!',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); | |
exit; | |
end; | |
Player.WriteConsole('Plese use /changepass <old_password> <new_password>',BAD); exit; | |
end; | |
if (Copy(Text,1,11)='/changenick') then begin | |
delete(Text,1,12); | |
if (Text <> '') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID > -1) then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
if (MD5Issue(GetPiece(Text,' ',0)) = ReadPlayer(TempIndexID,'password')) then begin | |
delete(Text,1,Length(GetPiece(Text,' ',0))+1); | |
if (length(Text) < 25) then begin | |
if (lowercase(Text) <> 'major') then begin | |
if (Memory.IndexOf('%name%'+Text) = -1) then begin | |
ChangeState(TempIndexID,'name',Text); PlayerInfo[Player.ID].NickStatus:=false; | |
Player.WriteConsole('We now logout you. Nickname changed to: '+Text,GOOD); | |
Player.WriteConsole('Please rejoin the server with your new nick to load your new profile.',GOOD); | |
end else Player.WriteConsole('That nickname is already taken!',BAD); | |
end else Player.WriteConsole('You can not change your nick to Major!',BAD); | |
end else Player.WriteConsole('Nickname is over 24 characters, please pick another.',BAD); | |
end else Player.WriteConsole('Wrong Password!',BAD); | |
end else Player.WriteConsole('Please login first!',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); | |
exit; | |
end; | |
Player.WriteConsole('Plese use /changenick <password> <newnick>',BAD); exit; | |
end; | |
if (Copy(Text,1,6)='/login') then begin | |
delete(Text,1,7); | |
if (Text <> '') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID > -1) then begin | |
if (PlayerInfo[Player.ID].NickStatus = false) then begin | |
if (MD5Issue(Text) = ReadPlayer(TempIndexID,'password')) then begin | |
if (ReadPlayer(TempIndexID,'autologin')<>'off') then begin | |
if (ReadPlayer(TempIndexID,'autologin')='hwid') and (Player.HWID <> ReadPlayer(TempIndexID,'hwid')) then begin | |
ChangeState(TempIndexID,'hwid',Player.HWID); | |
Player.WriteConsole('We detect your new computer, now you be autologin on this computer.',GOOD); | |
Player.WriteConsole('We use HWID to autologin, if you login on other computer we change you hwid again after logging.',GOOD); | |
Player.WriteConsole('On the old computer, you will need to again manually login and then will again autologin.',GOOD); | |
end; | |
if (ReadPlayer(TempIndexID,'autologin')='ip') and (Player.IP <> ReadPlayer(TempIndexID,'ip')) then begin | |
ChangeState(TempIndexID,'ip',Player.IP); | |
Player.WriteConsole('We detect your new IP address, now you be autologin on this computer.',GOOD); | |
Player.WriteConsole('We use IP to autologin, if you login on other computer we change you IP again after logging.',GOOD); | |
Player.WriteConsole('On the old IP address, you will need to again manually login and then will again autologin.',GOOD); | |
end; | |
end; | |
PlayerInfo[Player.ID].NickStatus:=true; PlayerInfo[Player.ID].KickTimer:=0; | |
Player.WriteConsole('You are now logged in!',GOOD); | |
end else Player.WriteConsole('Wrong password.',BAD); | |
end else Player.WriteConsole('You are already logged in!',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); | |
exit; | |
end; | |
Player.WriteConsole('Plese use /login <password>',BAD); exit; | |
end; | |
if (Text = '/logout') then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
PlayerInfo[Player.ID].NickStatus := false; | |
PlayerInfo[Player.ID].KickTimer := KickTime; | |
Player.WriteConsole('You has been logged out!',GOOD); | |
Player.WriteConsole('Type /login ''password'' to login.',GOOD); | |
end else Player.WriteConsole('Already logged out!',BAD); | |
exit; | |
end; | |
if (Copy(Text,1,10)='/autologin') then begin | |
delete(text,1,11); text := lowercase(text); | |
if (Text <> '') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID > -1) then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
case text of | |
'off': begin | |
if (ReadPlayer(TempIndexID,'password') <> '') then begin | |
ChangeState(TempIndexID,'autologin','off'); | |
Player.WriteConsole('You have disabled auto login.',GOOD); | |
end else | |
begin | |
Player.WriteConsole('Unfortunately you do not have a password, we can not change the autologin.',BAD); | |
Player.WriteConsole('Add a password and can try again. To add please use /addpassword <password>',BAD); | |
end; | |
end; | |
'ip': begin | |
ChangeState(TempIndexID,'autologin','ip'); | |
Player.WriteConsole('AutoLogin changed to: IP',GOOD); | |
end; | |
'hwid': begin | |
ChangeState(TempIndexID,'autologin','hwid'); | |
Player.WriteConsole('AutoLogin changed to: HWID',GOOD); | |
end; | |
'nick': begin | |
ChangeState(TempIndexID,'autologin','nick'); | |
Player.WriteConsole('AutoLogin changed to: NICK',GOOD); | |
Player.WriteConsole('Your account is now not protected!',BAD); | |
end; | |
end; | |
if (ExecRegExpr('^(off|hwid|ip|nick)$',text) = false) then Player.WriteConsole('Please select the type of AutoLogin: "IP" or "HWID" or "OFF" or "NICK".',BAD); | |
exit; | |
end else Player.WriteConsole('Please login first!',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); //Dominik | |
end; | |
Player.WriteConsole('Plese use /autologin <IP|HWID|NICK|OFF>',BAD); exit; | |
end; | |
if (Copy(Text,1,12)='/addpassword') then begin | |
delete(text,1,13); | |
if (Text <> '') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID > -1) then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
if (ReadPlayer(TempIndexID,'password') = '') then begin | |
if (Text <> '') then begin | |
if (ExecRegExpr(' ',text)=false) then begin | |
ChangeState(TempIndexID,'password',Text); | |
Player.WriteConsole('Added password: '+Text+'. Remember this!',GOOD); | |
end else Player.WriteConsole('Your password can not contain spaces.',BAD); | |
end else Player.WriteConsole('No password found. Please try again.',BAD); | |
end else Player.WriteConsole('You already have a password, please use to change "/changepass <old_password> <new_password>"',BAD); | |
end else Player.WriteConsole('You are not logged in, login or join again.',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); | |
exit; | |
end; | |
Player.WriteConsole('Plese use /addpassword <your_password>',BAD); exit; | |
end; | |
if (Copy(Text,1,8)='/addmail') then begin | |
delete(text,1,9); | |
if (Text <> '') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID > -1) then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
if (ReadPlayer(TempIndexID,'password') <> '') then begin | |
if (ReadPlayer(TempIndexID,'mail') = '') then begin | |
if (Text <> '') then begin | |
if (ExecRegExpr('(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)',text)) then begin | |
ChangeState(TempIndexID,'mail',Text); | |
Player.WriteConsole('Added mail: '+text+' Remember this!',GOOD); | |
end else Player.WriteConsole('Your mail is incorrect.',BAD); | |
end else Player.WriteConsole('No mail found. Please try again.',BAD); | |
end else Player.WriteConsole('You already have a mail ('+ReadPlayer(TempIndexID,'mail')+') please use to change "/changemail <password> <new_mail>"',BAD); | |
end else Player.WriteConsole('You must first add a password, use /addpassword <password> to add.',BAD); | |
end else Player.WriteConsole('You are not logged in, login or join again.',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); | |
exit; | |
end; | |
Player.WriteConsole('Plese use /addmail <your e-mail>',BAD); exit; | |
end; | |
if (Copy(Text,1,11)='/changemail') then begin | |
delete(text,1,12); | |
if (Text <> '') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID > -1) then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
if (ReadPlayer(TempIndexID,'mail') <> '') then begin | |
if (MD5Issue(GetPiece(Text,' ',0)) = ReadPlayer(TempIndexID,'password')) then begin | |
delete(Text,1,Length(GetPiece(Text,' ',0))+1); | |
if (Text <> '') then begin | |
if (ExecRegExpr('(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)',text)) then begin | |
ChangeState(TempIndexID,'mail',Text); | |
Player.WriteConsole('Mail changed to: '+Text+' Remember this!',GOOD); | |
end else Player.WriteConsole('Your mail is incorrect.',BAD); | |
end else Player.WriteConsole('No mail found. Please try again.',BAD); | |
end else Player.WriteConsole('Wrong password!',BAD); | |
end else Player.WriteConsole('You haven`t added an email. Typue /addmail <mail> to add your mail.',BAD); | |
end else Player.WriteConsole('Please login first!',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); | |
exit; | |
end; | |
Player.WriteConsole('Plese use /changemail <password> <new_mail>',BAD); exit; | |
end; | |
if (text = '/memail') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (ReadPlayer(TempIndexID,'mail')<>'') then Player.WriteConsole('Your added address e-mail is: '+ReadPlayer(TempIndexID,'mail'),GOOD) else Player.WriteConsole('You haven`t added an email yet. Type /addmail <e-mail> to add.',GOOD); | |
exit; | |
end; | |
if (Copy(Text,1,11)='/lastplayed') then begin | |
delete(text,1,12); | |
if (Text <> '') then begin | |
TempIndexID := FindPlayer(Player,Text,true); | |
if (TempIndexID > -1) then Player.WriteConsole('Player '+ReadPlayer(TempIndexID,'name')+' seen lately: '+ReadPlayer(TempIndexID,'lastplay'),GOOD); | |
exit; | |
end; | |
Player.WriteConsole('Plese use /lastplayed <fullname|partname>',BAD); exit; | |
end; | |
if (Copy(Text,1,13)='/registerdate') then begin | |
delete(text,1,14); | |
if (Text <> '') then begin | |
TempIndexID := FindPlayer(Player,Text,true); | |
if (TempIndexID > -1) then Player.WriteConsole('Player '+ReadPlayer(TempIndexID,'name')+' registered on: '+ReadPlayer(TempIndexID,'registerdate'),GOOD); | |
exit; | |
end; | |
Player.WriteConsole('Plese use /registerdate <fullname|partname>',BAD); exit; | |
end; | |
if (Text='/switchdisplay') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID > -1) then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
if (ReadPlayer(TempIndexID,'bigtext')='0') then begin | |
ChangeState(TempIndexID,'bigtext','1'); | |
Player.WriteConsole('Disabled display information on the screen.',GOOD); | |
end else | |
begin | |
ChangeState(TempIndexID,'bigtext','0'); | |
Player.WriteConsole('Enabled display information on the screen.',GOOD); | |
end; | |
end else Player.WriteConsole('Please login first!',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); | |
exit; | |
end; | |
if (Copy(Text,1,7)='/search') then begin | |
delete(text,1,8); | |
if (Text <> '') then begin | |
Text := lowercase(Text); SetArrayLength(MultiAccList, GetArrayLength(MultiAccList)+1); | |
for c := TempPlayersList.Count-1 downto 0 do begin | |
NameCahe := GetPiece(TempPlayersList[c],'%name%',1); | |
if (ContainsString(NameCahe,text)) then begin | |
FindsAcc := FindsAcc+1; | |
if (Length(MultiAccList[TextArrayNum]+NameCahe)<115) then MultiAccList[TextArrayNum] := MultiAccList[TextArrayNum]+NameCahe+', ' else | |
begin | |
TextArrayNum := TextArrayNum+1; | |
if (TextArrayNum>MaxSearchLines-1) then begin | |
LostSearch := true; | |
break; | |
end; | |
SetArrayLength(MultiAccList, GetArrayLength(MultiAccList)+1); | |
MultiAccList[TextArrayNum] := MultiAccList[TextArrayNum]+NameCahe+', '; | |
end; | |
end; | |
SearchID:=SearchID+DataLinesNum; | |
end; | |
if (FindsAcc>0) then begin | |
Player.WriteConsole('Search for "'+Text+'" and find '+inttostr(FindsAcc)+' result:',GOOD); | |
if (LostSearch) then Player.WriteConsole('(We can not display all results. If you don`t found, enter the more accurate phrase.) ',BAD); | |
for i := 0 to GetArrayLength(MultiAccList)-1 do begin | |
if (MultiAccList[i]<>'') then begin | |
if (copy(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i]))=', ') or (copy(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i]))=',') then delete(MultiAccList[i],length(MultiAccList[i])-1,length(MultiAccList[i])); | |
while (length(MultiAccList[i])<125) do MultiAccList[i]:=MultiAccList[i]+' '; | |
Player.WriteConsole(MultiAccList[i],GOOD); | |
end; | |
end; | |
end else Player.WriteConsole('Search for "'+Text+'" and nothing found.',BAD); | |
exit; | |
end; | |
Player.WriteConsole('Plese use /search <fullname|partname>',BAD); exit; | |
end; | |
if (Copy(Text,1,11)='/randompass') then begin | |
delete(Text,1,12); | |
if (Text <> '') then begin | |
try PassType := strtoint(GetPiece(Text,' ',0)); except Player.WriteConsole('Wrong password strength. Must be a number 1-4.',BAD); exit; end; | |
if (PassType>0) and (PassType<5) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (ReadPlayer(TempIndexID,'password')='') then begin | |
GeneratedPassword := RandomPassword(PassType); | |
ChangeState(TempIndexID,'password',GeneratedPassword); | |
Player.WriteConsole('Your new generated password: '+GeneratedPassword+' Remember this!',BAD); | |
end else | |
begin | |
delete(Text,1,Length(GetPiece(Text,' ',0))+1); | |
if (Text<>'') then begin | |
if (MD5Issue(text) = ReadPlayer(TempIndexID,'password')) then begin | |
GeneratedPassword := RandomPassword(PassType); | |
ChangeState(TempIndexID,'password',GeneratedPassword); | |
Player.WriteConsole('Your new generated password: '+GeneratedPassword+' Remember this!',BAD); | |
end else Player.WriteConsole('Wrong password!',BAD); | |
end else Player.WriteConsole('No password entered.',BAD); | |
end; | |
end else Player.WriteConsole('Password strength must be between 1-4.',BAD); | |
exit; | |
end; | |
Player.WriteConsole('Plese use /randompass <1-4> or /randompass <1-4> <password> if already have password.',BAD); | |
end; | |
if (lowercase(text) = '/bal') then if (Player.Team <> 5) then if ((Game.GameStyle = 3) or (Game.GameStyle = 5)) then if (bal.lastbalance > 0) then begin | |
if (TimeLeft <= 10) then begin | |
Player.writeconsole('Less than 10 seconds left. Balance is disabled.',BAD); | |
exit; | |
end; | |
if (bal.lastbalance < 15) then begin | |
Player.writeconsole('Last balance was less than 15 s ago. Please be patient.',BAD); | |
exit; | |
end; | |
Player.writeconsole('Checking balance. If nothing happens, teams are balanced.',GOOD); | |
bal.mode := 4; | |
Balance(true, false); | |
end; | |
//---- ADMIN COMMANDS --- | |
if (Player.IsAdmin) then begin | |
if (LowerCase(Copy(Text,1,10))='/deleteacc') then begin | |
delete(Text,1,11); | |
while (true) do begin | |
if (c>=Memory.Count) then begin | |
Player.WriteConsole('Not found ('+Text+')',GOOD); | |
exit; | |
end; | |
if (ContainsString(Memory[c],text)) then begin | |
Command('/kick '+inttostr(NameToID(GetPiece(Memory[c],'%name%,',1)))); | |
WriteLn('[ZitroFUN] Delete account: '+GetPiece(Memory[c],'%name%',1)+' By: '+Player.Name+', HWID: '+Player.HWID+', IP: '+Player.IP); | |
Player.WriteConsole('PLAYER: '+Player.Name+', HWID: '+Player.HWID+', IP: '+Player.IP+' - DELETE ACCOUNT PLAYER: '+GetPiece(Memory[c],'%name%',1),GOOD); | |
for b := (c+DataLinesNum-1) downto c do Memory.Delete(b); | |
exit; | |
end; | |
c:=c+DataLinesNum; | |
end; | |
exit; | |
end; | |
if (Copy(Text,1,16)='/generatenewpass') then begin | |
delete(Text,1,17); | |
if (Text <> '') then begin | |
try PassType := strtoint(GetPiece(Text,' ',0)); except Player.WriteConsole('Wrong password strength. Must be a number 1-4.',BAD); exit; end; | |
if (PassType>0) and (PassType<5) then begin | |
delete(Text,1,Length(GetPiece(Text,' ',0))+1); | |
if (Text<>'') then begin | |
TempIndexID := FindPlayer(Player,Text,true); | |
if (TempIndexID>-1) then begin | |
if (ReadPlayer(TempIndexID,'mail') <> '') then begin | |
GeneratedPassword := RandomPassword(PassType); | |
ChangeState(TempIndexID,'password',GeneratedPassword); | |
WriteLnFile(PatchCore+'Send-Mail.txt',ReadPlayer(TempIndexID,'mail')+' :Name: '+ReadPlayer(TempIndexID,'name')+' :AdminChange: '+Player.Name+' :Password: '+GeneratedPassword); | |
Player.WriteConsole(ReadPlayer(TempIndexID,'mail')+' :Name: '+ReadPlayer(TempIndexID,'name')+' :Password: '+GeneratedPassword,BAD); | |
end else Player.WriteConsole('The player has not provided his email!',BAD); | |
end; | |
end else Player.WriteConsole('Not specified the name of the player.',BAD); | |
end else Player.WriteConsole('Password strength must be between 1-4.',BAD); | |
exit; | |
end; | |
Player.WriteConsole('Plese use /generatenewpass <1-4> <name>',GOOD); | |
end; | |
if (text='/resetallstats') then RestartAllStats(Player); | |
if (text='/clearlogs') then HyperSafePassword(); | |
if (Copy(Text,1,13)='/backupcreate') then begin | |
delete(Text,1,14); | |
if (Text <> '') then begin | |
if (File.Exists(BackupPatch+text+'.backup')=false) then begin | |
Player.WriteConsole('Started backup created.',GOOD); | |
CurrTim:=date(); CurrTim2:=time; | |
File.Copy(PatchCore+'accounts.db',BackupPatch+text+'.backup'); | |
WriteLn('[ZitroFUN] Backup create: By: '+Player.Name+', Backup name: '+text); | |
Player.WriteConsole('Backup created completed. (File can find here: '+BackupPatch+text+'.backup)',GOOD); | |
end else Player.WriteConsole('Backup name is busy. ('+text+'.backup)',BAD); | |
end else Player.WriteConsole('No backup name specified.',BAD); | |
end; | |
if (Copy(Text,1,14)='/restorebackup') then begin | |
delete(Text,1,15); | |
if (Text <> '') then begin | |
if (File.Exists(BackupPatch+text+'.backup')) then begin | |
Player.WriteConsole('Started restore backup from '+BackupPatch+text+'.backup',GOOD); | |
File.Copy(BackupPatch+text+'.backup',PatchCore+'accounts.db'); | |
Memory := File.CreateStringListFromFile(PatchCore+'accounts.db'); LoadList(); | |
Player.WriteConsole('Backup restore completed. (From: '+BackupPatch+text+'.backup)',GOOD); | |
end else Player.WriteConsole('No backup file found. ('+text+'.backup)',BAD); | |
end else Player.WriteConsole('No backup specified.',BAD); | |
exit; | |
end; | |
if (Copy(Text,1,13)='/deletebackup') then begin | |
delete(Text,1,14); | |
if (Text <> '') then begin | |
if (File.Exists(BackupPatch+text+'.backup')) then begin | |
File.Delete(BackupPatch+text+'.backup'); | |
Player.WriteConsole('Backup delete completed. ('+BackupPatch+text+'.backup)',GOOD); | |
end else Player.WriteConsole('No backup file found. ('+text+'.backup)',BAD); | |
end else Player.WriteConsole('No backup specified.',BAD); | |
exit; | |
end; | |
if (Copy(Text,1,20)='/generatemailinglist') then begin | |
MailList := File.CreateStringList(); | |
while (SearchID < Memory.Count-1) do begin | |
if (GetPiece(Memory[SearchID+5],'%mail%',1)<>'') then MailList.Append(GetPiece(Memory[SearchID],'%name%',1)+' :: '+GetPiece(Memory[SearchID+5],'%mail%',1)); | |
SearchID:=SearchID+DataLinesNum; | |
end; | |
CurrTim:=date(); CurrTim2:=time; | |
MailList.Append('Mailing List Created By: '+Player.Name+', date: '+FormatDateTime('YYYY-mm-dd',CurrTim)+' at '+FormatDateTime('hh-nn-ss',CurrTim2)); | |
MailList.SaveToFile(PatchCore+'MailingList.txt'); | |
MailList.Free; | |
Player.WriteConsole('Creating mailing list complete.',GOOD); | |
end; | |
if (lowercase(text) = '/kickbots') or (lowercase(text) = '/kickbot') then begin | |
temp := 0; | |
for i := 1 to 32 do if (Players[i].Active) and (Players[i].Human=false) then begin | |
temp := (temp+1); | |
Players[i].Kick(TKickConsole); | |
end; | |
if (temp = 0) then Player.WriteConsole('There are no bots here!', BAD) else Players.WriteConsole('Kicked out '+inttostr(temp)+' bot(s).',GOOD); | |
exit; | |
end; | |
if (lowercase(text) = '/kickspect') or (lowercase(text) = '/kickspec') or (lowercase(text) = '/kickspecs') then begin | |
temp := 0; | |
for i := 1 to 32 do if (Players[i].Active) and (Players[i].Team=5) then begin | |
temp := (temp+1); | |
Players[i].Kick(TKickConsole); | |
end; | |
if (temp = 0) then Player.WriteConsole('There are no spectators here!',BAD) else Players.WriteConsole('Kicked out '+inttostr(temp)+' spectator(s).', GOOD); | |
exit; | |
end; | |
if (lowercase(text) = '/bal') then begin | |
if (GameStyle <> 3) and (GameStyle <> 5) then begin | |
Player.WriteConsole('Not supported GameStyle. Balance is disabled.',BAD); | |
exit; | |
end; | |
if (bal.lastcheck > Interval * 60 - 2) then exit; | |
if (TimeLeft <= 2) then begin | |
Player.WriteConsole('Less than 2 seconds left. Balance is blocked.',BAD); | |
exit; | |
end; | |
Player.writeconsole('Forcing the balance check. If nothing happens, teams are balanced.',GOOD); | |
bal.mode := 5; | |
Balance(true, false); | |
exit; | |
end; | |
if (lowercase(text) = '/shuffle') or (lowercase(text) = '/mix') then begin | |
Shuffle(Player); | |
exit; | |
end; | |
if (lowercase(getpiece(text, ' ', 0)) = '/gamemode') and (length(text) >= 11) then begin | |
result := true; | |
case (lowercase(getpiece(text, ' ', 1))) of | |
'0', 'd', 'dm', 'death', 'deathmatch' : temp := 0; | |
'1', 'p', 'pm', 'point', 'pointmatch' : temp := 1; | |
'2', 't', 'tm', 'tdm', 'team', 'teammatch': temp := 2; | |
'3', 'c', 'ctf', 'cap', 'capture' : temp := 3; | |
'4', 'r', 'rm', 'rambo', 'rambomatch' : temp := 4; | |
'5', 'i', 'inf', 'infiltration' : temp := 5; | |
'6', 'h', 'htf', 'hold', 'holdtheflag' : temp := 6; | |
else begin | |
Player.WriteConsole('ERROR: unknown gamemode.',BAD); | |
exit; | |
end; | |
end; | |
if (Game.GameStyle = temp) then begin | |
Player.WriteConsole('The gamemode you specified is already on.',BAD); | |
exit; | |
end; | |
Player.WriteConsole('Changing gamemode. Please rejoin.',GOOD); | |
Game.GameStyle := temp; | |
command('/recompile ZitroStats'); | |
exit; | |
end; | |
if (lowercase(getpiece(text, ' ', 0)) = '/swap') then begin | |
if (Game.TimeLeft <= 10) then begin | |
Player.writeconsole('Less than 10 seconds left. Swap is blocked.',BAD); | |
exit; | |
end; | |
if (lowercase(getpiece(text,' ', 1)) = 'all') then Swap(Player.ID, 0, 0) else if (length(text) >= 9) then begin | |
try | |
Swap(Player.ID, strtoint(getpiece(text, ' ', 1)), strtoint(getpiece(text, ' ', 2))); | |
except | |
Player.writeconsole('Something went wrong. Check the command and try again.', BAD); | |
end; | |
end; | |
end; | |
end; | |
end; | |
function Punkty(TempIndexID:int64): string; | |
var d, kd: double; cel, KD2, KD3: double; Temp:single; | |
begin | |
if (GameStyle = 0) or (GameStyle = 1) or (GameStyle = 4) then begin | |
Temp:=strtoint(ReadPlayer(TempIndexID,'shoots')); cel := (single(strtoint(ReadPlayer(TempIndexID,'shoothits'))*100)/iif(Temp>0,Temp,1)); if (cel > 100) then cel := 100.00; if (cel <= 0) then cel := 1; | |
Temp:=strtoint(ReadPlayer(TempIndexID,'deaths')); KD2:=(single(strtoint(ReadPlayer(TempIndexID,'teamkills')))/iif(Temp>0,Temp,1)); KD2 := strtofloat(FormatFloat('0.00',KD2)); if (KD2 <= 0) then KD2 := 1; | |
Temp:=strtoint(ReadPlayer(TempIndexID,'lose')); KD3 := (strtoint(ReadPlayer(TempIndexID,'wins'))/iif(temp>0,temp,1)); if (KD3 <= 0) then KD3 := 1; if (KD3 < 0) then KD3 := 1; | |
KD := (cel * KD2 * KD3 * Multiplier) / 3.14; if (KD > 0) then d := KD+((cel/100)*KD) else d := KD+((cel/100)*(KD*-1)); | |
if (TempRank.Count>PlayerRateRankCountMin) then d := (d*strtoint(ReadPlayer(TempIndexID,'points')))/TempRank.Count; | |
result := formatfloat('0.00',d); | |
end; | |
if (GameStyle = 2) or (GameStyle = 3) or (GameStyle = 5) or (GameStyle = 6) then begin | |
if (Game.FriendlyFire) then begin | |
Temp:=strtoint(ReadPlayer(TempIndexID,'shoots')); cel := (single(strtoint(ReadPlayer(TempIndexID,'shoothits'))*100)/iif(Temp>0,Temp,1)); if (cel > 100) then cel := 100.00; if (cel <= 0) then cel := 1; | |
Temp:=strtoint(ReadPlayer(TempIndexID,'deaths')); KD2 := (single(strtoint(ReadPlayer(TempIndexID,'kills'))-strtoint(ReadPlayer(TempIndexID,'teamkills')))/iif(Temp>0,Temp,1)); if (KD2 <= 0) then KD2 := 1; | |
Temp:=strtoint(ReadPlayer(TempIndexID,'lose')); KD3 := (strtoint(ReadPlayer(TempIndexID,'wins'))/iif(temp>0,temp,1)); if (KD3 <= 0) then KD3 := 1; if (KD3 <= 0) then KD3 := 1; if (KD3 <= 0) then KD3 := 1; | |
KD := (cel * KD2 * KD3 * Multiplier) / 3.14; if (KD > 0) then d := KD+((cel/100)*KD) else d := KD+((cel/100)*(KD*-1)); | |
if (TempRank.Count>PlayerRateRankCountMin) then d := (d*strtoint(ReadPlayer(TempIndexID,'points')))/TempRank.Count; | |
result := formatfloat('0.00',d); | |
end else | |
begin | |
Temp:=strtoint(ReadPlayer(TempIndexID,'shoots')); cel := (single(strtoint(ReadPlayer(TempIndexID,'shoothits'))*100)/iif(Temp>0,Temp,1)); if (cel > 100) then cel := 100.00; if (cel <= 0) then cel := 1; | |
Temp:=strtoint(ReadPlayer(TempIndexID,'deaths')); KD2 := (single(strtoint(ReadPlayer(TempIndexID,'kills')))/iif(Temp>0,Temp,1)); KD2 := strtofloat(FormatFloat('0.00',KD2)); if (KD2 <= 0) then KD2 := 1; | |
Temp:=strtoint(ReadPlayer(TempIndexID,'lose')); KD3 := (strtoint(ReadPlayer(TempIndexID,'wins'))/iif(temp>0,temp,1)); if (KD3 <= 0) then KD3 := 1; if (KD3 <= 0) then KD3 := 1; if (KD3 <= 0) then KD3 := 1; | |
KD := (cel * KD2 * KD3 * Multiplier) / 3.14; if (KD > 0) then d := KD+((cel/100)*KD) else d := KD+((cel/100)*(KD*-1)); | |
if (TempRank.Count>PlayerRateRankCountMin) then d := (d*strtoint(ReadPlayer(TempIndexID,'points')))/TempRank.Count; | |
result := formatfloat('0.00',d); | |
end; | |
end; | |
end; | |
procedure Speak(Player: TActivePlayer; Text: string); | |
var TempIndexID:int64; kd:double; TempInteger:integer; TempID: byte; | |
begin | |
if (Copy(Text, 0, 1) <> '!') then exit; | |
if (Copy(LowerCase(Text),1,4)='!top') then DisplayTop(Player,Text); | |
if (Copy(Text,1,5)='!rank') then begin | |
delete(Text,1,6); | |
if (Text = '') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID>-1) then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
if (strtoint(ReadPlayer(TempIndexID,'kills'))>MinimalKills) then begin | |
Players.WriteConsole('Player '+Player.Name+' is a '+inttostr(TempRank.IndexOf(ReadPlayer(TempIndexID,'points')+':'+Player.Name)+1)+'/'+inttostr(TempRank.Count)+' in the ranking of '+ReadPlayer(TempIndexID,'points')+' pts.', GOOD); | |
exit; | |
end else Player.WriteConsole('You must possess a minimum of '+inttostr(MinimalKills)+' killings. Have: '+ReadPlayer(TempIndexID,'kills'),BAD); | |
end else Player.WriteConsole('Please login first!',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); | |
end else | |
begin | |
TempIndexID := FindPlayer(Player,Text,false); | |
if (TempIndexID>-1) then begin | |
if (strtoint(ReadPlayer(TempIndexID,'kills'))>0) and (strtoint(ReadPlayer(TempIndexID,'kills'))>0) then begin | |
Players.WriteConsole('Player '+ReadPlayer(TempIndexID,'name')+' is a '+inttostr(TempRank.IndexOf(ReadPlayer(TempIndexID,'points')+':'+ReadPlayer(TempIndexID,'name'))+1)+'/'+inttostr(TempRank.Count)+' in the ranking of '+ReadPlayer(TempIndexID,'points')+' pts.', GOOD); | |
exit; | |
end else Player.WriteConsole('We still have too little information about this player.',BAD); | |
end; | |
end; | |
end; | |
if (Copy(Text,1,6)='!stats') then begin | |
delete(Text,1,7); | |
if (Text = '') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID>-1) then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
if (strtoint(ReadPlayer(TempIndexID,'kills'))>MinimalKills) then begin | |
TempInteger := strtoint(ReadPlayer(TempIndexID,'deaths')); | |
KD := single(strtoint(ReadPlayer(TempIndexID,'kills')))/single(iif(TempInteger=0,1,TempInteger)); | |
Players.WriteConsole('Rank: '+inttostr(TempRank.IndexOf(ReadPlayer(TempIndexID,'points')+':'+Player.Name)+1)+'/'+inttostr(TempRank.Count)+', Points: '+ReadPlayer(TempIndexID,'points')+', K/D: '+FormatFloat('0.00',KD)+', Player Rate: '+Punkty(TempIndexID),GOOD); | |
Players.WriteConsole('Kills: '+ReadPlayer(TempIndexID,'kills')+', Deaths: '+ReadPlayer(TempIndexID,'deaths')+', Selfkills: '+ReadPlayer(TempIndexID,'selfkills'),GOOD); | |
if (Game.FriendlyFire) then Players.WriteConsole('Teamkills: '+ReadPlayer(TempIndexID,'teamkills')+', Killed By Friend: '+ReadPlayer(TempIndexID,'deathsbyteam'),GOOD); | |
exit; | |
end else Player.WriteConsole('You must possess a minimum of '+inttostr(MinimalKills)+' killings. Have: '+ReadPlayer(TempIndexID,'kills'),BAD); | |
end else Player.WriteConsole('Please login first!',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); | |
end else | |
begin | |
TempIndexID := FindPlayer(Player,Text,false); | |
if (TempIndexID>-1) then begin | |
{ inttostr(TempRank.IndexOf(ReadPlayer(TempIndexID,'points')+':'+Player.Name)+1) | |
for b := 0 to TempRank.Count-1 do if (GetPiece(TempRank[b],':',1)=ReadPlayer(TempIndexID,'name')) then begin } | |
TempInteger := strtoint(ReadPlayer(TempIndexID,'deaths')); | |
KD := single(strtoint(ReadPlayer(TempIndexID,'kills')))/single(iif(TempInteger=0,1,TempInteger)); | |
Players.WriteConsole('Player statistics '+ReadPlayer(TempIndexID,'name')+':', GOOD); | |
Players.WriteConsole('Rank: '+inttostr(TempRank.IndexOf(ReadPlayer(TempIndexID,'points')+':'+ReadPlayer(TempIndexID,'name'))+1)+'/'+inttostr(TempRank.Count)+', Points: '+ReadPlayer(TempIndexID,'points')+', K/D: '+FormatFloat('0.00',KD)+', Player Rate: '+Punkty(TempIndexID),GOOD); | |
Players.WriteConsole('Kills: '+ReadPlayer(TempIndexID,'kills')+', Deaths: '+ReadPlayer(TempIndexID,'deaths')+', Selfkills: '+ReadPlayer(TempIndexID,'selfkills'),GOOD); | |
if (Game.FriendlyFire) then Players.WriteConsole('Teamkills: '+ReadPlayer(TempIndexID,'teamkills')+', Killed By Friend: '+ReadPlayer(TempIndexID,'deathsbyteam'), GOOD); | |
exit; | |
end; | |
end; | |
end; | |
if (Copy(Text,1,10)='!flagstats') then begin | |
delete(Text,1,11); | |
if (Text = '') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID>-1) then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
if (strtoint(ReadPlayer(TempIndexID,'kills'))>MinimalKills) then begin | |
Players.WriteConsole('Flag Grabs: '+ReadPlayer(TempIndexID,'flaggrab')+', Flag Return: '+ReadPlayer(TempIndexID,'flagreturn')+', Flag Score: '+ReadPlayer(TempIndexID,'flagscore')+', Flag Drop: '+ReadPlayer(TempIndexID,'flagdrop'), GOOD); | |
Players.WriteConsole('Alpha Caps: '+ReadPlayer(TempIndexID,'alphacaps')+', Bravo Caps: '+ReadPlayer(TempIndexID,'bravocaps')+', Kill Flager: '+ReadPlayer(TempIndexID,'flagerkills')+', Flag Thrown: '+ReadPlayer(TempIndexID,'flagthrown'), GOOD); | |
exit; | |
end else Player.WriteConsole('You must possess a minimum of '+inttostr(MinimalKills)+' killings. Have: '+ReadPlayer(TempIndexID,'kills'),BAD); | |
end else Player.WriteConsole('Please login first!',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); | |
end else | |
begin | |
TempIndexID := FindPlayer(Player,Text,false); | |
if (TempIndexID>-1) then begin | |
Players.WriteConsole('Player flagstats '+ReadPlayer(TempIndexID,'name')+':', GOOD); | |
Players.WriteConsole('Flag Grabs: '+ReadPlayer(TempIndexID,'flaggrab')+', Flag Return: '+ReadPlayer(TempIndexID,'flagreturn')+', Flag Score: '+ReadPlayer(TempIndexID,'flagscore')+', Flag Drop: '+ReadPlayer(TempIndexID,'flagdrop'), GOOD); | |
Players.WriteConsole('Alpha Caps: '+ReadPlayer(TempIndexID,'alphacaps')+', Bravo Caps: '+ReadPlayer(TempIndexID,'bravocaps')+', Kill Flager: '+ReadPlayer(TempIndexID,'flagerkills')+', Flag Thrown: '+ReadPlayer(TempIndexID,'flagthrown'), GOOD); | |
exit; | |
end; | |
end; | |
end; | |
if (Copy(Text,1,10)='!winstats') then begin | |
delete(Text,1,11); | |
if (Text = '') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID>-1) then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
if (strtoint(ReadPlayer(TempIndexID,'kills'))>MinimalKills) then begin | |
TempInteger := strtoint(ReadPlayer(TempIndexID,'lose')); | |
KD := Single(strtoint(ReadPlayer(TempIndexID,'wins')))/single(iif(TempInteger=0,1,TempInteger)); | |
Players.WriteConsole('Wins: '+ReadPlayer(TempIndexID,'wins')+', Lose: '+ReadPlayer(TempIndexID,'lose')+', Draws: '+ReadPlayer(TempIndexID,'remis')+', Win/Lose ratio: '+FormatFloat('0.00',kd),GOOD); | |
Players.WriteConsole('AlphaWin: '+ReadPlayer(TempIndexID,'alphawins')+', AlphaLose: '+ReadPlayer(TempIndexID,'alphalose')+', BrawoWin: '+ReadPlayer(TempIndexID,'bravowins')+', BravoLose: '+ReadPlayer(TempIndexID,'bravolose'),GOOD); | |
exit; | |
end else Player.WriteConsole('You must possess a minimum of '+inttostr(MinimalKills)+' killings. Have: '+ReadPlayer(TempIndexID,'kills'),BAD); | |
end else Player.WriteConsole('Please login first!',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); | |
end else | |
begin | |
TempIndexID := FindPlayer(Player,Text,false); | |
if (TempIndexID>-1) then begin | |
TempInteger := strtoint(ReadPlayer(TempIndexID,'lose')); | |
KD := Single(strtoint(ReadPlayer(TempIndexID,'wins')))/single(iif(TempInteger=0,1,TempInteger)); | |
Players.WriteConsole('Player winstats '+ReadPlayer(TempIndexID,'name')+':', GOOD); | |
Players.WriteConsole('Wins: '+ReadPlayer(TempIndexID,'wins')+', Lose: '+ReadPlayer(TempIndexID,'lose')+', Draws: '+ReadPlayer(TempIndexID,'remis')+', Win/Lose ratio: '+FormatFloat('0.00',kd),GOOD); | |
Players.WriteConsole('AlphaWin: '+ReadPlayer(TempIndexID,'alphawins')+', AlphaLose: '+ReadPlayer(TempIndexID,'alphalose')+', BrawoWin: '+ReadPlayer(TempIndexID,'bravowins')+', BravoLose: '+ReadPlayer(TempIndexID,'bravolose'),GOOD); | |
exit; | |
end; | |
end; | |
end; | |
if (Copy(Text,1,11)='!otherstats') then begin | |
delete(Text,1,12); | |
if (Text = '') then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID>-1) then begin | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
if (strtoint(ReadPlayer(TempIndexID,'kills'))>MinimalKills) then begin | |
TempInteger := strtoint(ReadPlayer(TempIndexID,'shoots')); | |
KD := (strtoint(ReadPlayer(TempIndexID,'shoothits'))*100.0)/single(iif(TempInteger=0,1,TempInteger)); | |
Players.WriteConsole('Shots: '+ReadPlayer(TempIndexID,'shoots')+', Hits: '+ReadPlayer(TempIndexID,'shoothits')+', Mishit: '+inttostr(strtoint(ReadPlayer(TempIndexID,'shoots'))-strtoint(ReadPlayer(TempIndexID,'shoothits')))+iif(Game.FriendlyFire,', Friendly shoots: '+ReadPlayer(TempIndexID,'shootfriendly')+', ','')+', Accuracy: '+FormatFloat('0.00',kd)+'%',GOOD); | |
Players.WriteConsole('Savior kill: '+ReadPlayer(TempIndexID,'wybawiel')+', Revenge: '+ReadPlayer(TempIndexID,'revengekills')+', Assist: '+ReadPlayer(TempIndexID,'assist')+', Posthumous kill: '+ReadPlayer(TempIndexID,'postromuskill')+', Avenged: '+ReadPlayer(TempIndexID,'avenger'),GOOD); | |
exit; | |
end else Player.WriteConsole('You must possess a minimum of '+inttostr(MinimalKills)+' killings. Have: '+ReadPlayer(TempIndexID,'kills'),BAD); | |
end else Player.WriteConsole('Please login first!',BAD); | |
end else Player.WriteConsole('You do not have an account. Use /create <password> to create!',BAD); | |
end else | |
begin | |
TempIndexID := FindPlayer(Player,Text,false); | |
if (TempIndexID>-1) then begin | |
TempInteger := strtoint(ReadPlayer(TempIndexID,'shoots')); | |
KD := (strtoint(ReadPlayer(TempIndexID,'shoothits'))*100.0)/single(iif(TempInteger=0,1,TempInteger)); | |
Players.WriteConsole('Player otherstats '+ReadPlayer(TempIndexID,'name')+':', GOOD); | |
Players.WriteConsole('Shots: '+ReadPlayer(TempIndexID,'shoots')+', Hits: '+ReadPlayer(TempIndexID,'shoothits')+', Mishit: '+inttostr(strtoint(ReadPlayer(TempIndexID,'shoots'))-strtoint(ReadPlayer(TempIndexID,'shoothits')))+iif(Game.FriendlyFire,', Friendly shoots: '+ReadPlayer(TempIndexID,'shootfriendly')+', ','')+', Accuracy: '+FormatFloat('0.00',kd)+'%',GOOD); | |
Players.WriteConsole('Savior kill: '+ReadPlayer(TempIndexID,'wybawiel')+', Revenge: '+ReadPlayer(TempIndexID,'revengekills')+', Assist: '+ReadPlayer(TempIndexID,'assist')+', Posthumous kill: '+ReadPlayer(TempIndexID,'postromuskill')+', Avenged: '+ReadPlayer(TempIndexID,'avenger'),GOOD); | |
exit; | |
end; | |
end; | |
end; | |
if ExecRegExpr('^!(reginfo)$',lowercase(Text)) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
Player.WriteConsole('____Registration Commands _________________________________________________________________________________ ',GOOD); | |
Player.WriteConsole('/create <password>, /login <password>, /logout, /addpassword <password>, /addmail <e-mail>, /memail | ',GOOD); | |
Player.WriteConsole('/changepass <old password> <newpassword>, /changenick <password> <newnick>, /autologin <HWID|IP|NAME|OFF> | ',GOOD); | |
Player.WriteConsole('/changemail <if have password must give password> <new e-mail>, /switchdisplay, /search <phrase>, /bal | ',GOOD); | |
Player.WriteConsole('/randompass <1-4> <if have password must give password>, /lastplayed <name>, /registerdate <name> | ',GOOD); | |
Player.WriteConsole('____Display Stats Commands _______________________________________________________________________________| ',GOOD+7500); | |
Player.WriteConsole('!stats, !stats <name*>, !otherstats, !otherstats <name*>, !winstats, !winstats <name*>, !a, !b, !s, !j | ',GOOD+7500); | |
Player.WriteConsole('!top, !top <name*|num>, !rank, !rank <name*>, !flagstats, !flagstats <name*>, !teampoints, !hardbal, !bal | ',GOOD+7500); | |
Player.WriteConsole('* - Can be ID, part name, full name (Search allso offline players) | num - Can be number | ',GOOD+7500); | |
if (Player.IsAdmin=false) then Player.WriteConsole('__________________________________________________________________________________________________________| ',GOOD+7500); | |
if (ReadPlayer(TempIndexID,'firstuse')='0') then begin | |
Player.WriteConsole('Type !login for example will display info how to login! (Use to OFF this messages) | ',BAD); | |
if (Player.IsAdmin=false) then Player.WriteConsole('__________________________________________________________________________________________________________| ',BAD); | |
end; | |
if (player.isadmin) then begin | |
Player.WriteConsole('____Admin Commands _______________________________________________________________________________________| ',GOOD+700); | |
Player.WriteConsole('/deleteacc <full name>, /generatenewpass <1-4> <full name>, /resetallstats, /clearlogs | ',GOOD+700); | |
Player.WriteConsole('/backupcreate <backup name>, /restorebackup <backup name>, /deletebackup <name> | ',GOOD+700); | |
Player.WriteConsole('/kickbots, /kickspecs, /bal, /mix, /swap <all>, /swap <player_1_id> <player_2_id> | ',GOOD+700); | |
Player.WriteConsole('__________________________________________________________________________________________________________| ',GOOD+700); | |
end; | |
end; | |
if ExecRegExpr('^!(autor|author|credit|credits|contact|tworca|info|zitrofun|zitro|fun)$',lowercase(Text)) then begin | |
Player.WriteConsole('Author scripts: dominikk26',GOOD); | |
Player.WriteConsole('E-mail: dominikk262@wp.pl',GOOD); | |
Player.WriteConsole(YouInfo,GOOD); | |
Player.WriteConsole('Script Version: '+ScriptVersion,GOOD); | |
Player.WriteConsole('Registered players: '+inttostr(Memory.Count/DataLinesNum),GOOD); | |
Player.WriteConsole('Players in ranking: '+inttostr(TempRank.Count),GOOD); | |
end; | |
if ExecRegExpr('^!(login)$',lowercase(Text)) then begin | |
Player.WriteConsole('Type /login ''your password'' to login.',GOOD); | |
Player.WriteConsole('Press the first "/" and write command. Do not press "T".',GOOD); | |
Player.WriteConsole('Example: Press "/" write "login" add space and write "your password" and enter.',GOOD); | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (ReadPlayer(TempIndexID,'firstuse')='0') then ChangeState(TempIndexID,'firstuse','1'); | |
end; | |
if (Game.GameStyle <> 3) and (Game.GameStyle <> 5) then exit; | |
case lowercase(text) of | |
'!balance', '!bal', '!teams': begin | |
if (Player.Team = 5) then begin | |
Player.WriteConsole('Spectators can''t use this trigger.',BAD); | |
exit; | |
end; | |
if (bal.lastbalance < 15) then begin | |
Players.WriteConsole('Last balance was less than 15 s ago. Please be patient.', BAD); | |
exit; | |
end; | |
if (Game.TimeLeft <= 10) then begin | |
Players.WriteConsole('The map will change soon. Balance is disabled', BAD); | |
Players.WriteConsole('to prevent ''wrong map version'' problems.', BAD); | |
exit; | |
end; | |
Balance(false, false); | |
end; | |
'!hardbal', '!hardbalance', '!balhard', '!balancehard': begin | |
if (Player.Team = 5) then begin | |
Player.WriteConsole('Spectators can''t use this trigger.',BAD); | |
exit; | |
end; | |
if (bal.hardbaltime > 0) then begin | |
Player.WriteConsole('You can`t use yet !hardbal, by time constraint. You can use once on '+inttostr(HardBalTimes)+' miniute.', BAD); | |
exit; | |
end; | |
if (Game.TimeLeft <= 10) then begin | |
Players.WriteConsole('The map will change soon. Balance is disabled', BAD); | |
Players.WriteConsole('to prevent ''wrong map version'' problems.', BAD); | |
exit; | |
end; | |
HardBalance(); | |
end; | |
end; | |
case lowercase(text) of | |
'!alpha', '!red', '!1', '!a', '!joina', '!join1': begin | |
if CheckTeamChange(Player, 1) then exit; | |
if ((PlayerInfo[Player.ID].lock = 0) or (Player.Team = 5)) and (Game.TimeLeft > 2) then begin | |
Player.Team := 1; | |
if (TriggerLimit > 0) then PlayerInfo[Player.ID].triggers := PlayerInfo[Player.ID].triggers + 1; | |
end else begin | |
Player.writeconsole('You were moved due to unbalanced teams.', BAD); | |
Player.writeconsole('You can''t change teams for '+inttostr(LockTime)+' min after being moved.', BAD); | |
exit; | |
end; | |
end; | |
'!bravo', '!blu', '!blue', '!2', '!b', '!joinb', '!join2': begin | |
if CheckTeamChange(Player, 2) then exit; | |
if ((PlayerInfo[Player.ID].lock = 0) or (Player.Team = 5)) and (TimeLeft > 2) then begin | |
Player.Team := 2; | |
if (TriggerLimit > 0) then PlayerInfo[Player.ID].triggers := PlayerInfo[Player.ID].triggers + 1; | |
end else begin | |
Player.writeconsole('You were moved due to unbalanced teams.', BAD); | |
Player.writeconsole('You can''t change teams for '+inttostr(LockTime)+' min after being moved.', BAD); | |
exit; | |
end; | |
end; | |
'!spectator', '!spect', '!spec', '!5', '!s', '!join5': begin | |
if CheckTeamChange(Player, 5) then exit; | |
if (TimeLeft > 2) then Player.Team := 5; | |
end; | |
'!join', '!j': begin | |
if (Player.Team <> 5) then begin | |
Player.writeconsole('This trigger is for spectators only.', BAD); | |
exit; | |
end; | |
TempID := CalcWeakerTeam(true) mod 10; | |
if (TempID = 0) then begin | |
if (AlphaScore > BravoScore) then TempID := 2 else if (AlphaScore < BravoScore) then TempID := 1 else TempID := random(1, 3); | |
end; | |
Player.Team := TempID; | |
end; | |
end; | |
end; | |
procedure JoinGame(Player: TActivePlayer; Team: TTeam); | |
var TempIndexID:int64; | |
begin | |
if (Player.Human) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID > -1) then AutoLogin(Player,TempIndexID) else AutoReg(Player); | |
end; | |
end; | |
procedure JoinTeam(Player: TActivePlayer; Team: TTeam); | |
var i:byte; | |
begin | |
if (Player.Human) then begin | |
for i := 1 to 32 do if (Players[i].Active) then begin | |
if (i<>Player.ID) and (Player.HWID = Players[i].HWID) then begin | |
Player.WriteConsole('Please stop buggs! You can not, go two accounts per server at a time.',BAD); | |
Players.WriteConsole('[ZitroFUN] I detected two players with the same HWID, '+Players[i].Name+' and '+Player.Name,BAD); | |
Player.Kick(TKickConsole); | |
end; | |
end; | |
end; | |
if (Game.GameStyle <> 3) and (Game.GameStyle <> 5) then exit; | |
if (not PlayerInfo[Player.ID].movedByScript) then if (team.ID <> 5) then begin | |
if (bal.smallerTeam = 0) then begin | |
bal.smallerTeam := CalcWeakerTeam(true); | |
if (bal.smallerTeam > 30) then bal.smallerTeam := 0 else bal.smallerTeam := bal.smallerTeam mod 10; | |
end; | |
if (bal.smallerTeam > 0) then if (bal.smallerTeam <> team.ID) then if (Game.NumPlayers > 1) then begin | |
PlayerInfo[Player.ID].movedByScript := true; | |
Player.Team := bal.smallerTeam; | |
Player.WriteConsole(iif(PlayerInfo[Player.ID].prevteam=1, 'Bravo', 'Alpha') + ' Team is full.', GOOD); | |
end; | |
end; | |
if (KeepTeamScore) then if ((team.ID = 2) and (Game.Teams[1].Count = 0)) or ((team.ID = 1) and (Game.Teams[2].Count = 0)) then bal.restoreDelay := iif(team.ID=2, bal.tempAlphaScore, -bal.tempBravoScore); | |
if (team.ID = 5) or (PlayerInfo[Player.ID].prevteam = team.ID) then begin | |
bal.smallerTeam := CalcWeakerTeam(true) mod 10; | |
exit; | |
end; | |
if (not PlayerInfo[Player.ID].movedByScript) then if (bal.smallerTeam = team.ID) then PlayerInfo[Player.ID].lock := 0; | |
if (PlayerInfo[Player.ID].lock <> 0) then begin | |
Player.Team := PlayerInfo[Player.ID].prevteam; | |
Player.WriteConsole('You were moved due to unbalanced teams.',BAD); | |
Player.WriteConsole('You can''t change teams for '+inttostr(LockTime)+' min after being moved.',BAD); | |
end else PlayerInfo[Player.ID].prevteam := team.ID; | |
PlayerInfo[Player.ID].movedByScript := false; | |
bal.smallerTeam := CalcWeakerTeam(true) mod 10; | |
end; | |
procedure LeaveGame(Player: TActivePlayer; Kicked: Boolean); | |
var TempIndexID: int64; i:byte; | |
begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (TempIndexID > -1) and (PlayerInfo[Player.ID].NickStatus) then ChangeState(TempIndexID,'lastplay',FormatDate('dd mmmm yyyy')+' at: '+ FormatDate('hh:nn:ss')); | |
PlayerInfo[Player.ID].NickStatus := false; | |
for i := 1 to 32 do begin | |
PlayerInfo[i].AssistDamageMade[Player.ID] := 0; | |
PlayerInfo[i].AssistCooldown[Player.ID] := 0; | |
PlayerInfo[Player.ID].AssistDamageMade[i] := 0; | |
PlayerInfo[Player.ID].AssistCooldown[i] := 0; | |
end; | |
if (SaveMemoryPriority>0) then Memory.SaveToFile(PatchCore+'accounts.db'); | |
if (GameStyle <> 3) and (GameStyle <> 5) then exit; | |
if (CheckOnLeave) then bal.mode := 3; | |
if (KeepTeamScore) then if ((Player.Team = 1) and (Game.Teams[1].Count = 1)) or ((Player.Team = 2) and (Game.Teams[2].Count = 1)) then bal.restoreDelay := iif(Player.Team=1, Game.Teams[1].Score, -Game.Teams[2].Score); | |
PlayerInfo[Player.ID].lock := 0; PlayerInfo[Player.ID].immune := 0; PlayerInfo[Player.ID].triggers := 0; bal.justLeft := true; | |
end; | |
procedure ChangeBefore(Next: string); | |
begin | |
Players.BigText(BigTextLayer+3,'Save Stats Start!',BigTextTime,BAD,0.075,20,390); | |
if (SaveMemoryPriority>=0) then Memory.SaveToFile(PatchCore+'accounts.db'); | |
Players.BigText(BigTextLayer+3,'Save Stats Complete :)',BigTextTime,GOOD,0.075,20,390); | |
if (HyperSafePass=true) and (HyperSafePassOnlyMapChange=true) then HyperSafePassword(); | |
end; | |
procedure ChangeAfter(Next: string); | |
var i: byte; | |
begin | |
if (GameStyle <> 3) and (GameStyle <> 5) then exit; | |
if (NumPlayers-Spectators <= 2) then writeln('[ZitroFUN] Balance won''t work until there are at least 3 players.'); | |
writeln('[ZitroFUN] Balances this run: '+inttostr(bal.numberGlobal)+' ('+inttostr(bal.numberMap)+' on prev map)'+iif(bal.numberGlobal>0, ' | Last one was '+iif(bal.lastbalance=32767, 'over 9 hours ago', inttostr(bal.lastbalance div 60)+' min '+inttostr(bal.lastbalance mod 60)+' s ago'),'')); | |
bal.numberMap := 0; bal.swaps := 0; | |
if (Interval > 0) then if (bal.lastcheck < 5) then bal.lastcheck := 5; | |
if (TriggerLimit > 0) then for i := 1 to 32 do PlayerInfo[i].triggers := 0; | |
if (KeepTeamScore) then begin | |
bal.restoreDelay := 0; bal.tempAlphaScore := 0; | |
bal.tempBravoScore := 0; | |
end; | |
end; | |
procedure OnPlayerShoot(Player: TActivePlayer; Weapon: byte; AmmoX: integer); | |
var TempIndexID: int64; i :integer; | |
begin | |
for i := 1 to AmmoX do begin | |
if (PlayerInfo[Player.ID].NickStatus) and (Weapon <> 255) then begin // and (Weapon <> 12) if SAW disable | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (Weapon <> 1) and (Weapon <> 5) then ChangeState(TempIndexID,'shoots',AddNum(ReadPlayer(TempIndexID,'shoots'),1)); | |
if (Weapon = 1) then ChangeState(TempIndexID,'shoots',AddNum(ReadPlayer(TempIndexID,'shoots'),2)); | |
if (Weapon = 5) then ChangeState(TempIndexID,'shoots',AddNum(ReadPlayer(TempIndexID,'shoots'),6)); | |
end; | |
end; | |
if (SaveMemoryPriority>4) then Memory.SaveToFile(PatchCore+'accounts.db'); | |
end; | |
procedure OnWepChange(Player: TActivePlayer; Primary, Secondary: TPlayerWeapon); | |
var TempIndexID: int64; | |
begin | |
if (PlayerInfo[Player.ID].NickStatus) and (Player.Primary.Wtype = 11) and (Primary.WType = 255) and (Secondary.WType<>11) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
ChangeState(TempIndexID,'shoots',AddNum(ReadPlayer(TempIndexID,'shoots'),1)); | |
end; | |
end; | |
procedure ShootKeyCheck(); | |
var i: byte; AmmoX:integer; | |
begin | |
for i := 1 to 32 do if (Players[i].Active) then begin | |
if (Players[i].KeyShoot) and (Players[i].Primary.Ammo < PlayerInfo[i].Ammo) then begin | |
AmmoX := (PlayerInfo[i].Ammo-Players[i].Primary.Ammo); | |
OnPlayerShoot(Players[i],Players[i].Primary.WType,AmmoX); | |
end; | |
PlayerInfo[i].Ammo := Players[i].Primary.Ammo; | |
end; | |
end; | |
procedure DisEvent(Player: TActivePlayer); | |
var TempIndexID:int64; len,b:integer; PlayerTempKills:string; | |
begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (PlayerInfo[Player.ID].NickStatus) and (ReadPlayer(TempIndexID,'bigtext')='0') and (Player.Team<>5) then begin | |
PlayerTempKills:=ReadPlayer(TempIndexID,'kills'); | |
if (strtoint(PlayerTempKills)>=MinimalKills) then begin | |
len := getarraylength(PlayerInfo[Player.ID].EventsDisplay); | |
if (len=0) then Player.BigText(BigTextLayer+5,'Rank: '+inttostr(TempRank.IndexOf(ReadPlayer(TempIndexID,'points')+':'+Player.Name)+1)+'/'+inttostr(TempRank.Count)+', Points: '+ReadPlayer(TempIndexID,'points'),200,$F15D70,0.055,12,425) | |
else | |
begin | |
Player.BigText(BigTextLayer+5,'Rank: '+inttostr(TempRank.IndexOf(ReadPlayer(TempIndexID,'points')+':'+Player.Name)+1)+'/'+inttostr(TempRank.Count)+', Points: '+ReadPlayer(TempIndexID,'points')+' '+PlayerInfo[Player.ID].EventsDisplay[0],200,$F15D70,0.055,12,425); | |
if (len=1) then begin | |
SetArrayLength(PlayerInfo[Player.ID].EventsDisplay,0); | |
exit; | |
end else | |
begin | |
for b := 1 to (len-1) do PlayerInfo[Player.ID].EventsDisplay[b-1] := PlayerInfo[Player.ID].EventsDisplay[b]; | |
SetArrayLength(PlayerInfo[Player.ID].EventsDisplay,len-1); | |
end; | |
end; | |
end else Player.BigText(BigTextLayer+5,'Minimal kills: '+PlayerTempKills+'/'+inttostr(MinimalKills),200,$F15D70,0.055,12,425); | |
end; | |
end; | |
procedure Timers(Ticks: integer); | |
var i,b:byte; TempIndexID:int64; BackupTemp: TStringList; CurrTim,CurrTim2: TDateTime; | |
begin | |
ShootKeyCheck(); | |
if (Ticks mod (60*HyperSafePassTime) = 0) then if (HyperSafePass=true) and (HyperSafePassOnlyMapChange=false) then HyperSafePassword(); | |
if (Ticks mod 3600 = 0) then begin | |
if (File.Exists(PatchCore+'backup.temp')) then BackupTemp := File.CreateStringListFromFile(PatchCore+'backup.temp') else begin BackupTemp := File.CreateStringList(); BackupTemp.Append('0'); end; | |
if (strtoint(BackupTemp[0])=AutoBackupTime) then begin | |
BackupTemp[0] := '0'; | |
CurrTim:=date(); CurrTim2:=time; | |
File.Copy(PatchCore+'accounts.db',BackupPatch+FormatDateTime('YYYY-mm-dd',CurrTim)+'at'+FormatDateTime('hh-nn-ss',CurrTim2)+'.backup'); | |
WriteLn('[ZitroFUN] Automatic backup: '+FormatDateTime('YYYY-mm-dd',CurrTim)+'at'+FormatDateTime('hh-nn-ss',CurrTim2)); | |
end else BackupTemp[0] := inttostr(strtoint(BackupTemp[0])+1); | |
BackupTemp.SaveToFile(PatchCore+'backup.temp'); | |
end; | |
if Ticks mod (3600 * RegInfoTime) = 0 then Players.WriteConsole('Enter !reginfo to see command. Information: !contact', GOOD); | |
if (Ticks mod 60 = 0) then begin | |
crossfunc([],'autorec.ResetCountdown'); | |
for i := 1 to 32 do if (Players[i].Active) then begin | |
for b := 1 to 32 do if (Players[b].Active) then begin | |
if (PlayerInfo[i].SaviorTimer[b] > 0) then PlayerInfo[i].SaviorTimer[b] := PlayerInfo[i].SaviorTimer[b]-1; | |
if (PlayerInfo[i].AvengerTimer[b] > 0) then PlayerInfo[i].AvengerTimer[b] := PlayerInfo[i].AvengerTimer[b]-1; | |
end; | |
if (AssistTime>0) then begin | |
for b := 1 to 32 do if (Players[b].Active) then begin | |
if (PlayerInfo[i].AssistCooldown[b]>0) then begin | |
PlayerInfo[i].AssistCooldown[b] := PlayerInfo[i].AssistCooldown[b]-1; | |
if (PlayerInfo[i].AssistCooldown[b]=0) then PlayerInfo[i].AssistDamageMade[b] := 0; | |
end; | |
end; | |
end; | |
if (PlayerInfo[i].KickTimer>0) then begin | |
if (PlayerInfo[i].KickTimer < KickTime) then Players[i].WriteConsole('Plese login! '+inttostr(PlayerInfo[i].KickTimer)+'s left to login. Use /login "password" to login.',BAD); | |
PlayerInfo[i].KickTimer := (PlayerInfo[i].KickTimer-1); | |
if (PlayerInfo[i].KickTimer=0) then Players[i].Kick(TKickConsole); | |
end; | |
if (lowercase(Players[i].Name) = 'major') then begin | |
Players[i].BigText(BigTextLayer+4,'Plese change nick to be able to register and use statistics!',BigTextTimeScreenInfo,BAD,0.075,20,405); | |
continue; | |
end; | |
TempIndexID := Memory.IndexOf('%name%'+Players[i].Name); | |
if (TempIndexID>-1) then begin | |
if (PlayerInfo[i].NickStatus = false) then begin | |
Players[i].BigText(BigTextLayer+4,'Type /login <password> to login.',BigTextTimeScreenInfo,$FF0000,0.07,184,405) | |
continue; | |
end else | |
begin | |
if (ReadPlayer(TempIndexID,'bigtext')='1') then continue; | |
if (ReadPlayer(TempIndexID,'password') = '') then Players[i].BigText(BigTextLayer+4,' Plese add password'+#13#10+'Type /addpassword <password>',BigTextTimeScreenInfo,$FF0000,0.07,188,405) else if (ReadPlayer(TempIndexID,'mail') = '') then Players[i].BigText(BigTextLayer+4,' Plese add mail'+#13#10+'Type /addmail <e-mail>',BigTextTimeScreenInfo,$FF0000,0.07,188,405); | |
end; | |
end else Players[i].BigText(BigTextLayer+4,'Type /create <password> to create account',BigTextTimeScreenInfo,$FF0000,0.07,106,405); | |
end; | |
end; | |
if ((Ticks mod 120) = 0) then for i := 1 to 32 do if (Players[i].Active) and (Players[i].Human) then DisEvent(Players[i]); | |
if (Ticks mod 60 = 0) then begin | |
if (ticks mod 60 <> 0) then exit; | |
if (GameStyle <> 3) and (GameStyle <> 5) then exit; | |
if (bal.hardbaltime>0) then bal.hardbaltime := bal.hardbaltime-1; | |
if (KeepTeamScore) then if (bal.restoreDelay <> 0) then begin | |
setteamscore(iif(bal.restoreDelay>0, 1, 2), abs2(bal.restoreDelay)); | |
bal.restoreDelay := 0; | |
end; | |
if (bal.mode = 1) then begin | |
bal.mode := 0; bal.maxBalances := 0; | |
Players.writeconsole('Teams balanced. '+ShowPlayers(), GOOD); | |
end; | |
if (bal.mode = 2) then begin | |
for i := 1 to 32 do if (Players[i].Active) and (Players[i].Team <> 5) then PlayerInfo[i].lock := (LockTime*60); | |
bal.mode := 0; bal.maxBalances := 0; | |
Players.writeconsole('Teams shuffled!', GOOD); | |
end; | |
if (bal.mode = 3) then Balance(true, false); | |
if (Interval > 0) then if (TimeLeft > 10) then if (bal.lastcheck = 0) then if (Game.NumPlayers-Game.Teams[5].Count >= 3) then Balance(true, false); | |
if (ImmuneTime > 0) then for i := 1 to 32 do if (PlayerInfo[i].immune > 0) then PlayerInfo[i].immune := (PlayerInfo[i].immune-1); | |
if (LockTime > 0) then for i := 1 to 32 do if (PlayerInfo[i].lock > 0) then PlayerInfo[i].lock := (PlayerInfo[i].lock-1); | |
if (bal.lastbalance < 32767) then bal.lastbalance := (bal.lastbalance+1); | |
if (bal.lastcheck > 0) then bal.lastcheck := (bal.lastcheck-1); | |
if (bal.justLeft) then begin | |
bal.justLeft := false; | |
bal.smallerTeam := CalcWeakerTeam(false) mod 10; | |
end; | |
end; | |
end; | |
function DebugCreateFile(ErrorCode: TErrorType; Message, UnitName, FunctionName: string; Row, Col: Cardinal): Boolean; | |
var Temp: TStringList; CurrTim,CurrTim2: TDateTime; | |
begin | |
result := false; | |
if (File.Exists(PatchCore+'bugs.errorlog')) then begin | |
Temp := File.CreateStringListFromFile(PatchCore+'bugs.errorlog'); | |
Temp.Add('-----------BUG '+inttostr(1+(Temp.Count/7))+' START-----------'); | |
end else | |
begin | |
Temp := File.CreateStringList(); | |
Temp.Add('-----------BUG 1 START-----------'); | |
end; | |
CurrTim:=date(); CurrTim2:=time; | |
Temp.Add('Kiedy - Data: '+FormatDateTime('YYYY-mm-dd',CurrTim)+', Czas: '+FormatDateTime('hh"h"-nn"min"-ss"sec"-zzz"ms"',CurrTim2)); | |
Temp.Add('Część: '+UnitName); | |
Temp.Add('Funkcja: '+FunctionName); | |
Temp.Add('Pozycja - Col: '+inttostr(Col)+', Ln: '+inttostr(Row)); | |
case ErrorCode of | |
ErNoError : Temp.Add('Error type: No Error'); erCannotImport : Temp.Add('Error type: Cannot Import'); erInvalidType : Temp.Add('Error type: Invalid Type'); | |
ErInternalError : Temp.Add('Error type: Internal Error'); erInvalidHeader : Temp.Add('Error type: Invalid Header'); erInvalidOpcode : Temp.Add('Error type: Invalid Opcode'); | |
erInvalidOpcodeParameter : Temp.Add('Error type: Invalid Opcode Parameter'); erNoMainProc : Temp.Add('Error type: No Main Proc'); erOutOfGlobalVarsRange : Temp.Add('Error type: Out Of Global Vars Range'); | |
erOutOfProcRange : Temp.Add('Error type: Out Of ProcRange'); ErOutOfRange : Temp.Add('Error type: Out Of Range'); erOutOfStackRange : Temp.Add('Error type: Out Of Stack Range'); | |
ErTypeMismatch : Temp.Add('Error type: Type Mismatch'); erUnexpectedEof : Temp.Add('Error type: Unexpected Eof'); erVersionError : Temp.Add('Error type: Version Error'); | |
ErDivideByZero : Temp.Add('Error type: Divide By Zero'); ErMathError : Temp.Add('Error type: Math Error'); erCouldNotCallProc : Temp.Add('Error type: Could Not Call Proc'); | |
erOutofRecordRange : Temp.Add('Error type: Out of Record Range'); erOutOfMemory : Temp.Add('Error type: Out Of Memory'); erException : Temp.Add('Error type: Exception'); | |
erNullPointerException : Temp.Add('Error type: Null Pointer Exception'); erNullVariantError : Temp.Add('Error type: Null Variant Error'); | |
erInterfaceNotSupported : Temp.Add('Error type: Interface Not Supported'); erCustomError : Temp.Add('Error type: Custom Error'); | |
end; | |
Temp.Add('Error Message: '+Message); | |
Temp.SaveToFile(PatchCore+'bugs.errorlog'); | |
Temp.Free; | |
end; | |
procedure AvengerModule(Killer, Victim: TActivePlayer); | |
var i,b: byte; TempIndexID: int64; | |
begin | |
if (PlayerInfo[Killer.ID].NickStatus) then begin | |
for i := 1 to 32 do begin | |
if (Players[i].Active) and (i <> Victim.ID) and (i <> Killer.ID) and (Players[i].Team = Killer.Team) and (PlayerInfo[Victim.ID].AvengerTimer[i] > 0) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Killer.Name); | |
ChangeState(TempIndexID,'avenger',AddNum(ReadPlayer(TempIndexID,'avenger'),1)); | |
AddEventDisplay(Killer,'+1 Avenger'); | |
for b := 1 to 32 do PlayerInfo[Victim.ID].AvengerTimer[b] := 0; | |
break; | |
end; | |
end; | |
end; | |
PlayerInfo[Killer.ID].AvengerTimer[Victim.ID] := AvengerTime; | |
end; | |
procedure SaviorModule(Killer, Victim: TActivePlayer); | |
var i,b: byte; TempIndexID: int64; | |
begin | |
if (PlayerInfo[Killer.ID].NickStatus) then begin | |
for i := 1 to 32 do begin | |
if (Players[i].Active) and (i <> Killer.ID) and (Players[i].Team = Killer.Team) and (Players[i].Alive) and (PlayerInfo[Victim.ID].SaviorTimer[i] > 0) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Killer.Name); | |
ChangeState(TempIndexID,'wybawiel',AddNum(ReadPlayer(TempIndexID,'wybawiel'),1)); | |
AddEventDisplay(Killer,'+1 Savior'); | |
for b := 1 to 32 do PlayerInfo[Victim.ID].SaviorTimer[b] := 0; | |
break; | |
end; | |
end; | |
end; | |
end; | |
procedure AssistModule(Killer, Victim: TActivePlayer); | |
var i: byte; TempIndexID: int64; AssistDamagePrecent: double; | |
begin | |
for i := 1 to 32 do begin | |
if (Players[i].Active) and (i <> Killer.ID) and (Players[i].Team <> Victim.Team) and (PlayerInfo[i].NickStatus) then begin | |
if (PlayerInfo[i].AssistCooldown[Victim.ID] > 0) then begin | |
AssistDamagePrecent := ((PlayerInfo[i].AssistDamageMade[Victim.ID]*100.0)/MaxHealth); | |
if (AssistDamagePrecent>=AssistMinimumDamagePercent) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[i].Name); | |
ChangeState(TempIndexID,'assist',AddNum(ReadPlayer(TempIndexID,'assist'),1)); | |
AddEventDisplay(Players[i],'+1 Assist'); | |
end; | |
end else | |
begin | |
if (AssistTime=0) then begin | |
AssistDamagePrecent := ((PlayerInfo[i].AssistDamageMade[Victim.ID]*100.0)/MaxHealth); | |
if (AssistDamagePrecent>=AssistMinimumDamagePercent) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[i].Name); | |
ChangeState(TempIndexID,'assist',AddNum(ReadPlayer(TempIndexID,'assist'),1)); | |
AddEventDisplay(Players[i],'+1 Assist'); | |
end; | |
end; | |
end; | |
end; | |
end; | |
for i := 1 to 32 do if (Players[i].Active) then begin | |
PlayerInfo[i].AssistDamageMade[Victim.ID] := 0; | |
PlayerInfo[i].AssistCooldown[Victim.ID] := 0; | |
end; | |
end; | |
procedure SelfkillModule(Victim: TActivePlayer); | |
var i: byte; LastPoints,NewPoints,PlayerRealLostPoints: integer; TempIndexID1,TempIndexID2: int64; | |
begin | |
if (PlayerInfo[Victim.ID].NickStatus) then begin | |
for i := 1 to 32 do begin | |
if (Players[i].Active) and (PlayerInfo[i].NickStatus) and (Players[i].Team <> Victim.Team) then begin | |
TempIndexID1 := Memory.IndexOf('%name%'+Players[i].Name); | |
LastPoints := strtoint(ReadPlayer(TempIndexID1,'points')); NewPoints := (LastPoints+SelfKillLostOnPlayer); ChangeState(TempIndexID1,'points',inttostr(NewPoints)); RankSetPos(TempIndexID1,LastPoints,NewPoints); | |
AddEventDisplay(Victim,'+'+inttostr(SelfKillLostOnPlayer)+'pts, Enemy Selfkill'); | |
PlayerRealLostPoints:=(PlayerRealLostPoints+SelfKillLostOnPlayer); | |
end; | |
end; | |
TempIndexID2 := Memory.IndexOf('%name%'+Victim.Name); | |
ChangeState(TempIndexID2,'selfkills',AddNum(ReadPlayer(TempIndexID2,'selfkills'),1)); | |
LastPoints := strtoint(ReadPlayer(TempIndexID2,'points')); NewPoints := (LastPoints-PlayerRealLostPoints); ChangeState(TempIndexID2,'points',inttostr(NewPoints)); RankSetPos(TempIndexID2,LastPoints,NewPoints); | |
AddEventDisplay(Victim,'-'+inttostr(PlayerRealLostPoints)+'pts, +1 Selfkill'); | |
end; | |
end; | |
procedure OnKill(Killer, Victim: TActivePlayer; BulletId: Byte); | |
var TempIndexID1,TempIndexID2:int64; i:byte; | |
begin | |
TempIndexID1 := Memory.IndexOf('%name%'+Killer.Name); TempIndexID2 := Memory.IndexOf('%name%'+Victim.Name); | |
if (Killer.ID<>Victim.ID) then begin | |
if (Killer.Team<>Victim.Team) then begin | |
if (PlayerInfo[Killer.ID].NickStatus) then begin | |
ChangeState(TempIndexID1,'kills',AddNum(ReadPlayer(TempIndexID1,'kills'),1)); | |
AddEventDisplay(Killer,'+1 Kill'); | |
if (Killer.Alive=false) then begin | |
ChangeState(TempIndexID1,'postromuskill',AddNum(ReadPlayer(TempIndexID1,'postromuskill'),1)); | |
AddEventDisplay(Killer,'+1 Postromus Kill'); | |
end; | |
if (PlayerInfo[Killer.ID].Revenge[Victim.ID] = true) then begin | |
ChangeState(TempIndexID1,'revengekills',AddNum(ReadPlayer(TempIndexID1,'revengekills'),1)); | |
AddEventDisplay(Killer,'+1 Revenge Kill'); | |
PlayerInfo[Killer.ID].Revenge[Victim.ID] := false; | |
end; | |
if (Victim.Flagger) then begin | |
ChangeState(TempIndexID1,'flagerkills',AddNum(ReadPlayer(TempIndexID1,'flagerkills'),1)); | |
AddEventDisplay(Killer,'+1 Flager Kill'); | |
end; | |
end; | |
PlayerInfo[Victim.ID].Revenge[Killer.ID] := true; for i := 1 to 32 do if (Players[i].Active) and (i<>Killer.ID) then PlayerInfo[Victim.ID].Revenge[i] := false; | |
if (PlayerInfo[Victim.ID].NickStatus) then begin | |
ChangeState(TempIndexID2,'deaths',AddNum(ReadPlayer(TempIndexID2,'deaths'),1)); | |
AddEventDisplay(Victim,'+1 Deaths'); | |
end; | |
if (PlayerInfo[Killer.ID].NickStatus) and (PlayerInfo[Victim.ID].NickStatus) then Give(TempIndexID1,TempIndexID2); | |
AvengerModule(Killer,Victim); | |
end else | |
begin | |
if (PlayerInfo[Killer.ID].NickStatus) then begin | |
ChangeState(TempIndexID1,'teamkills',AddNum(ReadPlayer(TempIndexID1,'teamkills'),1)); | |
AddEventDisplay(Killer,'+1 Teamkill'); | |
end; | |
if (PlayerInfo[Victim.ID].NickStatus) then begin | |
ChangeState(TempIndexID2,'deathsbyteam',AddNum(ReadPlayer(TempIndexID2,'deathsbyteam'),1)); | |
AddEventDisplay(Victim,'+1 DeathByTeam'); | |
end; | |
end; | |
SaviorModule(Killer,Victim); | |
AssistModule(Killer,Victim); | |
end else SelfkillModule(Victim); | |
if (SaveMemoryPriority>2) then Memory.SaveToFile(PatchCore+'accounts.db'); | |
end; | |
function OnDamage(Shooter, Victim: TActivePlayer; Damage: Single; BulletId: Byte): Single; | |
var TempIndexID: int64; | |
begin | |
if (Shooter.ID <> Victim.ID) then begin | |
if (GameStyle = 0) or (GameStyle = 1) or (GameStyle = 4) then begin | |
PlayerInfo[Shooter.ID].SaviorTimer[Victim.ID] := SaviorTime; | |
PlayerInfo[Shooter.ID].AssistDamageMade[Victim.ID] := PlayerInfo[Shooter.ID].AssistDamageMade[Victim.ID]+Damage; | |
PlayerInfo[Shooter.ID].AssistCooldown[Victim.ID] := AssistTime; | |
end else | |
begin | |
if (Shooter.Team <> Victim.Team) then begin | |
PlayerInfo[Shooter.ID].SaviorTimer[Victim.ID] := SaviorTime; | |
PlayerInfo[Shooter.ID].AssistDamageMade[Victim.ID] := PlayerInfo[Shooter.ID].AssistDamageMade[Victim.ID]+Damage; | |
PlayerInfo[Shooter.ID].AssistCooldown[Victim.ID] := AssistTime; | |
end; | |
end; | |
if (PlayerInfo[Shooter.ID].NickStatus) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Shooter.Name); | |
if (GameStyle = 0) or (GameStyle = 1) or (GameStyle = 4) then begin | |
if ((Map.Bullets[BulletId].GetOwnerWeaponId = 16) and (Damage >= 25)) or ((Map.Bullets[BulletId].GetOwnerWeaponId = 7) and (Damage >= 40)) then ChangeState(TempIndexID,'shoothits',AddNum(ReadPlayer(TempIndexID,'shoothits'),1)); | |
if (Map.Bullets[BulletId].GetOwnerWeaponId <> 16) and (Map.Bullets[BulletId].GetOwnerWeaponId <> 7) and (Map.Bullets[BulletId].GetOwnerWeaponId <> 50) and (Map.Bullets[BulletId].GetOwnerWeaponId <> 15) then ChangeState(TempIndexID,'shoothits',AddNum(ReadPlayer(TempIndexID,'shoothits'),1)); | |
end else | |
begin | |
if (Shooter.Team<>Victim.Team) then begin | |
if ((Map.Bullets[BulletId].GetOwnerWeaponId = 16) and (Damage >= 25)) or ((Map.Bullets[BulletId].GetOwnerWeaponId = 7) and (Damage >= 40)) then ChangeState(TempIndexID,'shoothits',AddNum(ReadPlayer(TempIndexID,'shoothits'),1)); | |
if (Map.Bullets[BulletId].GetOwnerWeaponId <> 16) and (Map.Bullets[BulletId].GetOwnerWeaponId <> 7) and (Map.Bullets[BulletId].GetOwnerWeaponId <> 50) and (Map.Bullets[BulletId].GetOwnerWeaponId <> 15) then ChangeState(TempIndexID,'shoothits',AddNum(ReadPlayer(TempIndexID,'shoothits'),1)); | |
end; | |
if (Shooter.Team=Victim.Team) then ChangeState(TempIndexID,'shootfriendly',AddNum(ReadPlayer(TempIndexID,'shootfriendly'),1)); | |
end; | |
end; | |
end; | |
if (SaveMemoryPriority>3) then Memory.SaveToFile(PatchCore+'accounts.db'); | |
Result:=Damage; | |
end; | |
procedure DropFlag(Player: TActivePlayer; Flag: TActiveFlag; Team: Byte; Thrown: Boolean); | |
var TempIndexID: int64; | |
begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (PlayerInfo[Player.ID].NickStatus = true) then begin | |
if (Thrown) then begin | |
ChangeState(TempIndexID,'flagthrown',AddNum(ReadPlayer(TempIndexID,'flagthrown'),1)) | |
AddEventDisplay(Player,'+1 Flag Thrown'); | |
end else | |
begin | |
ChangeState(TempIndexID,'flagdrop',AddNum(ReadPlayer(TempIndexID,'flagdrop'),1)); | |
AddEventDisplay(Player,'+1 Flag Drop'); | |
end; | |
end; | |
end; | |
procedure FlagGrab(Player: TActivePlayer; TFlag: TActiveFlag; Team: Byte; GrabbedInBase: Boolean); | |
var TempIndexID: int64; | |
begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (GrabbedInBase) and (PlayerInfo[Player.ID].NickStatus = true) then begin | |
ChangeState(TempIndexID,'flaggrab',AddNum(ReadPlayer(TempIndexID,'flaggrab'),1)); | |
AddEventDisplay(Player,'+1 Flag Grab'); | |
end; | |
end; | |
procedure FlagReturn(Player: TActivePlayer; Flag: TActiveFlag; Team: Byte); | |
var TempIndexID: int64; | |
begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); | |
if (PlayerInfo[Player.ID].NickStatus = true) then begin | |
ChangeState(TempIndexID,'flagreturn',AddNum(ReadPlayer(TempIndexID,'flagreturn'),1)); | |
AddEventDisplay(Player,'+1 Flag Return'); | |
end; | |
end; | |
procedure FlagScore(Player: TActivePlayer; Flag: TActiveFlag; Team: Byte); | |
var TempIndexID: int64; LastPoints, NewPoints, PlayerRealLostPoints, CapperPoints, OtherTeamPoints, FriendlyPlayerRegNum: integer; i: byte; | |
begin | |
for i := 1 to 32 do if (Players[i].Active) then begin | |
if (Players[i].Team<>Player.Team) and (PlayerInfo[i].NickStatus) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[i].Name); | |
LastPoints := strtoint(ReadPlayer(TempIndexID,'points')); NewPoints := (LastPoints-CapGivePointsForEnemy); ChangeState(TempIndexID,'points',inttostr(NewPoints)); RankSetPos(TempIndexID,LastPoints,NewPoints); | |
AddEventDisplay(Players[i],'-'+inttostr(CapGivePointsForEnemy)+'pts Enemy Cap'); | |
PlayerRealLostPoints := (PlayerRealLostPoints+CapGivePointsForEnemy); | |
end; | |
end; | |
if (SaveMemoryPriority>1) then Memory.SaveToFile(PatchCore+'accounts.db'); | |
if (KeepTeamScore) then begin | |
bal.tempAlphaScore := Game.Teams[1].Score; | |
bal.tempBravoScore := Game.Teams[2].Score; | |
end; | |
for i := 1 to 32 do if (Players[i].Active) then if (Players[i].Team=Player.Team) and (PlayerInfo[i].NickStatus) and (i<>player.id) then FriendlyPlayerRegNum := (FriendlyPlayerRegNum+1); | |
if (PlayerInfo[Player.ID].NickStatus) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Player.Name); LastPoints := strtoint(ReadPlayer(TempIndexID,'points')); | |
if (PlayerRealLostPoints=0) then exit; | |
if (FriendlyPlayerRegNum>0) then CapperPoints := Round((CapperPointsPrecent*PlayerRealLostPoints)/100.0) else CapperPoints := PlayerRealLostPoints; NewPoints := (LastPoints+CapperPoints); | |
ChangeState(TempIndexID,'points',inttostr(NewPoints)); RankSetPos(TempIndexID,LastPoints,NewPoints); | |
ChangeState(TempIndexID,'flagscore',AddNum(ReadPlayer(TempIndexID,'flagscore'),1)); | |
if (Player.Team=1) then begin | |
ChangeState(TempIndexID,'alphacaps',AddNum(ReadPlayer(TempIndexID,'alphacaps'),1)); | |
AddEventDisplay(Player,'+'+inttostr(CapperPoints)+'pts, +1 Flag Score, +1 Alpha Cap'); | |
end; | |
if (Player.Team=2) then begin | |
ChangeState(TempIndexID,'bravocaps',AddNum(ReadPlayer(TempIndexID,'bravocaps'),1)); | |
AddEventDisplay(Player,'+'+inttostr(CapperPoints)+'pts, +1 Flag Score, +1 Bravo Cap'); | |
end; | |
end; | |
if (FriendlyPlayerRegNum>0) then begin | |
OtherTeamPoints := Round(((100-CapperPointsPrecent)*PlayerRealLostPoints)/100.0); | |
OtherTeamPoints := Round(OtherTeamPoints/FriendlyPlayerRegNum); | |
if (OtherTeamPoints>0) then begin | |
for i := 1 to 32 do if (Players[i].Active) then begin | |
if (Players[i].Team=Player.Team) and (PlayerInfo[i].NickStatus) and (i<>player.id) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[i].Name); LastPoints := strtoint(ReadPlayer(TempIndexID,'points')); | |
NewPoints := Round(LastPoints+OtherTeamPoints); | |
ChangeState(TempIndexID,'points',inttostr(NewPoints)); RankSetPos(TempIndexID,LastPoints,NewPoints); | |
AddEventDisplay(Players[i],'+'+inttostr(OtherTeamPoints)+'pts Friendly Cap'); | |
end; | |
end; | |
end; | |
end; | |
end; | |
procedure OnGameEnd(); | |
var i: byte; TempIndexID:int64; | |
begin | |
if (Game.NumPlayers>1) then begin | |
for i := 1 to 32 do if (Players[i].Active) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[i].Name); | |
if (Players[i].Team = 1) and (PlayerInfo[i].NickStatus) then begin | |
if (Game.ScoreLimit = Game.Teams[1].Score) or ((Game.Teams[2].Score < Game.Teams[1].Score) and (Game.Teams[3].Score < Game.Teams[1].Score) and (Game.Teams[4].Score < Game.Teams[1].Score)) then begin | |
ChangeState(TempIndexID,'alphawins',AddNum(ReadPlayer(TempIndexID,'alphawins'),1)); | |
ChangeState(TempIndexID,'wins',AddNum(ReadPlayer(TempIndexID,'wins'),1)); | |
AddEventDisplay(Players[i],'+1 Win, +1 Alpha Win'); | |
end else | |
begin | |
if (AlphaScore < Game.Teams[2].Score) or (AlphaScore < Game.Teams[4].Score) or (AlphaScore < Game.Teams[3].Score) then begin | |
ChangeState(TempIndexID,'alphalose',AddNum(ReadPlayer(TempIndexID,'alphalose'),1)); | |
ChangeState(TempIndexID,'lose',AddNum(ReadPlayer(TempIndexID,'lose'),1)); | |
AddEventDisplay(Players[i],'+1 Lose, +1 Alpha Lose'); | |
end else | |
begin | |
ChangeState(TempIndexID,'remis',AddNum(ReadPlayer(TempIndexID,'remis'),1)); | |
AddEventDisplay(Players[i],'+1 Draws'); | |
end; | |
end; | |
end; | |
if (Players[i].Team = 2) then begin | |
if (Game.ScoreLimit = Game.Teams[2].Score) or ((AlphaScore < Game.Teams[2].Score) and (Game.Teams[3].Score < Game.Teams[2].Score) and (Game.Teams[4].Score < Game.Teams[2].Score)) then begin | |
ChangeState(TempIndexID,'bravowins',AddNum(ReadPlayer(TempIndexID,'bravowins'),1)); | |
ChangeState(TempIndexID,'wins',AddNum(ReadPlayer(TempIndexID,'wins'),1)); | |
AddEventDisplay(Players[i],'+1 Win, +1 Alpha Win'); | |
end else | |
begin | |
if (Game.Teams[2].Score < AlphaScore) or (Game.Teams[2].Score < Game.Teams[4].Score) or (Game.Teams[2].Score < Game.Teams[3].Score) then begin | |
ChangeState(TempIndexID,'bravolose',AddNum(ReadPlayer(TempIndexID,'bravolose'),1)); | |
ChangeState(TempIndexID,'lose',AddNum(ReadPlayer(TempIndexID,'lose'),1)); | |
AddEventDisplay(Players[i],'+1 Lose, +1 Bravo Lose'); | |
end else | |
begin | |
ChangeState(TempIndexID,'remis',AddNum(ReadPlayer(TempIndexID,'remis'),1)); | |
AddEventDisplay(Players[i],'+1 Draws'); | |
end; | |
end; | |
end; | |
end; | |
end; | |
end; | |
procedure ScriptDecl(); | |
var i:byte; | |
begin | |
for i := 1 to 32 do begin | |
Players[i].OnCommand := @Commands; | |
Players[i].OnSpeak := @Speak; | |
Players[i].OnKill := @OnKill; | |
Players[i].OnFlagDrop := @DropFlag; | |
Players[i].OnFlagGrab := @FlagGrab; | |
Players[i].OnFlagReturn := @FlagReturn; | |
Players[i].OnFlagScore := @FlagScore; | |
Players[i].OnDamage := @OnDamage; | |
Players[i].OnWeaponChange := @OnWepChange; | |
end; | |
Game.OnJoin := @JoinGame; | |
for i := 0 to 5 do Game.Teams[i].OnJoin := @JoinTeam; | |
Map.OnBeforeMapChange := @ChangeBefore; | |
Map.OnAfterMapChange := @ChangeAfter; | |
Game.OnLeave := @LeaveGame; | |
Game.TickThreshold:=1; | |
Game.OnClockTick := @Timers; | |
Script.OnUnhandledException := @DebugCreateFile; | |
WriteLn('[ZitroFUN] Declares the functions complete!'); | |
end; | |
procedure ScriptRecompile(); | |
var i:byte; TempIndexID:int64; | |
begin | |
MaxHealth := iif(Game.Realistic,65,150); | |
if (File.Exists(PatchCore+'accounts.db')) then Memory := File.CreateStringListFromFile(PatchCore+'accounts.db') else CreateMemory(); | |
TempRank := File.CreateStringList(); | |
WriteLn('[ZitroFUN] Preparing memory complete!'); | |
LoadList(); | |
RecompileBalance(); | |
for i := 1 to 32 do if (Players[i].Active) and (Players[i].Human) then begin | |
TempIndexID := Memory.IndexOf('%name%'+Players[i].Name); | |
if (TempIndexID > -1) then AutoLogin(Players[i],TempIndexID) else AutoReg(Players[i]); | |
end; | |
end; | |
procedure Convert(AndResetStats:boolean); | |
var PlayerList, MEM, PlayerData: TStringList; i:int64; | |
begin | |
WriteLn('[ZitroFUN] Start convert old profiles to system 2.0.0 ..'); | |
PlayerList := File.CreateStringListFromFile(PatchCore+'server\players.db'); | |
MEM := File.CreateStringList(); | |
for i := 0 to PlayerList.Count-1 do begin | |
if (File.Exists(PatchCore+PlayerList[i])) then begin | |
PlayerData := File.CreateStringListFromFile(PatchCore+PlayerList[i]); | |
MEM.Append('%name%'+PlayerData[0]); | |
MEM.Append(PlayerData[1]); | |
MEM.Append(PlayerData[3]+'%ip%'+PlayerData[2]); | |
MEM.Append(inttostr(Random(1,4000))); | |
MEM.Append(FormatDate('dd mmmm yyyy')+' at: '+FormatDate('hh:nn:ss')+'%lp%'+FormatDate('dd mmmm yyyy')+' at: '+FormatDate('hh:nn:ss')); //Register date:Last play date | |
MEM.Append('0%first%0%autologin%'+lowercase(PlayerData[4])+'%mail%'); //FirstUseageCommand !login:AutoLoginType:Mail | |
MEM.Append(inttostr(Random(26,1200))+'%k%'+inttostr(Random(26,1200))+'%d%'+inttostr(Random(26,1200))+'%s%0%t%0%dt%0%p%0%a%0%r%0%z%0%w%0'); //Kills:Deaths:SelfKills:TeamKills:DeathsByTeam:PostromusKill:Assist:RevengeKills:Avenger:Wybawiel:FlagerKills | |
MEM.Append('0%fg%0%fr%0%fs%0%fd%0%ac%0%bc%0%ir%0%ib%0%hr%0%ft%0'); //FlagGrab:FlagReturn:FlagScore:FlagDrop:AlphaCaps:BravoCaps:INF_Red:INF_Blue:HTF_Red:HTF_Blue:FlagThrown | |
MEM.Append('0%w%0%l%0%r%0%aw%0%al%0%bw%0%bl%0%cw%0%cl%0%dw%0'); //Win:Lose:Remis:AlphaWins:AlphaLose:BravoWins:BravoLose:CharlieWin:CharlieLose:DeltaWin:DeltaLose | |
MEM.Append('0%s%0%sh%0'); //Shoots:ShootHits:ShootFriendly | |
File.delete(PatchCore+PlayerList[i]); | |
PlayerData.Free; | |
end else continue; | |
end; | |
PlayerList.Free; | |
Mem.SaveToFile(PatchCore+'accounts.db'); | |
Mem.Free; | |
WriteLn('[ZitroFUN] Convert old profiles completed!'); | |
end; | |
initialization | |
begin | |
//Convert(); | |
ScriptDecl(); | |
ScriptRecompile(); | |
WriteLN('[ZitroFUN] Script Start :)') | |
end; | |
finalization; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment