Welcome, Guest Thursday 17th April 2014, 16:27:34
   Home   Help Search Login Register  

OFPEC Forum

Author Topic: Concurrent array usage by many fired EH  (Read 211 times)
0 Members and 1 Guest are viewing this topic.
j0e
*
Offline Offline


WWW
« on: 21 Feb 2012, 12:06:39 »

I'll try to be as clear as possible.
Of course the environment is the multiplayer.

PREFACE

I have an array in which I store the kills of each player:

  j0e_scores=[0,..,0]  // index 0->player1 and so on

A trigger covers the enemy soldiers and calls a script that parses each units by linking the killed-EH to it:

  <enemy> AddEventHandler ["KILLED",{_THIS Exec "score.sqs"}]

Until here, all is regular.

Note: the EHs are handled only by the server.

PROBLEM

When a massive kill is done, the server fires many EH in the same time.
I'm afraid, but not sure, that most of the "score.sqs" istances write their value in a situation of memory collision.

EXAMPLE

Player1 blows up a whole convoy: 18 soldiers are killed.
The score should be: player1=18.
Instead the stored value is often lower thant the expected one.

QUESTION<SUGGESTIONS

If the missed kills are due to the game that not fires all EHs, then there aren't solutions.
Otherwise, I'm thinking of three possible ways:

1) add a randomized pause (~) in the "score.sqs" to differentiate the instances timing and minimize collision events;

2) let each "score.sqs" istance to put itself in a FIFO list and wait its turn before changing the array;

3) provide an extra array with all enemy soldiers, identify the killed unit and add the killer in another array, in the same index;

  j0e_enemies=enemy1,enemy2,enemy3,..,enemyN
  j0e_killers=0,-1,-1,..,-1   // -1=alive or not killed by a player, 0=killed by player1

YOU

Any comment is appreaciated.
Logged
Pages: [1]   Go Up
  Send this topicPrint  
 
Jump to: