BEAKSBY 11 Posted May 27, 2014 How do I disguish the _x from WEST vs. EAST side? I tried to incorporate private but couldn't figure out how to place it in the script, thinking this would solve the problem. { if ((side player == WEST) && (side _x != side player)) then { _x addEventHandler ["Killed", {[100] execVM "BLUaddMoney.sqf";}]; }; if ((side player == EAST) && (side _x != side player)) then { _x addEventHandler ["Killed", {[100] execVM "OPPaddMoney.sqf";}]; }; } forEach allUnits; I noticed that in LAN the EAST side addEventHandler won't work because of the shared _x. Share this post Link to post Share on other sites
tpw 2315 Posted May 27, 2014 I'm no MP programmer, but for MP play wouldn't you be needing to use _x addMPEventHandler ["MPKilled", {[100] execVM "OPPaddMoney.sqf";}]; ? Share this post Link to post Share on other sites
KC Grimes 79 Posted May 27, 2014 I'm no MP programmer, but for MP play wouldn't you be needing to use _x addMPEventHandler ["MPKilled", {[100] execVM "OPPaddMoney.sqf";}]; ? Not necessarily. The MPKilled, MPHit, and MPRespawn types execute on all clients. Basically, its the normal version (Killed, Hit, etc) but with a BIS_fnc_MP inside it. Which you choose depends on your application, but you can accomplish the same thing with both. That said, it sounds like your issue has to do with where these lines are being executed. The way you have it setup, you need that full code to execute on every machine. If you use MPKilled, then only execute them on one machine, ie, server. Personally? I would do the following (provided you didn't provide much context). Execute the following on all clients. { private ["_execType"]; _sidePlayer = side player; _sideX = side _x; if (_sidePlayer != _sideX) then { switch (_sidePlayer) do { case WEST: { _execType = "BLUaddMoney.sqf"; }; case EAST: { _execType = "OPPaddMoney.sqf"; }; }; _x addEventHandler ["Killed", {[100] execVM _execType;}]; }; } forEach allUnits; That's using your current method. For JIP support, you'd need to create a function that broadcasts to the server that the unit is JIP which results in a BIS_fnc_MP to all machines that executes that EH for the new unit, which was passed along the broadcasts. Another option is to manage it all on the server via MPKilled. This may not work, however, depending on what exactly you're trying to do. I use the above method in my revive script, and it works wonders. Share this post Link to post Share on other sites
Tajin 349 Posted May 27, 2014 (edited) Why not add a "killed" eventHandler for all units and include the side-check in there? That way nothing can go wrong when a unit switches sides. Besides, "OPPaddMoney" and "BLUaddMoney" sound like something you could combine in one script, with a parameter. Now I'm not sure how exactly you want it to work, but I would probably do it like this: { _x addEventHandler ["Killed", { private ["_unit","_killer"]; _unit = _this select 0; _killer = _this select 1; if ( (_killer countEnemy [_unit]) > 0 ) then { [side _killer,100] execVM "addMoney.sqf"; }; }]; } forEach allUnits; That is, whenever a unit (not necessarily the player) kills a hostile unit, its' side gets 100 money. Edited May 27, 2014 by Tajin Share this post Link to post Share on other sites
BEAKSBY 11 Posted May 27, 2014 That is, whenever a unit (not necessarily the player) kills a hostile unit, its' side gets 100 money. This is exactly what I want, but then, what do I add in the "addMoney.sqf". Each side has there own account. I.e. Oppaddmoney.sqf _sum = _this select 0; OPPmoney = OPPmoney + _sum; hint format ["You have %1$", OPPmoney]; BLUaddmoney.sqf _sum = _this select 0; BLUmoney = BLUmoney + _sum; hint format ["You have %1$", BLUmoney]; I feel I'm getting closer! ---------- Post added at 12:32 ---------- Previous post was at 11:53 ---------- I created this for your script Tajin but... init.sqf { _x addEventHandler ["Killed", { private ["_unit","_killer"]; _unit = _this select 0; _killer = _this select 1; if ( (_killer countEnemy [_unit]) > 0 ) then { [side _killer,100] execVM "addMoney.sqf"; }; }]; } forEach allUnits; addMoney.sqf _side = _this select 0; _sum = _this select 1; If (_side == WEST) then {// for west units BLUmoney = BLUmoney + _sum; hint format ["You have %1$", BLUmoney]; }; If (_side == EAST) then {// for east units OPPmoney = OPPmoney + _sum; hint format ["You have %1$", OPPmoney]; }; My game slows down to a crawl, and OPPmoney is not being displayed or even registered when EAST kills a unit. Share this post Link to post Share on other sites
Tajin 349 Posted May 27, 2014 Not sure why it slows you down. But try this for your addMoney.sqf: _side = _this select 0; _sum = _this select 1; If (_side == WEST) then {// for west units if (isNil "BLUmoney") Then { BLUmoney = 0; }; BLUmoney = BLUmoney + _sum; hint format ["You have %1$", BLUmoney]; }; If (_side == EAST) then {// for east units if (isNil "OPPmoney") Then { OPPmoney = 0; } OPPmoney = OPPmoney + _sum; hint format ["You have %1$", OPPmoney]; }; Just making sure the variables exist before adding to them. Share this post Link to post Share on other sites
BEAKSBY 11 Posted May 27, 2014 I'll try that. I had in my init.sqf but forgot to add to my post the following: BLUmoney = 5000 OPPmoney = 1000 BUT, I suspect that hint message will still appear on the host's (local?) screen. I want the hint only to be displayed on the machine that earns the money (by killing the enemy). Share this post Link to post Share on other sites
BEAKSBY 11 Posted May 27, 2014 (edited) Hi Tajin, I tried this as addMoney.sqf I'll try that. I had in my init.sqf but forgot to add to my post the following: BLUmoney = 5000 OPPmoney = 1000 BUT, I suspect that hint message will still appear on the host's (local?) screen. I want the hint only to be displayed on the machine that earns the money (by killing the enemy). along with this in my init.sqf BLUmoney = 5000; OPPmoney = 1000; call compile preProcessFileLineNumbers "scripts\UIFunctions.sqf"; waitUntil {!isNull player}; //////////////////////////////////////////////////// { _x addEventHandler ["Killed", { private ["_unit","_killer"]; _unit = _this select 0; _killer = _this select 1; if ( (_killer countEnemy [_unit]) > 0 ) then { [side _killer,100] execVM "addMoney.sqf"; }; }]; } forEach allUnits; If (side player == WEST) then {// for west units player addAction ["Player identity", { hint format ["Player name is %1!", _this select 3] }, name player]; // {player addEventHandler ["Killed", {[100] execVM "BLUaddMoney.sqf";}]} forEach allUnits; // THIS DOES NOT WORK player addAction ["<t color='#00dd00'>Account Status </t>", "BLUaccount.sqf"]; // TESTING HINT MESSAGE ON EITHER PLAYER AND THIS WORKS } else {// change this for east units player addAction ["Player identity", { hint format ["Player name is %1", _this select 3] }, name player]; // {player addEventHandler ["Killed", {[100] execVM "OPPaddMoney.sqf";}]} forEach allUnits; // THIS DOES NOT WORK player addAction ["<t color='#00dd00'>Account Status </t>", "OPPaccount.sqf"]; // TESTING HINT MESSAGE ON EITHER PLAYER AND THIS WORKS }; _menu = player addAction ["<t color=""#3399FF"">" +"Weapons", {call FUS_fnc_dialogInit;}]; Still not working properly. It works fine as WEST but when I reload and play as EAST only the WEST side's team money is registered and displayed when they make a kill. This should not appear as the intent is that only the player's side that makes an enemy kill generates money which is diplayed on the killing side(s) screen only. ---------- Post added at 22:45 ---------- Previous post was at 21:28 ---------- I think this all has to do with addEventHandler effects of the given scripting command are not broadcasted over the network and remain local to the client the command is executed on. Check Locality in Multiplayer for more information about locality of objects. I'm not sure how to check which machine it is run on server or client then run the addEventHandler on the appropriate machine. SO how do I run addEventHandler effects on a specific machine, server or client? Starting a new thread. Edited May 27, 2014 by BEAKSBY Share this post Link to post Share on other sites