0 Members and 1 Guest are viewing this topic.
procedure OnFlagScore(Id, TeamFlag: byte);var Time: cardinal; Stat: string;begin if (not Ignore) then begin Time := GetTime; Stat := GetPlayerStat(Id, 'Name') + #3 + InttoStr(GetPlayerStat(Id, 'Team')) + #3 + GetPlayerStat(Id, 'Deaths') + #3 + InttoStr(Time - Player[Id].RespawnTime) + #3 + InttoStr(Time - Player[Id].JoinTime) + #3 + InttoStr(Time - MapStartTime) + #3 + FormatDate('yy-mm-dd') + #3 + FormatDate('hh:nn:zzz') + #3 + CurrentMap; WriteLnFile('scripts/' + ScriptName + '/logs/date/' + FormatDate('yy-mm-dd') +'.log',Stat); WriteLnFile('scripts/' + ScriptName + '/logs/player/' + MD5(GetPlayerStat(Id, 'Name')) +'.log',Stat); WriteLnFile('scripts/' + ScriptName + '/logs/map/' + CurrentMap +'.log',Stat); WriteLn(GetPlayerStat(Id, 'Name') + ' capped ' + CurrentMap + ' in ' + FloattoStr(PlayerTime(Player[Id]) / 1000) + 's with ' + InttoStr(GetPlayerStat(Id, 'Deaths')) + ' death' + iif(GetPlayerStat(Id, 'Deaths') = 1, '', 's')); WriteConsole(0, GetPlayerStat(Id, 'Name') + ' capped ' + CurrentMap + ' in ' + FloattoStr(PlayerTime(Player[Id]) / 1000) + 's with ' + InttoStr(GetPlayerStat(Id, 'Deaths')) + ' death' + iif(GetPlayerStat(Id, 'Deaths') = 1, '', 's'), Color); if (not CapNext and CapKill) then DoDamage(Id, 4000); if (CapNext) then Command('/nextmap'); if (CapRes) then Player[Id].RespawnTime := GetTime; end else begin WriteLn('Unable to log ' + GetPlayerStat(Id, 'Name') + '''s cap'); WriteConsole(0, 'Unable to log ' + GetPlayerStat(Id, 'Name') + '''s cap', Color); if (not CapNext and CapKill) then DoDamage(Id, 4000); if (CapNext) then Command('/nextmap'); if (CapRes) then Player[Id].RespawnTime := GetTime; end;end;
HiI have a problem with climb script.What is this error?TopCap -> (OnFlagScore): Could not convert variant of type (String) into type (Double)Hey!Does it actualy crash your soldatserver or does it just give you the error message in arsse sometimes?
Error is that,when I score,doesn't write to folders.
procedure OnFlagScore(Id, TeamFlag: byte);var Time: cardinal; Stat: string;begin if (not Ignore) then begin Time := GetTime; Stat := GetPlayerStat(Id, 'Name') + #3 + InttoStr(GetPlayerStat(Id, 'Team')) + #3 + IntToStr(GetPlayerStat(Id, 'Deaths')) + #3 + InttoStr(Time - Player[Id].RespawnTime) + #3 + InttoStr(Time - Player[Id].JoinTime) + #3 + InttoStr(Time - MapStartTime) + #3 + FormatDate('yy-mm-dd') + #3 + FormatDate('hh:nn:zzz') + #3 + CurrentMap; WriteLnFile('scripts/' + ScriptName + '/logs/date/' + FormatDate('yy-mm-dd') +'.log',Stat); WriteLnFile('scripts/' + ScriptName + '/logs/player/' + MD5(GetPlayerStat(Id, 'Name')) +'.log',Stat); WriteLnFile('scripts/' + ScriptName + '/logs/map/' + CurrentMap +'.log',Stat); WriteLn(GetPlayerStat(Id, 'Name') + ' capped ' + CurrentMap + ' in ' + FloattoStr(PlayerTime(Player[Id]) / 1000) + 's with ' + InttoStr(GetPlayerStat(Id, 'Deaths')) + ' death' + iif(GetPlayerStat(Id, 'Deaths') = 1, '', 's')); WriteConsole(0, GetPlayerStat(Id, 'Name') + ' capped ' + CurrentMap + ' in ' + FloattoStr(PlayerTime(Player[Id]) / 1000) + 's with ' + InttoStr(GetPlayerStat(Id, 'Deaths')) + ' death' + iif(GetPlayerStat(Id, 'Deaths') = 1, '', 's'), Color); end else begin WriteLn('Unable to log ' + GetPlayerStat(Id, 'Name') + '''s cap'); WriteConsole(0, 'Unable to log ' + GetPlayerStat(Id, 'Name') + '''s cap', Color); end; if (not CapNext and CapKill) then DoDamage(Id, 4000); if (CapNext) then Command('/nextmap'); if (CapRes) then Player[Id].RespawnTime := GetTime;end;
procedure ShowStats(const Num: integer; const Style: string; Filename: string; ID: byte);var Team, Deaths: byte; i: integer; RespawnTime, JoinTime, MapTime: cardinal; Buffer, Name, Date, Time, sMap: string; Stats: tStats; PStats: tPlayer; Split: array of string;begin Style := LowerCase(Style); Buffer := ReadFile('scripts/' + ScriptName + '/logs/' + Style + '/' + iif(Style = 'player', MD5(Filename), Filename) + '.log'); if (Buffer <> '') then begin Buffer := StrReplace(Buffer, #13, #10); Buffer := StrReplace(Buffer, #10#10, #10); Split := Explode(Buffer, #10); SetArrayLength(Split, GetArrayLength(Split) - 1); Buffer := ''; if (GetArrayLength(Split) > 0) then begin if (Num > 0) then begin Buffer := Uppercase(Style[1]) + Copy(Style, 2, Length(Style)) + ' stats for ' + Filename + ' (' + InttoStr(MinI([GetArrayLength(Split), Num])) + '/' + InttoStr(GetArrayLength(Split)) + ' results):' + #10; if (Style = 'map') then QuickSort(Split, 0, GetArrayLength(Split) - 1); for i := GetArrayLength(Split) - 1 downto MaxI([0, GetArrayLength(Split) - Num]) do begin if (Split[i] <> '') then begin Stats := ParseStat(Split[i]); Buffer := Buffer + Stats.Name + ' capped ' + Stats.Map + ' in ' + FloattoStr(StatsTime(Stats) / 1000) + 's with ' + InttoStr(Stats.Deaths) + ' death' + iif(Stats.Deaths = 1, '', 's') + ' (' + GetPiece(Stats.Date, '-', 1) + '-' + GetPiece(Stats.Date, '-', 2) + '-' + GetPiece(Stats.Date, '-', 0) + ')' + #10; end; end; end else Buffer := ''; end else Buffer := ''; end else Buffer := ''; if (Buffer <> '') then begin SetArrayLength(Split, 0); Split := Explode(Buffer, #10); SetArrayLength(Split, GetArrayLength(Split) - 1) if GetArrayLength(Split) > 0 then begin for i := 0 to GetArrayLength(Split) - 1 do begin WriteConsole(ID, Split[i], Color); end; end else WriteConsole(ID, 'No ' + Style + ' stats for ' + iif(Style = 'date', GetPiece(Filename, '-', 1) + '-' + GetPiece(Filename, '-', 2) + '-' + GetPiece(Filename, '-', 0), Filename), Color); end else WriteConsole(ID, 'No ' + Style + ' stats for ' + iif(Style = 'date', GetPiece(Filename, '-', 1) + '-' + GetPiece(Filename, '-', 2) + '-' + GetPiece(Filename, '-', 0), Filename), Color);end;procedure OnPlayerSpeak(Id: byte; Text: string);var Num: byte; Arg: string;begin // !top[n=3] [map=CM]; !stats[n=3] [name=self]; !date[n=3] [date=today]; !time // if (Text[1] = '!') then begin Delete(Text, 1, 1); if (StrPos(' ', Text) = 0) then Text := Text + ' '; if (LowerCase(Copy(Text, 1, 3)) = 'top') then begin try Num := MinI([nHigh, StrtoInt(Copy(Text, 4, StrPos(' ', Text) - 4))]); except Num := 3; end; Arg := Copy(Text, StrPos(' ', Text) + 1, Length(Text)); if (Arg = '') then Arg := CurrentMap; ShowStats(Num, 'map', Arg, ID); end else if (LowerCase(Copy(Text, 1, 5)) = 'stats') then begin try Num := MinI([nHigh, StrtoInt(Copy(Text, 6, StrPos(' ', Text) - 6))]); except Num := 3; end; Arg := Copy(Text, StrPos(' ', Text) + 1, Length(Text)); if (Arg = '') then Arg := GetPlayerStat(Id, 'Name'); ShowStats(Num, 'player', Arg, ID); end else if (LowerCase(Copy(Text, 1, 4)) = 'date') then begin try Num := MinI([nHigh, StrtoInt(Copy(Text, 5, StrPos(' ', Text) - 5))]); except Num := 3; end; Arg := Copy(Text, StrPos(' ', Text) + 1, Length(Text)); if ((Arg = '') or (LowerCase(Arg) = 'today')) then begin Arg := FormatDate('yy-mm-dd'); end else if ((LowerCase(Arg) = 'yest') or (LowerCase(Arg) = 'yesterday')) then begin Arg := FormatDate('yy-mm-dd'); Arg := GetPiece(Arg, '-', 0) + '-' + GetPiece(Arg, '-', 1) + '-' + TwoDigit(InttoStr(1 + StrtoInt(GetPiece(Arg, '-', 2)))); end else begin Arg := StrReplace(Arg, '/', '-'); Arg := StrReplace(Arg, ':', '-'); Arg := TwoDigit(GetPiece(Arg, '-', 2)) + '-' + TwoDigit(GetPiece(Arg, '-', 0)) + '-' + TwoDigit(GetPiece(Arg, '-', 1)); end; ShowStats(Num, 'date', Arg, ID); end; end;end;