JacobJ 10 Posted March 18, 2011 Hey What command do you have to use, if I want to make a trigger that counts 20 mouse clicks on mouse button 1 (fire-button)? I guess I need the count command, but what to return the mouseclick from the fire-button? /Jacob ---------- Post added at 07:20 PM ---------- Previous post was at 05:49 PM ---------- Can I somehow use this: http://community.bistudio.com/wiki/User_Interface_Event_Handlers And for the actionkey use "Fire"? ---------- Post added at 07:37 PM ---------- Previous post was at 07:20 PM ---------- What about this? I just can't find the code for mousebutton 1 http://community.bistudio.com/wiki/displaySetEventHandler ---------- Post added at 08:38 PM ---------- Previous post was at 07:37 PM ---------- Okay this is what I got so far: starter.sqf: disableSerialization; keyspressed = compile preprocessFile "wirecutter.sqf"; _display = findDisplay 46; _display displaySetEventHandler ["KeyDown","_this call keyspressed"]; wirecutter.sqf: private['_handled']; _handled = false; switch (_this select 1) do { //H key case 35: { round_counter = 0; player addEventHandler ["keyDown", {round_counter = round_counter + 1; hint format ["%1", round_counter]}]; _handled = true; }; }; _handled; I can get a hint to work, but this doesnt work. I know it isnt the mousebutton, but if I just can get this to work I am one step longer. I need this script to compensate for the wirecutter not working in the current version of Arma2 AO. It works on fence that is preplaced in the maps, but not fence you put into a mission. My idea is, that if I make a trigger that starts when a unit comes into the triggerarea (which is just around that peace of fence you want it to work for) and in the conditions put currentWeapon "wirecutter". It then checks if the current weapon of the unit is the wirecutter. If it is it runs the script. In the script there is a If command and if the unit with the wirecutter pushes his primery mousebutton like 20 times the scripts sets: fence setdamage 1. Then the wirecutter would have to be the primary weapon, the unit must be in the triggerarea and he has to push the "fire" button 20 times to get the fence to lay down. ---------- Post added at 08:54 PM ---------- Previous post was at 08:38 PM ---------- Wouldnt I have to add this to the buttom of wirecutter.sqf to make it compare the number of keystrokes with 20 and then set the damage to 1? waitUntill {(round_counter = 20)}; fence setdamage 1; Share this post Link to post Share on other sites
demonized 20 Posted March 18, 2011 disableSerialization; keyspressed = compile preprocessFile "wirecutter.sqf"; _display = findDisplay 46; _display displaySetEventHandler ["KeyDown","_this call 'wirecutter.sfq'"]; waitUntill {(round_counter) == 20}; fence setdamage 1; Errors i spotted, corrected in red, take note that ive never worked with this command before. Also using not sure if 'wirecutter.sqf' is correct or "wirecutter.sqf" note the ' or " in the keydown line. Share this post Link to post Share on other sites
JacobJ 10 Posted March 18, 2011 How do I compare the output to the number of counts I would like to have for it to trigger/setdamage 1? Do you know how to make the key that has to be pressed to primary mouse button? I can't seem to find the correct "case"/key number for it. I am afraid that it is only working with inputs from the keyboard... Share this post Link to post Share on other sites
demonized 20 Posted March 18, 2011 scroll down in this and find onmouseclick or something. Lots of info on usage but same or similar as key i think by quick look, you need to read up on it. http://community.bistudio.com/wiki/User_Interface_Event_Handlers ---------- Post added at 10:54 PM ---------- Previous post was at 10:48 PM ---------- _control ctrlSetEventHandler ["MouseButtonClick ", "_this call 'wirecutter.sfq'"]; something like the above or maybe use MouseButtonDown instead, as i said, lots of info you need to read up on it there. Learning is half the fun, acomplishment is rest of it :) Share this post Link to post Share on other sites
JacobJ 10 Posted March 18, 2011 I have looked at that page 100 times now and I still don't get it where to put in onButtonClick and how to put in what button it should be attached to. I could do try the onMouseButtonClick, but that I still don't know how to put into the code that is in the example above. Can I just swap the KeyDown with onMouseButtonClick? That sounds a bit too easy. ---------- Post added at 10:59 PM ---------- Previous post was at 10:56 PM ---------- Okay I see, that looks like it is just swapping it. I will give that a try and see if I can get something to get triggered. Just a hint "Hey, the mousebuttonthing did what you wanted it to" would be nice to start with..hehe Share this post Link to post Share on other sites
JacobJ 10 Posted March 19, 2011 Okay, so far I have this and it works for running a script: disableSerialization; keyspressed = compile preprocessFile "wirecutter.sqf"; _display = findDisplay 46; _display displaySetEventHandler ["MouseButtonDown","_this call keyspressed"]; But as soon as I do anything else inside the last two "" it won't work. Maybe its my lag of knowledge about syntax, but I have seen others do it with success. If I want to change the "_this call keypressed" to a counterfunction that counts the number of times I press the key, how would I do that? I believe that I have to define a variable after the DisableSerialization; part like this: _numberOfCounts = 0 Then I would need some way to get it to count _numberOfCounts = _numberOfCounts + 1 And then maybe a If statement: (_numberOfCounts >= 20) and ("Ace_wirecutter" = currentWeapon player) then {fence setdamage 1}; But how to put it all together I am a little lost I must say. Does it look totally wrong? ---------- Post added at 11:49 AM ---------- Previous post was at 10:32 AM ---------- Okay now I have this and got the If command to work. But the counting part is still and issue. How to make a script count those mousebuttondown strokes..? Share this post Link to post Share on other sites