0 Members and 1 Guest are viewing this topic.
procedure OnMapChange(NewMap: String);beginaddscorehns();//Backup;sleep(2);Sortowanie(Database,0,ArrayHigh(Database));sleep(2);writeConsole(0, 'Yedekleme başarılı', RGB(132,112,255));end;procedure AppOnIdle(Ticks: integer); begin if (Ticks mod (60 * 140) = 0) then begin //writeConsole(0, 'Oyuncu sıralaması icin !top ya da !stats yazın', RGB(255,255,0)); _SnapDatabase(); end; if (Ticks mod (3600 * 120) = 0) then begin Backup; end; //// //if Ticks mod (60 * 10) = 0 then begin //every 10 seconds// GiveBonus(ID, 1); // pred mode// end;end;
procedure AppOnIdle(Ticks: integer); begin if (Ticks mod (3600 * 2) = 0) then begin Sortowanie(Database,0,ArrayHigh(Database)); end; if (Ticks mod (60 * 140) = 0) then begin {writeConsole(0, 'Oyuncu siralamasi icin !top ya da !stats yazin', RGB(255,255,0));} _SnapDatabase(); end; if (Ticks mod (3600 * 120) = 0) then begin Backup; end; { if Ticks mod (60 * 10) = 0 then begin GiveBonus(ID, 1); end; } end;procedure OnMapChange(NewMap: String);beginaddscorehns();Sortowanie(Database,0,ArrayHigh(Database));writeConsole(0, 'Yedekleme başarili', RGB(132,112,255));end;
Sortowanieaddscorehns();
You have used two procedures onmapchange.You have to combine them or remove one of them.
const FOLDER_DATABASE = 'DATA_PLAYERS/TOP/'; NAME_DATABASE = 'statsHNS.txt'; Players = 16;var RetID: integer; RetValidar: integer; RetCount: integer; ultimovenc: byte; database : array of string; Exception: string; Kills,Deaths,Caps,SelfKills: array [1..Players] of Word; _FOLDER_DATABASE,_NAME_DATABASE:String;procedure OnErrorOccur(const ERROR_MSG: string);begin Exception:= ERROR_MSG;end;function Rnd(A:String):String;varTemp:Single;beginTemp:=StrToFloat(A)*1000;Temp:=Round(Temp);Result:=FloatToStr(Temp/1000);end;function Rnc(A:String):String;varTemp:Single;beginTemp:=StrToFloat(A)*100;Temp:=Round(Temp);Result:=FloatToStr(Temp);end;function IXSplit(Source: string; const Delimiter: string): array of string;var Position, DelLength, ResLength: integer;begin DelLength := Length(Delimiter); Source := Source + Delimiter; repeat Position := Pos(Delimiter, Source); SetArrayLength(Result, ResLength + 1); Result[ResLength] := Copy(Source, 1, Position - 1); ResLength := ResLength + 1; Delete(Source, 1, Position + DelLength - 1); until (Position = 0); SetArrayLength(Result, ResLength - 1);end;function ReadFromFile(File: string): string;begin Result:= ReadFile(File); Result:= Copy(Result, 0, length(Result) - 2);end;function DoesFileExist(Name: string): boolean;begin if (GetSystem() = 'windows') then begin if (FileExists(Name)) then begin result:= true; end; end else begin if ((FileExists(Name)) or (ReadFromFile(Name) <> '')) then begin result:= true; end; end;end;procedure _LoadDatabase();begin if (DoesFileExist(_FOLDER_DATABASE + _NAME_DATABASE)) then begin database:= IXSplit(ReadFromFile(_FOLDER_DATABASE + _NAME_DATABASE), #13#10); end else begin WriteFile(_FOLDER_DATABASE + _NAME_DATABASE, ''); end;end;procedure _SnapDatabase();var i: integer; b: string;begin for i:= 0 to GetArrayLength(database) - 1 do begin if (b <> '') then begin b:= b + #13#10 + database[i]; end else begin b:= database[i]; end; end; WriteFile(_FOLDER_DATABASE + _NAME_DATABASE, b);end;function _RowExists(RowID: integer): boolean;begin result:= ArrayHigh(database) >= RowID;end;function _getColumnInfo(RowID, ColumnID: integer): integer;var ch, x, tabs: integer; b: string;begin tabs:= -1; b:= database[RowID]; while (tabs <> ColumnID) do begin x:= StrPos(#9, b); if ((x = 0) and (tabs <> ColumnID)) then begin exit; end; Inc(tabs, 1); if (tabs = ColumnID) then begin result:= ch + 1; break; end else begin ch:= ch + x; Delete(b, 1, x); end; end;end;function GetTypeOF(Value: variant): string;begin case VarType(Value) of 3 : result:= IntToStr(Value); 5 : result:= FloatToStr(Value); 11 : result:= iif(Value, 'true', 'false'); 256: result:= Value; else result:= 'unknown Type'; end;end;procedure _CreateRow(Columns: array of variant);var i, x: integer;begin SetArrayLength(database, GetArrayLength(database) + 1); x:= GetArrayLength(database) - 1; for i:= 0 to GetArrayLength(Columns) - 1 do begin database[x]:= database[x] + GetTypeOF(Columns[i]) + #9; end; _SnapDatabase();end;function _DeleteRow(RowID: integer): boolean;var HIndex: integer;begin if (_RowExists(RowID)) then begin HIndex:= GetArrayLength(database) - 1; if (RowID <> HIndex) then begin database[RowID]:= database[HIndex]; end; SetArrayLength(database, iif(HIndex > 0, HIndex - 1, 0)); _SnapDatabase(); result:= true; end else begin OnErrorOccur('RowID ' + IntToStr(RowID) + ' does not exist'); end;end;function _UpdateColumn(RowID, ColumnID: integer; Increase: extended): boolean;var data, Sum: string; poz: integer;begin if (_RowExists(RowID)) then begin poz:= _getColumnInfo(RowID, ColumnID); if (poz > 0) then begin data:= GetPiece(database[RowID], #9, ColumnID); if (RegExpMatch('^-?(\d+|\d+.?\d+)$', data)) then begin Sum:= FloatToStr(StrToFloat(data) + Increase); Delete(database[RowID], poz, length(data)); Insert(Sum, database[RowID], poz); result:= true; end else begin OnErrorOccur('Column "' + IntToStr(ColumnID) + '" represents no numeric value'); end; end else begin OnErrorOccur('ColumnID ' + IntToStr(ColumnID) + ' does not exist'); end; end else begin OnErrorOccur('RowID ' + IntToStr(RowID) + ' does not exist'); end;end;function _SetColumn(RowID, ColumnID: integer; Value: variant): boolean;var poz: integer; data: string;begin if (_RowExists(RowID)) then begin poz:= _getColumnInfo(RowID, ColumnID); if (poz > 0) then begin data:= GetPiece(database[RowID], #9, ColumnID); Delete(database[RowID], poz, length(data)); Insert(GetTypeOF(Value), database[RowID], poz); result:= true; end else begin OnErrorOccur('ColumnID ' + IntToStr(ColumnID) + ' does not exist'); end; end else begin OnErrorOccur('RowID ' + IntToStr(RowID) + ' does not exist'); end;end;function _AppendColumn(RowID: integer; Value: variant): boolean;begin if (_RowExists(RowID)) then begin database[RowID]:= database[RowID] + GetTypeOF(Value) + #9; result:= true; end else begin OnErrorOccur('RowID ' + IntToStr(RowID) + ' does not exist'); end;end;procedure ActivateServer();begin_FOLDER_DATABASE:=FOLDER_DATABASE;_NAME_DATABASE:=NAME_DATABASE;_LoadDatabase(); RetValidar:= 0; RetCount:= 0;writeln('Script TopHNS compilado com sucesso!');end;Procedure Backup;begin_FOLDER_DATABASE:='temp/';_NAME_DATABASE:='stats_'+FormatDate('yy-mm-dd hh-mm')+'.txt';_SnapDatabase;_NAME_DATABASE:=NAME_DATABASE;_FOLDER_DATABASE:=FOLDER_DATABASE;end;procedure Sortowanie(var Field: array of string; Left, Right: integer);var l, r: integer; Buffer: string; Pivot: Extended;begin // Check whether there is at least more than one element to sort if (Left < Right) then begin l:= Left; r:= Right; // Pick the Pivot element Pivot:= StrToFloat(GetPiece(Field[(Left + Right) shr 1], #9, 1)); // Presort repeat // Search an element which is smaller than the piviot while (StrToFloat(GetPiece(Field[l], #9, 1)) > Pivot) do begin Inc(l, 1); end; // Search an element which is greater than the pivot while (StrToFloat(GetPiece(Field[r], #9, 1)) < Pivot) do begin Dec(r, 1); end; // Swap the greater element with the smaller one if (l <= r) then begin Buffer:= Field[r]; Field[r]:= Field[l]; Field[l]:= Buffer; Inc(l, 1); Dec(r, 1); end; until (l >= r); if (Left < r) then begin Sortowanie(Field, Left, r); end; if (Right > l) then begin Sortowanie(Field, l, Right); end; end else begin exit; end;end;function IDByName(Name: string): byte;var i: byte;beginresult := 0;for i := 1 to 32 do if getplayerstat(i,'active')=true then begin if containsstring(lowercase(getplayerstat(i,'name')),lowercase(Name)) then begin result := i; break; end; end;end;function ConsultRowByPlayer(Name:String):longword;vari:Integer;Found:Boolean;beginFound:=False;For i:=0 to GetArrayLength(Database)-1 do beginif ContainsString(lowercase(GetPiece(Database[i], #9, 0)),lowercase(Name)) = true then begin Found:=True; Result:=i; Break; end;end;end;function GetRowByPlayer(Name:String):longword;vari:Integer;Found:Boolean;beginFound:=False;For i:=0 to GetArrayLength(Database)-1 do beginif Name=GetPiece(Database[i], #9, 0) then begin Found:=True; Result:=i; Break; end;end;If Not Found then beginResult:=GetArrayLength(Database);_CreateRow([Name,'0','0','1']);end;end;procedure SaveAllStats;vari:byte;row:Longword;Killss,Deathss,Capss:Word;beginfor i:=1 to Players do beginsleep(2);If GetPlayerStat(I,'active')=True then begin row:=GetRowByPlayer(IdToName(i));Capss:=StrToInt(GetPiece(Database[Row], #9, 1));Killss:=StrToInt(GetPiece(Database[Row], #9, 2))-1;Deathss:=StrToInt(GetPiece(Database[Row], #9, 3))-1;_SetColumn(Row, 2 , IntToStr(Killss+Kills[I]));_SetColumn(Row, 3 , IntToStr(Deathss+Deaths[I]));//_SetColumn(Row, 1 , Rnc(FloatToStr((Killss/Deathss*Killss)/100)));_SetColumn(Row, 1 , IntToStr(Capss+Caps[I]));//////////////////////////////////////////Kills[I]:=0;Deaths[I]:=0;Caps[I]:=0;end;end;_SnapDatabase();end;procedure SaveStats(i:Byte);varrow:Longword;Killss,Deathss,Capss:Integer;beginrow:=GetRowByPlayer(IdToName(i));Capss:=StrToInt(GetPiece(Database[Row], #9, 1));Killss:=StrToInt(GetPiece(Database[Row], #9, 2));Deathss:=StrToInt(GetPiece(Database[Row], #9, 3));_SetColumn(Row, 2 , IntToStr(Killss+Kills[I]));_SetColumn(Row, 3 , IntToStr(Deathss+Deaths[I]));//_SetColumn(Row, 1 , Rnc(FloatToStr((Killss/Deathss*Killss)/100)));_SetColumn(Row, 1 , IntToStr(Capss+Caps[I]));//////////////////////////////////////////Kills[I]:=0;Deaths[I]:=0;Caps[I]:=0;end;procedure addscorehns();vari:byte;begin for i:=1 to 32 do begin if GetPlayerStat(i, 'team')=1 then begin if ultimovenc = i then exit; if Caps[i] <= 0 then begin Caps[i]:= 0; end; Caps[i]:=Caps[i]+1; SaveStats(i); ultimovenc :=i; //command('/say Adicionado 1 ponto ao vencedor!') exit; end; end;end;Procedure ShowStatsQuickly(Id:Byte);varRow:Longword;beginRow:=GetRowByPlayer(IdToName(Id));//DrawText(Id,'Sıra ' +IntToStr(Row+1)+ ' / ' +IntToStr(GetArrayLength(Database)),330,RGB(255,255,255),0.18,40,370);WriteConsole(Id,'Sıra ' +IntToStr(Row+1)+ ' / ' +IntToStr(GetArrayLength(Database)),RGB(114,248,80));WriteConsole(Id, 'Puan: '+ GetPiece(Database[Row], #9, 1), RGB(114,248,80)); end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// KILL /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);begin If (Killer<>Victim) and (GetPlayerStat(Killer,'Team')<>GetPlayerStat(Victim,'Team')) then begin Kills[Killer]:=Kills[Killer]+1; Deaths[Victim]:=Deaths[Victim]+1; SaveStats(Killer); SaveStats(Victim); end;end;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// FLAG RETURN!! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////procedure OnFlagReturn(ID, TeamFlag: byte);begin// RetID := ID;// RetValidar:= 1;// RetCount:=6;end;procedure OnLeaveGame(ID, Team: byte;Kicked: boolean);beginend;Procedure ShowStats(Id:Byte);varRow:Longword;begin Row:=GetRowByPlayer(IdToName(Id)); DrawText(Id,'Sıra ' +IntToStr(Row+1)+ ' toplam ' +IntToStr(GetArrayLength(Database)),330, RGB(255,255,255),0.18,40,370); WriteConsole(Id, ' ', RGB(220,220,220)); sleep(2); WriteConsole(Id, ' Oyuncu ' + IdToName(Id) + ' Durum:',RGB(220,220,220)); sleep(2); WriteConsole(Id, ' --------------------------------------------------',RGB(220,220,220)); sleep(2); WriteConsole(Id, ' Sıra: '+ IntToStr(Row+1)+ 'º toplam '+ IntToStr(GetArrayLength(Database)), RGB(220,220,220)); sleep(2); WriteConsole(Id, ' *Puan: '+ GetPiece(Database[Row], #9, 1), RGB(255,255,0)); sleep(2); WriteConsole(Id, ' Oldurme: '+ GetPiece(Database[Row], #9, 2) + ' kez', RGB(173,255,47)); sleep(2); WriteConsole(Id, ' Oldurulme: '+ GetPiece(Database[Row], #9, 3) + ' kez', RGB(173,255,47)); //sleep(2); //WriteConsole(Id, ' Sonuc: '+ Rnd(FloatToStr(StrToFloat(GetPiece(Database[Row], #9, 2))/StrToFloat(GetPiece(Database[Row], #9, 3)))) + ' (1=Regular, 1.5=Bom, 2+=Excelente)', RGB(255,248,80)); sleep(2); WriteConsole(Id, ' ', RGB(220,220,220)); //WriteConsole(ID,' ---------------------',RGB(114,248,80));end;procedure ShowTop10(Id:byte);vari:byte;begin WriteConsole(Id, ' ',RGB(220,220,220)); WriteConsole(Id, '--------------------------------------------------', RGB(220,220,220)); sleep(2); WriteConsole(Id, 'Top 20 players no HIDE N SEEK:',RGB(114,248,80)); sleep(2); WriteConsole(Id, '--------------------------------------------------', RGB(220,220,220)); sleep(2); For i:=0 to iif(GetArrayLength(Database)>20,19,GetArrayLength(Database)-1) do begin If i<9 then WriteConsole(Id, IntToStr(i+1)+' - '+GetPiece(Database[i], #9, 0)+' = '+GetPiece(Database[i], #9, 1)+' Puan',RGB(255,255,0)); //, RGB(100,255,80)); If i>=9 then WriteConsole(Id, IntToStr(i+1)+' - '+GetPiece(Database[i], #9, 0)+' = '+GetPiece(Database[i], #9, 1)+' Puan',RGB(255,255,0)); //, RGB(100,255,80)); sleep(2); end;end; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SPEAK //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////procedure OnPlayerSpeak(ID: Byte; Text: string);varranks:string;Row:Longword;begin //Row := " " if (Text = '!stats') or (Text = '!Stats') or (Text = '!STATS') or (Text = '!Rank') or (Text = '!rank') or (Text = '!RANK') then ShowStats(ID); if regExpMatch('^!(top|top20)$', Text) then ShowTop10(ID); if (MaskCheck(Text,'!stats *')) then begin ranks := GetPiece(Text,'!stats ',1); //Row := GetRowByPlayer(ranks); Row := ConsultRowByPlayer(ranks); WriteConsole(ID, ' ', RGB(220,220,220)); WriteConsole(ID, ' Sonuç: ' +IntToStr(Row+1) + 'º = ' +GetPiece(Database[Row], #9, 0), RGB(220,220,220)); //Row:=GetRowByPlayer(IdToName(Id)) //if Row <> " " then begin //DrawText(Id,'Rank ' +IntToStr(Row+1)+ ' / ' +IntToStr(GetArrayLength(Database)),330,RGB(255,255,255),0.18,40,370); if GetPiece(Database[Row], #9, 0) = '0' then begin WriteConsole(ID, 'Oyuncu bulanamadı...',RGB(255,88,80)); end else begin DrawText(ID,' Sıra ' +IntToStr(Row+1)+ ' toplam ' +IntToStr(GetArrayLength(Database)),330, RGB(255,255,255),0.18,40,370); sleep(2); WriteConsole(ID, ' ', RGB(220,220,220)); sleep(2); WriteConsole(ID, ' Oyuncu ' + GetPiece(Database[Row], #9, 0) + ' Hide and SEEK:',RGB(220,220,220)); sleep(2); WriteConsole(ID, ' --------------------------------------------------',RGB(220,220,220)); sleep(2); WriteConsole(ID, ' Sıra: '+ IntToStr(Row+1)+ 'º toplam '+ IntToStr(GetArrayLength(Database)), RGB(220,220,220)); sleep(2); WriteConsole(ID, ' *Puan: '+ GetPiece(Database[Row], #9, 1), RGB(255,255,0)); sleep(2); WriteConsole(ID, ' Oldurme: '+ GetPiece(Database[Row], #9, 2) + ' kez', RGB(173,255,47)); sleep(2); WriteConsole(ID, ' Oldurulme: '+ GetPiece(Database[Row], #9, 3) + ' kez', RGB(173,255,47)); sleep(2); //WriteConsole(ID, ' Sonuc: '+ Rnd(FloatToStr(StrToFloat(GetPiece(Database[Row], #9, 2))/StrToFloat(GetPiece(Database[Row], #9, 3)))) + ' (1=Regular, 1.5=Bom, 2+=Excelente)', RGB(255,248,80)); //sleep(2); WriteConsole(ID, ' ', RGB(220,220,220)); //WriteConsole(ID,' ---------------------',RGB(114,248,80)); end; end; end;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// COMANDOS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////function OnCommand(ID: Byte; Text: string): boolean;beginif lowercase(Text) = '/backup' then beginwriteConsole(ID, 'Yedekleme başarılı',RGB(132,112,255));Backup;end;if lowercase(Text) = '/organizar' then beginwriteConsole(ID, 'Classificando players',RGB(255,165,0));Sortowanie(Database,0,ArrayHigh(Database));end;end;/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// MAP //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////procedure OnMapChange(NewMap: String);beginaddscorehns();//Backup;sleep(2);Sortowanie(Database,0,ArrayHigh(Database));sleep(2);writeConsole(0, 'Yedekleme başarılı', RGB(132,112,255));end;procedure AppOnIdle(Ticks: integer); begin if (Ticks mod (60 * 140) = 0) then begin //writeConsole(0, 'Sıralama icin !stats ve !top yazın', RGB(255,255,0)); _SnapDatabase(); end; if (Ticks mod (3600 * 120) = 0) then begin Backup; end; //// //if Ticks mod (60 * 10) = 0 then begin //cada 10 segundos// GiveBonus(ID, 1); // modo pred// end;end;
sleep(2);