Bnae 1431 Posted January 2, 2016 Hi! I'm trying to make my scripts work on my COOP mission but nothing is working. Not even these simple things. I tried to find some tutorials but didn't help. this is just example killCount = 0; updateCount = { killCount = killCount +1; if(killCount == 1) then { hint "Working";_nul = [] execVM "script.sqf" }; }; enemyKilled = { _enemy = _this select 0; _unit = _this select 1; if(_unit == player) then { call updateCount; }; }; { if(side _x == EAST) then { _x addEventHandler ["killed", { _this call enemyKilled } ]; }; } foreach allUnits; }; script.sqf removeallweapons this; Need to make this work on every player on MP mission Share this post Link to post Share on other sites
whiztler 137 Posted January 2, 2016 I am not exactly getting what you want to do. Please post exactly how your triggers are configured (condition, on activation, etc) + scripts. Used the <> (Code) button to post your scripts. To check a variable equals something, use: variable == something; or variable isEqualto something; Share this post Link to post Share on other sites
Bnae 1431 Posted January 2, 2016 I am not exactly getting what you want to do. Please post exactly how your triggers are configured (condition, on activation, etc) + scripts. Used the <> (Code) button to post your scripts. To check a variable equals something, use: variable == something; or variable isEqualto something; Share this post Link to post Share on other sites
Bnae 1431 Posted January 3, 2016 I updated the whole topic to make it clearer. Share this post Link to post Share on other sites
killzone_kid 1329 Posted January 3, 2016 you have extra }; at the end. This should throw error and you should see it if you enable error showing, which of course you already did, right? Share this post Link to post Share on other sites
Bnae 1431 Posted January 3, 2016 you have extra }; at the end. This should throw error and you should see it if you enable error showing, which of course you already did, right? Good that you noticed but the script is working perfectly. Problem is that it's only working in SP. I don't know what i'm supposed to add or change to make it work in every PC that is playing my MP mission. Share this post Link to post Share on other sites
killzone_kid 1329 Posted January 3, 2016 use mp event handler maybe Share this post Link to post Share on other sites
whiztler 137 Posted January 3, 2016 Like KK said, use the "killed" eventhandler or the "MPkilled" eventhandler. E.g.: player addEventHandler [ "Killed", { hint format ["%1 was killed by %2",name (_this select 0),name (_this select 1)]; }; ]; Share this post Link to post Share on other sites
Bnae 1431 Posted January 3, 2016 Like KK said, use the "killed" eventhandler or the "MPkilled" eventhandler. E.g.: player addEventHandler [ "Killed", { hint format ["%1 was killed by %2",name (_this select 0),name (_this select 1)]; }; ]; I'm confuced. The problem is that when i'm playing my mission with a friend i'm the only one who can trigger that script. Is it because of if(_unit == player) then { call updateCount; }; Or do i have to add something like if (!isServer) exitWith {}; I'm very new to these MP scipts and i cannot find the right solution. In my mission that counter is for killing AI, not other players. Share this post Link to post Share on other sites
killzone_kid 1329 Posted January 3, 2016 Good that you noticed but the script is working perfectly. I don't know why you chose to lie when asking for help, but I just copy pasted your script into editor and got this: 16:04:54 Error in expression <lled } ]; }; } foreach allUnits; };>16:04:54 Error position: <};> 16:04:54 Error Missing { 16:04:54 Error in expression <lled } ]; }; } foreach allUnits; };> 16:04:54 Error position: <};> 16:04:54 Error Missing { Share this post Link to post Share on other sites
Bnae 1431 Posted January 3, 2016 I don't know why you chose to lie when asking for help, but I just copy pasted your script into editor and got this: Well for me it's working perfectly fine? I'm using it as a script that i run from init.sqf [] execVM "counter.sqf" counter.sqf killCount = 0; updateCount = { killCount = killCount +1; if(killCount == 1) then { hint "Working";_nul = [] execVM "script.sqf" }; }; enemyKilled = { _enemy = _this select 0; _unit = _this select 1; if(_unit == player) then { call updateCount; }; }; { if(side _x == EAST) then { _x addEventHandler ["killed", { _this call enemyKilled } ]; }; } foreach allUnits; }; I might be noob at scripting but i'm not a liar. And like i said "Good that you noticed". Meaning that there should not be }; at the end. But it's still working without any problems. The problem isin't that the script is not running. The problem is that the script is completely wrong in some other way that i cannot figure out. Share this post Link to post Share on other sites
killzone_kid 1329 Posted January 3, 2016 It doesn't work even when using suggested setup, must be magic then 1 Share this post Link to post Share on other sites
whiztler 137 Posted January 3, 2016 It's brackets day! Share this post Link to post Share on other sites
davidoss 552 Posted January 4, 2016 Anyway is there are some smart method to learn how event handlers works? I still can not figure it out. I have read the armaWiki about, make 100 of test no luck. Share this post Link to post Share on other sites
R3vo 2654 Posted January 4, 2016 Anyway is there are some smart method to learn how event handlers works? I still can not figure it out. I have read the armaWiki about, make 100 of test no luck. Read the wiki, search KK's blog etc. Share this post Link to post Share on other sites
Bnae 1431 Posted January 4, 2016 Read the wiki, search KK's blog etc. Yeah thats probably the best way to learn. I was personally just asking help for this one script. If i try to figure it out by myself i'll probably lose my interest on this mission. I'm still reading the blog and wiki all the time Share this post Link to post Share on other sites
whiztler 137 Posted January 4, 2016 @Bnae, we all learned how to script at some point, asked questions, etc. You learn by trying, reading, looking at how other people solved problems, etc. You start with learning how to debug your mission. Enable -showScriptErrors as a Arma 3 start-up param and learn/understand how to read the RPT. That will give you enough information to look up errors on the Biki, Google or ask them here. Debugging on biki: https://community.bistudio.com/wiki/Debugging_Techniques Debug tut: https://forums.bistudio.com/topic/172834-tutorial-debugging-server-issues-eg-not-loading-correctly/ Share this post Link to post Share on other sites
davidoss 552 Posted January 4, 2016 Read the wiki, search KK's blog etc. Well the problem is ... i already did that. Multiple times.. Share this post Link to post Share on other sites
Bnae 1431 Posted January 4, 2016 @Bnae, we all learned how to script at some point, asked questions, etc. You learn by trying, reading, looking at how other people solved problems, etc. You start with learning how to debug your mission. Enable -showScriptErrors as a Arma 3 start-up param and learn/understand how to read the RPT. That will give you enough information to look up errors on the Biki, Google or ask them here. Debugging on biki: https://community.bistudio.com/wiki/Debugging_Techniques Debug tut: https://forums.bistudio.com/topic/172834-tutorial-debugging-server-issues-eg-not-loading-correctly/ Yeah that is true. I'll try to figure this out. Share this post Link to post Share on other sites
donelsarjo 60 Posted January 4, 2016 Unfortunately I can't test your script atm. Tomorrow I will, if it is still unsolved. But the things that came to my mind are following: You should first of all loose the last bracket. The hint is useless if run on server, because it will (if even) only show up on the server not the client. In your "script.sqf" , "this" is not defined. You should pass the unit to the function. You should definitly run your example script in the init, but just for the server. This will cause, that there will be only one killcount variable and not one for each client. As soon as an enemy is killed the EH will fire and add +1 to killcount and if you pass the killed unit to updatecount and the exec of "script.sqf" it will remove all weapons. If you run everything on server side only you can get the killcount declaring it a public variable, so it is also JIP compatible. This is only usefull if you want to handle the variable on clientside. Hope it helped. Share this post Link to post Share on other sites
Bnae 1431 Posted January 4, 2016 Unfortunately I can't test your script atm. Tomorrow I will, if it is still unsolved. But the things that came to my mind are following: You should first of all loose the last bracket. The hint is useless if run on server, because it will (if even) only show up on the server not the client. In your "script.sqf" , "this" is not defined. You should pass the unit to the function. You should definitly run your example script in the init, but just for the server. This will cause, that there will be only one killcount variable and not one for each client. As soon as an enemy is killed the EH will fire and add +1 to killcount and if you pass the killed unit to updatecount and the exec of "script.sqf" it will remove all weapons. If you run everything on server side only you can get the killcount declaring it a public variable, so it is also JIP compatible. This is only usefull if you want to handle the variable on clientside. Hope it helped. This was very helpful! Instead of using script.sqf i decided to move the contents to if(killCount == 1) then { removeAllWeapons _unit }; Now i'm going to check all the other things Share this post Link to post Share on other sites
donelsarjo 60 Posted January 4, 2016 If it does not work write me and I will have a look at it. Hf Share this post Link to post Share on other sites
donelsarjo 60 Posted January 4, 2016 Your if statement will only remove the first kill's weapon! Use (killcount > 0) Share this post Link to post Share on other sites
Bnae 1431 Posted January 4, 2016 Your if statement will only remove the first kill's weapon! Use (killcount > 0) It's example of a more complicated script. Actual script is going to be (killCount == 10) but for testing reason it's better to run with 1 kill. Share this post Link to post Share on other sites
Bnae 1431 Posted January 4, 2016 And yeah, let me explain it little bit better. The idea (in example) is to remove the weapon after you kill one enemy. Problem is that it's only working for me as host. It's supposed to remove only my weapon when i kill and if my friend kills his weapon removes. Not everyones weapon when someone kills. I even tried to change the (_unit == player) to (_unit==playername). It worked in my screen but in my friends screen he still had his gun. So somehow i need to run the script in everyones PC since it has (_unit == player). if (isDedicated) then { //run on dedicated server only }; if (isServer) then { //run on dedicated server or player host }; if (hasInterface) then { //run on all player clients incl. player host }; if (!isDedicated) then { //run on all player clients incl. player host and headless clients }; if (!isServer) then { //run on all player clients incl. headless clients but not player host }; if (!hasInterface) then { //run on headless clients and dedicated server }; if (!hasInterface && !isDedicated) then { //run on headless clients only }; I'll bet it's some of these and i'm trying to figure out how these works. Share this post Link to post Share on other sites