Name: Accuracy Script for Knife Only
Author: Mighty
Script version: 1.3
Server version: 2.6.5
Release Date: 18th of June 2010
Last Update: 6th of July 2010
Compile Test: PassedDescription: Script for Knife Only Servers made by Mighty.
Script counts Hits made by knives (both stabbs and throws) and Knife Throws.
Basing on these, returns Accuracy after typing !stats
Also in the end of map it shows best and worst accuracy.
Commands: * !stats - shows players accuracy
* !stats x - shows accuracy of player x (ID)
* !stats abc - shows accuracy of player whos name contains abc (min 3 characters)
Requirements: * All weapons except knives
disabled * Damage dealt by fist must
not be modified
Version 1.3 Changelog: * All bugs fixed
* Script executes when map changes any way (vote/scorelimit/timelimit)
Version 1.2 Changelog: * Bug with worst accuracy not showing -> fixed
* Added showing accuracy to every player (when the map ends)
Version 1.1 Changelog: * changed maxplayers to 32
* added procedures instead of writing all in defaults
* added some comments
* made it look a bit clearer i guess
* deleted inttofloat
* specs can now see accuracy also
* Added procedure that allows to check any players accuracy. Check
Commands.
---
Download attached!---
Code: {snippets}
(...)
procedure OnPlayerSpeak(ID: byte; Text: string);
begin
if (Copy(Text,1,6)='!stats') then
begin
if (Text='!stats') then
begin
NeededID := ID;
FoundID := TRUE;
end
else FindID(Copy(Text,8,Length(Text)));
IF (FoundID = TRUE) AND (GetPlayerStat(NeededID,'name') <> '') then
begin
// if player hasnt made throws yet, write it
if (AccThrows[NeededID] = 0) then WriteConsole(0,IDToName(NeededID)+' hasn`t made any throws yet',Color)
else
// else get his accuracy and return it
begin
Acc[NeededID] := RoundTo((AccHits[NeededID])/(AccThrows[NeededID]),4) * 100;
WriteConsole(0,IDToName(NeededID)+'`s Accuracy is ' + floattostr(Acc[NeededID]) + '% ('+inttostr(AccHits[NeededID])+'/'+inttostr(AccThrows[NeededID])+')',Color);
end;
end
else WriteConsole(0,'Match Not Found.',Color);
end;
end;
(...)
Questions? Bugs? Report please -->
macekmil@gmail.com