Jump to content
Sign in to follow this  
creartan

adding scoreboard death count?

Recommended Posts

adding scoreboard death count?

i want to add a death count via trigger not by killed event, is that possible?

and maybe the kill count too.. using

IncomingMissile event handler to add kill count to the shooter?

what is the CALL to do the COUNT? because i cannot find it in cfg viewer

Share this post


Link to post
Share on other sites

A killed EH would be much easier going both ways, because it passes the killed unit and the killer, you would just have to have global variables for both kills and deaths for each player/unit in the mission (define them in the init.sqf), unless there is another easier way to do it. You may be able to use get/set variable as well, not too sure, I can see it in my head but can't put it to code atm :p.

Share this post


Link to post
Share on other sites

Definitely the easiest way to do this is with a "Killed" EH, for both the kill count and the death count.

"IncomingMissile" is the wrong EH to use, because it is only run when a vehicle detects that a locked-on missile has been fired with it as the missile's target. Stay with the "Killed" EH.

The commands you'll want to look at for this are addScore and addScoreSide

Not sure what you mean with "what is the call". Are you looking for a proper example of use? The most useful example of count is "count array with condition", so I'll type one up.

_myVar = {damage _x > 0.5} count _enemyArray

This code will "count the number of units in array '_enemyArray' that have taken more than 50% of damage and save that number to a variable called '_myVar' ".

A good debug habit is to "translate" the code into your language to see if it makes sense/does what you intended it to do. This practice has saved me more than once when I've stayed up way too long, and had way too much beer to continue working on a script, yet still want to.

Share this post


Link to post
Share on other sites

addScore and addScoreSide commands are executed Server side only.

Killed eventhandler runs where the unit is local.

If unit does not belong to server as in server spawned AI than Killed eventhandler will not work unless you use a global variables inthe EH and you publicVariable the global variable.

The best MP way:

//init.sqf
if (isServer) then 
{
if (isNil "paddscore") then {paddscore = 0;};
"paddscore" addPublicVariableEventHandler {_data = _this select 1; (_data select 0) addScore (_data select 1);};
};

Then when you need to give score from client side

//player_side_script.sqf
_player = player;
_pscore = 2;
paddscore = [_player, _pscore];
publicVariableServer "paddscore";

When you need to give score from Server side use same as above except replace player with a variable representing player because Dedicated server does not recognize player command and replace publicVariableServer with publicVariable.

Edited by Jigsor

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×