Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: Mighty on June 18, 2010, 12:33:27 pm

Title: Accuracy Script for Knife Only v1.3
Post by: Mighty on June 18, 2010, 12:33:27 pm
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: (http://soldatcentral.com/images/pass.gif) Passed
Description:
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.

---
(http://soldatcentral.com/images/download.gif)
Download attached!
---
Code: {snippets}
Code: [Select]
(...)
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
Title: Re: Accuracy Script for Knife Only
Post by: VirtualTT on June 19, 2010, 02:26:44 am
Your integer<>float conversations aren't nice at all. Why didn't you set max players to 32? Also why can't spectators can see their stats (maybe they were playing before switching to spec)? Also it's a common bad practice to write all the code inside standard event procedures. It would be much better if you wrote properly named procedures with all your code and then called them from event procedures. Otherwise it's very hard to get what does every nameless cycle do and you'll forget it all in a week...
Title: Re: Accuracy Script for Knife Only
Post by: Mighty on June 19, 2010, 02:40:32 am
Thanks for advices, that's my 1st release, still need to learn alot :)

Quote
Why didn't you set max players to 32?
Hell good question :P
Title: Re: Accuracy Script for Knife Only
Post by: Swompie on June 19, 2010, 03:22:44 am
Yeah, just make it an array of 0..32
Second thing, you don't need IntToFloat anywhere, just use integers, it doesn't matter.
At least, use types when you already got that much vars, it makes the script look nicer ;p
And try to find your indenting style, you're sometimes putting spaces, another time TAB's and then none.

Gj tho, go on with such stuff  ;)
Title: Re: Accuracy Script for Knife Only v1.1
Post by: Mighty on June 19, 2010, 04:29:24 am

UPDATE TO 1.1
 
Title: Re: Accuracy Script for Knife Only v1.1
Post by: Irlandec on June 19, 2010, 06:12:11 am
Nice script , hope it will become the best for knife only servers! :)
Title: Re: Accuracy Script for Knife Only v1.1
Post by: Mighty on July 03, 2010, 05:25:44 pm
Update!

Attached new version and changelog to the 1st post

[1.42 pm 4th July] Edit: Fixed some minor bugs also
Title: Re: Accuracy Script for Knife Only v1.3
Post by: Mighty on July 06, 2010, 12:16:53 pm
Update to 1.3

Download (http://forums.soldat.pl/index.php?action=dlattach;topic=38414.0;attach=25436)
Title: Re: Accuracy Script for Knife Only v1.3
Post by: Beowulf Agate on September 29, 2010, 02:42:10 pm
How about adding average length of the player's throws to the script? Spawnkillers will be marked then.
Title: Re: Accuracy Script for Knife Only v1.3
Post by: Mighty on September 30, 2010, 03:46:35 am
Not a big deal, I'll do that when i have some free time.
Title: Re: Accuracy Script for Knife Only v1.3
Post by: Beowulf Agate on January 05, 2015, 03:02:23 pm
Yo Mighty  8) U still scriptin' ? It would be awesome to have this script fixed and working with current version.
Title: Re: Accuracy Script for Knife Only v1.3
Post by: Mighty on January 07, 2015, 04:04:07 am
Hey Beo! :>
I plan to rewrite most of the utility scripts I've made so they work with most recent versions, however, I'm currently pretty busy working so it may take some time :) That's going to be the first one though, if you need it.
Glad to see you still hosting, too. (I assume, why would you need KO scripts otherwise)