draoth 13 Posted August 31, 2017 Hello everybody, I'm working on a script that will change a player his side when he's shot by a certain person. And change the player that shot the other player back. So it will always be a 3v1 The player that is last shot will be called = Active. The eventhandler doesn't work as i hoped it would, because everyone gets changed sides when shot by anyone. I'm pretty certain that the mistake is in the first line, but i'll show it all: _HITIT = Player1 addMPEventHandler ["MPHit", {if (_this select 4 == Active) then { [Active] joinSilent (Friendlygroup); Active setObjectTexture [0, "#(rgb,8,8,3)color(0,0.1,0,1)"]}; Active = Player1; [Active] joinSilent (Enemygroup); Active setObjectTexture [0, "#(rgb,8,8,3)color(1,0,0,1)"]; }]; This is done for all 4 players. Thank you for helping someone who has almost no experience in coding howsoever! Draoth Share this post Link to post Share on other sites
pierremgi 4739 Posted August 31, 2017 I guess you have named player1, player2... your playable units in editor. But where active, friendlygroup, enemygroup, (variables) come from? 1 Share this post Link to post Share on other sites
draoth 13 Posted August 31, 2017 18 minutes ago, pierremgi said: I guess you have named player1, player2... your playable units in editor. But where active, friendlygroup, enemygroup, (variables) come from? They are set in different scripts: //First script Friendlygroup = createGroup west; Enemygroup = createGroup east; //ArrowSpin script that randomizes the first Active while {true} do { //player1 if (ArrowDir >180 && ArrowDir <235) then {ActiveP = Player1}; if (ArrowDir >135 && ArrowDir <180) then {ActiveP = Player1}; //player2 if (ArrowDir >45 && ArrowDir <90) then {ActiveP = Player2}; if (ArrowDir >90 && ArrowDir <45) then {ActiveP = Player2}; //player3 if (ArrowDir >0 && ArrowDir <45) then {ActiveP = Player3}; if (ArrowDir >315 && ArrowDir <360) then {ActiveP = Player3}; //player4 if (ArrowDir >270 && ArrowDir <315) then {ActiveP = Player4}; if (ArrowDir >235 && ArrowDir <275) then {ActiveP = Player4}; Pointer setPos [ getPos ActiveP select 0, getPos ActiveP select 1, 3]; if (Arrowspeed < 1) exitwith {}; sleep 0.1 } I hope you can understand it a little, I know it's messy but i did my best Share this post Link to post Share on other sites
pierremgi 4739 Posted August 31, 2017 Hum, No chance to do something with that. I don't understand your infinite loop. 1 Share this post Link to post Share on other sites
draoth 13 Posted August 31, 2017 18 minutes ago, pierremgi said: Hum, No chance to do something with that. I don't understand your infinite loop. I made an arrow spinning in 360 degrees. 4 players stand around it. The infinite loop checks at what degree the arrow stops. When it stops it will set a player ActiveP. The only part i need help with is this line. _HITIT = Player1 addMPEventHandler ["MPHit", {if (_this select 4 == ActiveP) then { ETC Is the eventhandler correct? i want to check if the one that shot Player one is the same as ActiveP. That's why i put select 4, which is the instigator. instigator: Object - Person who pulled the trigger https://community.bistudio.com/wiki/Arma_3:_Event_Handlers Share this post Link to post Share on other sites
pierremgi 4739 Posted August 31, 2017 No, instigator is select 3 but try something like this (SP/MP compatible) just one EH in init.sqf or a trigger for example: if (isServer) then { { _x addMPEventHandler ["MPHit", { [_this select 3] joinSilent (Friendlygroup); (_this select 3) setObjectTextureGlobal [0, "#(rgb,8,8,3)color(0,1,0,1)"]; ActiveP = _this select 0; [ActiveP] joinSilent (Enemygroup); ActiveP setObjectTextureGlobal [0, "#(rgb,8,8,3)color(1,0,0,1)"]; }]} forEach switchableUnits + playableUnits; }; 1 Share this post Link to post Share on other sites
draoth 13 Posted August 31, 2017 1 hour ago, pierremgi said: No, instigator is select 3 but try something like this (SP/MP compatible) just one EH in init.sqf or a trigger for example: if (isServer) then { { _x addMPEventHandler ["MPHit", { [_this select 3] joinSilent (Friendlygroup); (_this select 3) setObjectTextureGlobal [0, "#(rgb,8,8,3)color(0,1,0,1)"]; ActiveP = _this select 0; [ActiveP] joinSilent (Enemygroup); ActiveP setObjectTextureGlobal [0, "#(rgb,8,8,3)color(1,0,0,1)"]; }]} forEach switchableUnits + playableUnits; }; Thank you so much! People like you are the reason i keep scripting. Have a good day! Share this post Link to post Share on other sites