Alert23 215 Posted May 10, 2017 Hi all, im creating an mariokart mission and right now i stuck very badly at this issue and i hope some of u can lend me an helping hand =) both my scripts below are activated by trigger. so when script "keypressed.sqf" is activated it will give the player an random item from the array which he can use by pressing the "Q" Key. at the same time the other script "getobject.sqf" is activated showing an hint on the screen which item the player randomly got. now my problem is that the Hint showing up dosent match with what the player got from the item array. for example hint shows "PRESS Q TO BOOST" but pressing Q executes "Rocket" from the item array. how can i make it so that the randomly picked item from the array and the Hint match? keypressed.sqf: private['_handled']; _handled = false; switch (_this select 1) do { //Q key case 16: {item = selectRandom ["Boost","Jump","Rocket","Smoke","Shield","Block"]; switch (item) do { case "Boost": {null = [] execVM "itemBoost.sqf";}; case "Jump": {null = [] execVM "itemJump.sqf";}; case "Rocket": {null = [] execVM "itemRocket.sqf";}; case "Smoke": {null = [] execVM "itemSmoke.sqf";}; case "Shield": {null = [] execVM "itemShield.sqf";}; case "Block": {null = [] execVM "itemBlock.sqf";}; _handled = true; }; }; }; _handled; getObject.sqf: item = selectRandom ["Boost","Jump","Rocket","Smoke","Shield","Block"]; switch (item) do { case "Boost": {nul = ["PRESS Q TO BOOST"] spawn BIS_fnc_dynamicText;}; case "Jump": {nul = ["PRESS Q TO JUMP"] spawn BIS_fnc_dynamicText;}; case "Rocket": {nul = ["PRESS Q TO SHOOT ROCKET"] spawn BIS_fnc_dynamicText;}; case "Smoke": {nul = ["PRESS Q TO USE SMOKE"] spawn BIS_fnc_dynamicText;}; case "Shield": {nul = ["PRESS Q TO USE SHIELD"] spawn BIS_fnc_dynamicText;}; case "Block": {nul = ["PRESS Q TO DROP BLOCK"] spawn BIS_fnc_dynamicText;}; }; Share this post Link to post Share on other sites
beno_83au 1369 Posted May 10, 2017 They're both running their own selectRandom. Instead of running keyPressed as well as getObject, just combine the two: item = selectRandom ["Boost","Jump","Rocket","Smoke","Shield","Block"]; switch (item) do { case "Boost": { nul = [] execVM "itemBoost.sqf"; nul = ["PRESS Q TO BOOST"] spawn BIS_fnc_dynamicText; }; case "Jump": { nul = [] execVM "itemJump.sqf"; nul = ["PRESS Q TO JUMP"] spawn BIS_fnc_dynamicText; }; //plus the rest of them }; Try something like that. 1 Share this post Link to post Share on other sites
BroBeans. 279 Posted May 10, 2017 why dont you just add nul = ["PRESS Q TO BOOST"] spawn BIS_fnc_dynamicText; to itemboost.sqf? or optionally private['_handled']; _handled = false; switch (_this select 1) do { //Q key case 16: {item = selectRandom ["Boost","Jump","Rocket","Smoke","Shield","Block"]; switch (item) do { case "Boost": {null = [] execVM "itemBoost.sqf"; nul = ["PRESS Q TO BOOST"] spawn BIS_fnc_dynamicText;}; case "Jump": {null = [] execVM "itemJump.sqf";} nul = ["PRESS Q TO JUMP"] spawn BIS_fnc_dynamicText;; case "Rocket": {null = [] execVM "itemRocket.sqf"; nul = ["PRESS Q TO FIRE ROCKET"] spawn BIS_fnc_dynamicText;}; case "Smoke": {null = [] execVM "itemSmoke.sqf"; nul = ["PRESS Q TO SMOKE"] spawn BIS_fnc_dynamicText;}; case "Shield": {null = [] execVM "itemShield.sqf"; nul = ["PRESS Q TO SHIELD"] spawn BIS_fnc_dynamicText;}; case "Block": {null = [] execVM "itemBlock.sqf"; nul = ["PRESS Q TO BLOCK"] spawn BIS_fnc_dynamicText;}; _handled = true; Ignore this. @beno_83au beat me to it :D 1 Share this post Link to post Share on other sites
beno_83au 1369 Posted May 10, 2017 2 minutes ago, BroBeans. said: Ignore this. @beno_83au beat me to it :D I should like to think so, I paused a SupCom cast to answer this XD 3 Share this post Link to post Share on other sites
Alert23 215 Posted May 10, 2017 49 minutes ago, beno_83au said: They're both running their own selectRandom. Instead of running keyPressed as well as getObject, just combine the two: item = selectRandom ["Boost","Jump","Rocket","Smoke","Shield","Block"]; switch (item) do { case "Boost": { nul = [] execVM "itemBoost.sqf"; nul = ["PRESS Q TO BOOST"] spawn BIS_fnc_dynamicText; }; case "Jump": { nul = [] execVM "itemJump.sqf"; nul = ["PRESS Q TO JUMP"] spawn BIS_fnc_dynamicText; }; //plus the rest of them }; Try something like that. first of all thank you both for your reply, but i did that before and this is not how i want the script, this way the Hint will show up after u press Q which also executes the code at the same time. So that means the player who got the item dosent know which item he got until he uses it, but i want it so that when the player drives through the trigger a hint will show up saying what item the player got and then the player can use the item by pressing Q whenever he want. The Hint must show up saying to the player for example: "PRESS Q TO BOOST" and then whenever the player decides to use the item by pressing Q the code null = [] execVM "itemBoost.sqf"; must execute. maybe with setvariable getvariable but i dont know how. Share this post Link to post Share on other sites
beno_83au 1369 Posted May 10, 2017 Ok i get what you mean. You could select the item and then assign the result to a variable like this: _item = selectRandom _array; player setVariable ["RandomItem",_item]; Then in your script you can grab the code with: _switch = player getVariable "RandomItem"; switch (_switch) do { //cases and code }; Sorry, I'm on my phone now, formating is out the window. There's a couple of different ways to use set/getVariable so it's worth looking at them on the wiki. An alternative is you pick your random object in the same fashion, but then parse the local variable through into the scripts: nul = [_item] execVM script.sqf; If this is still throwing you a bit hopefully someone can post up something further. Posting from a phone can make things a bit difficult at times. 1 Share this post Link to post Share on other sites
Alert23 215 Posted May 10, 2017 36 minutes ago, beno_83au said: Ok i get what you mean. You could select the item and then assign the result to a variable like this: _item = selectRandom _array; player setVariable ["RandomItem",_item]; Then in your script you can grab the code with: _switch = player getVariable "RandomItem"; switch (_switch) do { //cases and code }; Sorry, I'm on my phone now, formating is out the window. There's a couple of different ways to use set/getVariable so it's worth looking at them on the wiki. An alternative is you pick your random object in the same fashion, but then parse the local variable through into the scripts: nul = [_item] execVM script.sqf; If this is still throwing you a bit hopefully someone can post up something further. Posting from a phone can make things a bit difficult at times. THANK U SO VERY MUCH FOR UR HELP I FINALLY GOT IT WORKING =))) 1 Share this post Link to post Share on other sites
Alert23 215 Posted May 11, 2017 works very well =) 1 Share this post Link to post Share on other sites
beno_83au 1369 Posted May 11, 2017 Haha, I like how you've gone outside the box to create something unique (within ArmA). Share this post Link to post Share on other sites
killzone_kid 1332 Posted May 11, 2017 why you dont use Karts borders? there are tonnes of them all different shapes and you can even animate them in shape you want. plus all other racing attributes Share this post Link to post Share on other sites
Alert23 215 Posted May 11, 2017 11 hours ago, killzone_kid said: why you dont use Karts borders? there are tonnes of them all different shapes and you can even animate them in shape you want. plus all other racing attributes yeah your right, just boughted today. however i have an question if u dont mind. i want a script to be executed when the player is at a certain distance to an object like this but i get an error: waitUntil {((vehicle player distance oilsplash) <= 0.5)};null = [vehicle player, 1, 1] execVM "HitRotate.sqf"; what im doing wrong? i know i could use a trigger but the problem is with trigger if i set an small size it wont work everytime some times it does nothing. Share this post Link to post Share on other sites
pierremgi 4906 Posted May 11, 2017 What kind of error? You're probably in unscheduled scope which doesn't support any suspension. Test with: 0 = [] spawn { waitUntil { sleep 0.5; (vehicle player distanceSqr oilsplash) <= 0.25}; [vehicle player, 1, 1] execVM "HitRotate.sqf" }; 1 Share this post Link to post Share on other sites
Alert23 215 Posted May 13, 2017 On Thursday, May 11, 2017 at 10:18 PM, pierremgi said: What kind of error? You're probably in unscheduled scope which doesn't support any suspension. Test with: 0 = [] spawn { waitUntil { sleep 0.5; (vehicle player distanceSqr oilsplash) <= 0.25}; [vehicle player, 1, 1] execVM "HitRotate.sqf" }; Thank you very much it did work perfectly. Is there a way to spawn an single lightning bolt on a player whic will not do any dammage meaning only for effect because i will add the dammage myself right now i got this but it does dammage. _target = _this select 0; _center = createCenter sideLogic; _group = createGroup _center; _logic = _group createUnit ["LOGIC",[0,0,0], [], 0, ""]; _logic setPosASL (getPosASL _target); [_logic, nil, true] call BIS_fnc_moduleLightning; Share this post Link to post Share on other sites
Alert23 215 Posted May 19, 2017 guys pls if u have any time help me out with this issue =) im still creating arma 3 mario kart mission and im stuck at a point. again.. I have some scripts which if executed by a random player should only effect the other players For example i have 8 cars named : car1,car2,car3 and so on... The script for example is: Enablesimulation false; Sleep 3; Enablesimulation true; Now if car3 executes this script it should effect all other cars execpt car3. I hope rly someone could help me with this i got this so far just copy pasting =) is it complete false or am i heading in the right direction ? cars = [car1,car2,car3,car4,car5,car6,car7,car8]; carsToStop = [car1,car2,car3,car4,car5,car6,car7,car8]; if (vehicle player == carsToStop) then { _x enablesimulation false; sleep 3; _x enablesimulation true; } forEach carsToStop; Share this post Link to post Share on other sites
pierremgi 4906 Posted May 19, 2017 https://community.bistudio.com/wiki/enableSimulationGlobal carsToStop = [car1,car2,car3,car8]; // to be defined somewhere ( but should evolves during game with a script ! ) (vehicle player) spawn { waitUnitil {sleep 0.5; _this in carsToStop}; _this enablesimulationGlobal false; sleep 3; _this enablesimulationGlobal true; waitUnitil {sleep 0.5; !(_this in carsToStop)}; }; Share this post Link to post Share on other sites
Alert23 215 Posted May 21, 2017 Thanks for your help. Track will change. 1 Share this post Link to post Share on other sites
Alert23 215 Posted May 26, 2017 Hi guys, still need some help with scripting =) i have this script which i want to add into the mission. i want the "Space" key to execute a script only once when its pressed, right now if i press it and hold it down the script will be executed a million times but it should only execute once even if hold down. init.sqf: keypressed = compile preprocessFile "keypressed.sqf"; disableSerialization; _display = findDisplay 46; _display displayAddEventHandler ["KeyDown","_this call keypressed"]; keypressed.sqf: private['_handled']; _handled = false; switch (_this select 1) do { //Space key case 57: { vehicle player setvelocity [10 * (sin (getdir vehicle player)), 10 * (cos (getdir vehicle player )), 4]; _handled = true; }; }; _handled; Share this post Link to post Share on other sites
crewt 31 Posted May 26, 2017 Strange should work this way. You could add something like a global variable, to limit execution only if space key was lifted afterwards. Add an other eventhandler for keyUp which set a variable to true, and modify your code to only execute if the particular variable is true. Share this post Link to post Share on other sites
Alert23 215 Posted May 26, 2017 thanks for the reply but i cant get it work that way. Share this post Link to post Share on other sites
Alert23 215 Posted May 26, 2017 can anyone help pls? Share this post Link to post Share on other sites
crewt 31 Posted May 26, 2017 NoHow did you do it? Keydown: Spoiler private['_handled']; _handled = false; If (!isNil "keydownallowed" ) then {keydownallowed =true;}; If(keydownallowed) then{ switch (_this select 1) do { //Space key case 57: { vehicle player setvelocity [10 * (sin (getdir vehicle player)), 10 * (cos (getdir vehicle player )), 4]; _handled = true; }; }; }; _handled keyUp Spoiler Keydownallowed =true; Share this post Link to post Share on other sites