OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Jakro on 15 Mar 2018, 13:16:00

Title: Script for calculating accuracy of fire?
Post by: Jakro on 15 Mar 2018, 13:16:00
I am basically making a mission which is very straightforward, just shooting a lot at enemies to train our beginner guys to become better at it.

I thought it would be a cool to have sort of an end statistic that shows for each player how many shots they fired and how many hit. However I dont know much about scripting so I would not know how to do it. Does such script already exist and if not, how would you go about creating it?

Actually just a counter for shots fired by each player would be enough to get an idea since the multiplayer automatically gives you the number of kills you have got.
Title: Re: Script for calculating accuracy of fire?
Post by: SoldierEPilot on 17 Mar 2018, 12:36:24
I'm not a MP scripter but anyway :D

Code: [Select]
code = "if (local player) then {player addRating 0.001}"
player addEventHandler ["fired", code]

To see statistics:
Code: [Select]
hint format ["%1 fired %2 times", name player, 1000*((rating player) %1)]
For chopper attack mission u can use
Code: [Select]
vehicle player addEventHandler ["fired", code]
Another way is to compare ammo counts of all weaps before
and after the fight
For M2 hmg:
Code: [Select]
ammoCount =  mg ammo (weapons ms select 0)
shotsHMG = 500 - ammoCount