Home   Help Search Login Register  

Author Topic: Counting problem  (Read 1386 times)

0 Members and 1 Guest are viewing this topic.

Offline unknownx9

  • Members
  • *
Counting problem
« on: 25 May 2011, 05:47:29 »
Hello,

I have these two scripts I am working with:

Script 1:
private["_target","_instructor"];

_target = AR49;
_instructor = player;
endNumber = 0;
cnt = 0;

_instructor commandChat "Welcome to the AR range.";
sleep 2;
_instructor commandChat "Setting up course.";
sleep 2;
_instructor commandChat "Ready";

_target animate["terc", 0];   

while{endNumber == 0}do
{
   _target addEventHandler ["hit",{cnt = cnt + 1;}];
   waitUntil {_target animationPhase "terc" != 0};
   _target animate["terc", 0];
};

if(endNumber != 0)exitWith{};

Script 2:
private["_target","_instructor"];

endNumber = 1;
_target = AR49;
_instructor = player;

_target animate["terc", 0];

_target removeEventHandler ["hit", 0];
_instructor commandChat format ["Targets hit: %1", cnt];
cnt = 0;
_instructor commandChat "Training complete";

The problem I am having is with the counting. When I finish firing on the target I am getting 11000+ count on the number of hits, which is not real based on a M249 "200" magazine round.

Any assistance would be much appreciated.

Offline F2kSel

  • Members
  • *
Re: Counting problem
« Reply #1 on: 25 May 2011, 15:30:13 »
this section is wrong it's assigning multiple eventhandlers to the target.

Code: [Select]
_target animate["terc", 0];  

while{endNumber == 0}do
{
   _target addEventHandler ["hit",{cnt = cnt + 1;}];
   waitUntil {_target animationPhase "terc" != 0};
   _target animate["terc", 0];
};


make it look like this
Code: [Select]
_target animate["terc", 0];  
   _target addEventHandler ["hit",{cnt = cnt + 1;}];

while{endNumber == 0}do
{
  waitUntil {_target animationPhase "terc" != 0};
   _target animate["terc", 0];
};

Also answered in the other forum.

Offline unknownx9

  • Members
  • *
Re: Counting problem
« Reply #2 on: 26 May 2011, 02:15:25 »
Thanks.

I am having a problem now when I put it on a dedicated server. The counting works fine when hosted locally, but when I test it on a dedicated server the count always returns 0. Any ideas?

« Last Edit: 27 May 2011, 13:38:07 by unknownx9 »