Jump to content
Sign in to follow this  
shuko

publicVariable and addPublicVariableEventHandler

Recommended Posts

fuck it

Edited by Shuko

Share this post


Link to post
Share on other sites

You can also simply replace addEventHandler ["killed"

with addMPEventHandler ["MPKilled"

which is triggered globally, so you can attach them just on the server.

Perhaps not the best example?

Also captive units are registered with side == civilian too. Using side (group _x) would always return the proper side.

Edited by Sickboy

Share this post


Link to post
Share on other sites

init.sqf

// Global variable to hold the death counter.
DeadCivilians = 0;

This is not JIP safe. PV variables will be automatically synced for JIP, yet you

overwrite it locally again here as the init.sqf is processed after the JIP data is received.

Instead you need:

if (isNil "DeadCivilians") then {DeadCivilians = 0;};

The topic name should be clarified too, like "Example of ...".

Share this post


Link to post
Share on other sites
This is not JIP safe. PV variables will be automatically synced for JIP, yet you

overwrite it locally again here as the init.sqf is processed after the JIP data is received.

Doesn't matter since it will be re-overwritten next time the server PVs the var. Display is tied to update.

Share this post


Link to post
Share on other sites
Doesn't matter since it will be re-overwritten next time the server PVs the var. Display is tied to update.
If you'd use the isNil method the display will be fine immediately upon joining, without having to wait for an update (happening upon killed EH only I think).

I see you now removed the code - I wasn't saying it was crap - just that the used code to example the PV + PVEH, addEventHandler "Killed", perhaps wasn't the best to example this stuff in, because they can be easily done without using PV's. That just means i'd recommend to exhange the killed eventhandler bits with something else, not that the essence is crap ;)

PV + PVEH definitely ftw ;)

Share this post


Link to post
Share on other sites

The kill counter was from an old thread. Still, it was a working example. I hoped the focus would have been more on the essence of it.

Now it's replaced with a different example, feel free to rip it apart. ;)

Share this post


Link to post
Share on other sites

This is really helpfull guys...thanks a lot Shuko. Just got a fourth copy of Arma 2....two for me to test at home and two to give to my buddies to play online when I can figure the MP stuff out.... so this is great timing! Thanks again.

Share this post


Link to post
Share on other sites

Thanks shuko!

Would this approach work if I used it to create a function to 'addAction'/'removeAction' on dynamically created vehicles?

Edited by Wobbleyheadedbob

Share this post


Link to post
Share on other sites

Sweet, I started putting it together last night anyway. now just need to test with multiple clients.

I think I may need to add another eventHandler on the server-side to listen for events triggered by the clients.

Share this post


Link to post
Share on other sites

Thanks again Shuko, this has worked brilliantly. I've made Deployable MHQ's that players can "Sign-In" to and they will then be "Stationed" there meaning they will respawn there when killed. They can also pack them up again into a Mobile vehicle. Tested on the Dedi and Listen server and it's now JIP compatible.

Edited by Wobbleyheadedbob

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  

×