0 Members and 1 Guest are viewing this topic.
VARAccHits: array[1..16] of byte;(...)function OnPlayerDamage(Victim,Shooter: Byte;Damage: Integer;Weapon: Byte) : integer;begin // weapon 14 - knife If (Weapon=14) then AccHits[Shooter] := AccHits[Shooter] + 1; result := Damage;end;
It's not possible.
It's not possible
I meant how to count hits made with knives.
const Color = $EE30DDEE;var AccKnives1, AccKnives2, AccHits, AccThrows: array[1..16] of byte; Acc: array[0..16] of double; AccBestID: byte; AccWorstID: byte; i: byte;
function IntToFloat(Num: integer): single;beginresult := strtofloat(inttostr(num));end;
procedure ActivateServer();begin AccBestID := 0; AccWorstID := 0;end;
procedure OnPlayerSpeak(ID: byte; Text: string);begin if (Text='!stats') AND (GetPlayerStat(ID,'team')<>5) then begin if (AccThrows[ID] = 0) then WriteConsole(0,'Make some throws first',Color) else begin Acc[ID] := RoundTo(inttofloat(AccHits[ID])/inttofloat(AccThrows[ID]),4) * 100; WriteConsole(0,IDToName(ID)+', Your Accuracy is ' + floattostr(Acc[ID]) + '% ('+inttostr(AccHits[ID])+'/'+inttostr(AccThrows[ID])+')',Color); end; end;end;
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);beginIf ((PrimaryNum=14) AND (SecondaryNum=255)) OR ((PrimaryNum=255) AND (SecondaryNum=14)) then AccKnives1[ID] := 1;If (PrimaryNum=14) AND (SecondaryNum=14) then AccKnives1[ID]:=2;If (PrimaryNum=255) AND (SecondaryNum=255) then AccKnives1[ID] := 0;if (AccKnives2[ID]>AccKnives1[ID]) AND (GetPlayerStat(ID,'health')>0) then beginAccThrows[ID] := AccThrows[ID] + 1;end;If ((PrimaryNum=14) AND (SecondaryNum=255)) OR ((PrimaryNum=255) AND (SecondaryNum=14)) then AccKnives2[ID] := 1;If (PrimaryNum=14) AND (SecondaryNum=14) then AccKnives2[ID]:=2;If (PrimaryNum=255) AND (SecondaryNum=255) then AccKnives2[ID] := 0;end;
function OnPlayerDamage(Victim,Shooter: Byte;Damage: Integer) : integer;begin {Damage dealt by fists is always (?) 29/33/37} IF (Damage<>29) AND (Damage<>33) AND (Damage<>37) AND (Shooter<>Victim) then AccHits[Shooter] := AccHits[Shooter] + 1; result := Damage;end;
procedure OnPlayerRespawn(ID: byte);beginAccKnives1[ID] := 1;end;
procedure OnFlagScore(ID, TeamFlag: byte);beginif (AlphaScore=ScoreLimit) OR (BravoScore=ScoreLimit) then begin for i:=1 to MaxPlayers do begin If AccThrows[i] <> 0 then begin Acc[i] := RoundTo(inttofloat(AccHits[i])/inttofloat(AccThrows[i]),4) * 100; IF Acc[i] > Acc[AccBestID] then AccBestID := i; IF Acc[i] < Acc[AccWorstID] then AccWorstID := i; end; end; IF AccBestID <> 0 then WriteConsole(0,'Best Accuracy: '+ floattostr(Acc[AccBestID]) +' % by ' +IDToName(AccBestID)+' ['+inttostr(AccHits[AccBestID])+'/'+inttostr(AccThrows[AccBestID])+']',Color);IF AccWorstID <> 0 then WriteConsole(0,'Worst Accuracy: '+ floattostr(Acc[AccWorstID]) +' % by ' +IDToName(AccWorstID)+' ['+inttostr(AccHits[AccWorstID])+'/'+inttostr(AccThrows[AccWorstID])+']',Color);for i:=1 to MaxPlayers do begin AccHits[i] := 0; AccThrows[i] := 0; Acc[i] := 0; end; AccBestID := 0; AccWorstID := 0;end;end;
procedure OnJoinGame(ID, Team: byte);begin AccHits[ID] := 0; AccThrows[ID] := 0; Acc[ID] := 0; AccKnives1[ID] := 1; AccKnives2[ID] := 1;end;