Jump to content
Sign in to follow this  
Col. Ben Sherman

EventHanlder being triggered for everyone

Recommended Posts

Hi there, I have a question when it comes to eventhandlers. As I'm currently trying to track peoples statistics such as shots fired, shots hit etc. But for some reason if my friend shots I get's his statistics on my player which I'm not 100% on how to fix.

 

This is the code right now

player addEventHandler ["Fired", {
  shotsfired = shotsfired + 1;
}];

I tested outputting the values into a hint format once the event is happening.

Share this post


Link to post
Share on other sites
Hi there, I have a question when it comes to eventhandlers. As I'm currently trying to track peoples statistics such as shots fired, shots hit etc. But for some reason if my friend shots I get's his statistics on my player which I'm not 100% on how to fix.
 
This is the code right now
player addEventHandler ["Fired", { shotsfired = shotsfired + 1;}];

I tested outputting the values into a hint format once the event is happening.



Where are you putting that code?

Sent from my LG-H870 using Tapatalk

Share this post


Link to post
Share on other sites

look at the top here https://community.bistudio.com/wiki/addEventHandler

and the second last column in the table below on here https://community.bistudio.com/wiki/Arma_3:_Event_Handlers

 

when i was starting i was totally ignorant about these locality flags. they will save you a lot of headache and trial and error by simply telling you how commands and EHs behave in an MP environment. some EHs have detailed descriptions about it too, like "Hitpart"

 

talking about these little buggers

arguments_global.gifeffects_local.gif

Share this post


Link to post
Share on other sites
look at the top here https://community.bistudio.com/wiki/addEventHandler
and the second last column in the table below on here https://community.bistudio.com/wiki/Arma_3:_Event_Handlers
 
when i was starting i was totally ignorant about these locality flags. they will save you a lot of headache and trial and error by simply telling you how commands and EHs behave in an MP environment. some EHs have detailed descriptions about it too, like "Hitpart"
 
talking about these little buggers
arguments_global.gifeffects_local.gif


Ops code is all local though, unless there is more that he has not shown us or he is adding those EH's in a global position like init.sqf or an obects init line.

Sent from my LG-H870 using Tapatalk

Share this post


Link to post
Share on other sites

Doesn't matter where it is added since it is added for the (always) local player, and the variable incremented is always the global variable on a single machine. This could only lead to multiple countings if added too many times. But, if you see the friends value, that would suggests the value is somehow being made public (e.g. using publicVariable) and overwriting it on other machines.

Share this post


Link to post
Share on other sites
36 minutes ago, crazy538 said:

 


Ops code is all local though, unless there is more that he has not shown us or he is adding those EH's in a global position like init.sqf or an obects init line.

Sent from my LG-H870 using Tapatalk
 

 

 

It's added once the database is loaded, so first time it's calling the database staff is from initPlayerLocal.sqf  and then when the callback is received it applies the EH's to the player I assume since it's done with "player addEventHandler", but it's its local only why is the EH giving my player other players stuff, or do I have to like add the EH for the server somehow and then check if like the source is the player and then make a call so that the player increases his counts?

 

I'm not really understanding the local part, like how would I make it so that it's done per player if that's the case. So that the player actually gets the correct data. I'm so confused. Like I don't know too much about arma scripting, only like the basics of it. I'm surprised I actually got the database going xD so the more info I get the more I'll understand it xD. Thanks for all the quick replies though.

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  

×