odyseus 19 Posted July 19, 2012 (edited) Ok guys. So here is what i m trying to do. I have a "player 1" and an "empty flag pole" placed on the map. I want to addAction to this flag pole so that player one is the only one that can place a flag on it. But i want the flag to go up slowly. Ones the flag is up an something would happens it would trigger an action. Any ideas??? Edited July 19, 2012 by Odyseus Share this post Link to post Share on other sites
f2k sel 145 Posted July 19, 2012 place your pole and name and place the addaction in the init box this addaction ["Raise the Flag","fly_the_flag.sqf"]; save script as "fly_the_flag.sqf" // this addaction ["Raise the Flag","fly_the_flag"]; _flagE = _this select 0; _unit = _this select 1; _flagS = ""; _flagE removeAction (_this select 2); switch (side _unit) do { case EAST : {_flagS = "flagcarrierRU"}; case WEST : {_flagS = "flagcarrierUSA"}; case RESISTANCE : {_flagS = "flagcarrierGUE"}; };// end switch _unit action ["TakeFlag", _flagE]; _flagup = createvehicle [_flagS,[getpos _flagE select 0,getpos _flagE select 1,-12],[],0,"NONE"]; _flagup setdir getdir _flagE; _height =-20; while { (getpos _flagE select 2) > (getpos _flagup select 2)} do { _flagup setpos [ getpos _flagE select 0, getpos _flagE select 1,_height]; _height =_height+0.2; sleep 0.01 }; Share this post Link to post Share on other sites
odyseus 19 Posted July 19, 2012 (edited) Thank you so much. It worked just fine. Now one more question. I need a action ones the flag is up. like a sound activated by trigger. Any ideas? ---------- Post added at 10:41 PM ---------- Previous post was at 10:40 PM ---------- like for example if in case resistance : {_flags = "FlagCarrierTakistanKingdom_EP1"} is up a sound play. Another thing could i replace resistance by the player name? for example "player1" Edited July 19, 2012 by Odyseus Share this post Link to post Share on other sites
f2k sel 145 Posted July 19, 2012 (edited) Not really sure I really understand as _unit is player, I take it it's MP. I have no experience of MP coding. You could try switch (_unit) do { case player1 : {_flagS = "flagcarrierRU"}; case player2 : {_flagS = "flagcarrierUSA"}; case player3 : {_flagS = "flagcarrierGUE"}; };// end switch as for sound it depends on what sound, if it's a sound in a trigger then you just need to setup some variable and pass that to the trigger. example replace cond this with soundfx and then select the sound you want to play. and in the script you need to set soundfx to true case player3 : {_flagS = "flagcarrierGUE";soundFX=true}; If you want a custom sound then you will have to do a bit of work. You need a description file, if it's a sound then the first class CfgSounds would be used and for music you would use class CfgMusic section. Sound are usually placed in sub folder sound or music. class CfgSounds { // List of sounds (.ogg files without the .ogg extension) sounds[] = {barrel1}; // Definition for each sound class barrel1 { name = "barrel1"; // Name for mission editor sound[] = {\sound\barrel1.ogg, db -6, 1.0}; titles[] = {0, ""}; }; }; //////////////////////////// class CfgMusic { tracks[]={switch}; class switch { name = "switch"; sound[] = {"\music\switch.ogg", 1.0, 1.0}; }; }; to get it to play playmusic ["switch",0]; or playsound "barrel1" or even say say3D ["barrel1",2]; example case player3 : {_flagS = "flagcarrierGUE";playmusic ["switch",0];}; Having said that for MP there's a little more to do the best I can do it point you to this thread. http://forums.bistudio.com/showthread.php?136476-vehicle-player-say3d-quot-sound-quot-not-global&p=2179704&viewfull=1#post2179704 I just noticed when I paste the description file it's removing some forward slashes for some reason. this is how the line should read sound[] = {\sound\barrel1.ogg, db -6, 1.0}; Edited July 19, 2012 by F2k Sel Share this post Link to post Share on other sites
odyseus 19 Posted July 19, 2012 (edited) OWWW thx. It seems really complex. I will try. So if i have a trigger on the map, and i want its condition to be something like "waitUntill script "fly_the_flag.sqf" is done. How should i go about doing it? Could i use this on the condition field of the trigger? And how do i do it?? I mean what should i replace with what ? script_handler = [parameters] execVM "scriptname.sqf"; waitUntil {scriptDone script_handler}; Or something like when script is true than trigger is true. Edited July 20, 2012 by Odyseus Share this post Link to post Share on other sites
f2k sel 145 Posted July 20, 2012 You don't need script done, just setup a variable in the script and set it to true. last line of script could be done_it = true; and in trigger cond done_it Share this post Link to post Share on other sites
odyseus 19 Posted July 20, 2012 Thank you F2k Sel my friend. I would kiss you if i could! ;D LOL ---------- Post added at 04:15 AM ---------- Previous post was at 02:40 AM ---------- Thank you F2k Sel my friend. I would kiss you if i could! ;D LOL Hey F2k Sel. What happens if i have more than one flag? When i set action on one all of them setoff. Do you know why? Share this post Link to post Share on other sites
f2k sel 145 Posted July 20, 2012 (edited) If your talking about the triggers going off then one way would be to just name the flags flag1 ect and instead of the variable in the script done_it = true; use _flagE setvariable ["Flag",true,true]; and in the trigger flag1 getvariable "Flag" You will need a trigger for each pole using the name of the flag associated with it. Another way would be to spawn the trigger from the script but I don't have the time right now. Edited July 20, 2012 by F2k Sel Share this post Link to post Share on other sites
kylania 546 Posted July 20, 2012 Also remember that addAction and sounds are all local per client in Multiplayer. So you'd have to play the sound on each client for everyone to hear it and remove the action on every client to avoid some people seeing it and others not. If you're able to, using CBA helps a lot with that kind of global multiplayer scripting. Share this post Link to post Share on other sites
odyseus 19 Posted July 21, 2012 Thank you F2k Sel. Sorry what is CBA? Share this post Link to post Share on other sites
tom3kb 13 Posted July 21, 2012 CBA = Community Base Addons, you can download this addon from Armaholic or from many other sites with stuff for Arma 2. Share this post Link to post Share on other sites
odyseus 19 Posted July 21, 2012 Thank you. I m using some! any advice??? ---------- Post added at 10:33 AM ---------- Previous post was at 10:29 AM ---------- Hey F2k one more question. Can I set a trigger to stop the action if player leaves a specific area before flag is fully up? How would go about doing that? Share this post Link to post Share on other sites
f2k sel 145 Posted July 21, 2012 (edited) I've added a distance and alive check when raising the flag. It lowers it when you move away if it wasn't full raised. I've also added a lower the flag, second file. That way flags can be changed. I can't test MP so I don't know about how addaction will function. save as "fly_the_flag.sqf" // this addaction ["Raise Flag","scripts\flags\fly_the_flag.sqf",[],1,false,true,""," _this distance _target < 5"]; _flagE = _this select 0; _unit = _this select 1; _flagS = ""; _height = 0; _flagE removeAction (_this select 2); switch (side _unit) do { case EAST : {_flagS = "flagcarrierRU"}; case WEST : {_flagS = "flagcarrierUSA"}; case RESISTANCE : {_flagS = "flagcarrierGUE"}; };// end switch _unit action ["TakeFlag", _flagE]; _flagUP = createvehicle [_flagS,[getpos _flagE select 0,getpos _flagE select 1,-12],[],0,"NONE"]; _flagUP setdir getdir _flagE; _height =-7; while { (getpos _flagE select 2) > (getpos _flagUP select 2) and alive _unit and _unit distance _flagE < 5} do { _flagup setpos [ getpos _flagE select 0, getpos _flagE select 1,_height]; _height =_height+0.015; sleep 0.01; }; if ((getpos _flagE select 2) > (getpos _flagUP select 2)) then { _height = getpos _flagUP select 2; while {(getpos _flagUP select 2) > -7 } do { _flagUP setpos [ getpos _flagE select 0, getpos _flagE select 1,_height]; _height =_height-0.015; sleep 0.01; }; hint format ["%1",_flagE]; _flagE addaction ["Raise Flag","scripts\flags\fly_the_flag.sqf",[],1,false,true,""," _this distance _target < 5"]; _flagUP setvariable ["FlagName",nil,true]; sleep 1; hint format ["%1",""]; deletevehicle _flagUP; } else { _flagUP addaction ["Lower Flag","scripts\flags\lower_the_flag.sqf",[],1,false,true,""," _this distance _target < 5"]; _flagE setvariable ["Flag",true,true]; _flagUP setvariable ["FlagName",_flagE,true]; }; save as "Lower_the_flag.sqf" _height = 0; _flagUP = _this select 0; _unit = _this select 1; _flagUP removeAction (_this select 2); _flagE = _flagUP getvariable "flagname"; _height = getpos _flagUP select 2; _unit action ["TakeFlag", _flagE]; while {(getpos _flagUP select 2) > -7 } do { _flagUP setpos [ getpos _flagE select 0, getpos _flagE select 1,_height]; _height =_height-0.015; sleep 0.01; }; _flagE addaction ["Raise Flag","scripts\flags\fly_the_flag.sqf",[],1,false,true,""," _this distance _target < 5"]; _flagE setvariable ["Flag",false,true]; _flagUP setvariable ["FlagName",nil,true]; deletevehicle _flagUP; I haven't added a distance or not alive check when lowering the flag. Edited July 22, 2012 by F2k Sel Share this post Link to post Share on other sites
odyseus 19 Posted July 21, 2012 hey brother. Again thank you so much. I m trying to decrease the distance from the unit and the flag. i believe hat is the line on your code _unit distance _flagE < 8 but every time i change the number 8 to any smaller number it does work . Do you know why is that? ---------- Post added at 06:20 PM ---------- Previous post was at 05:34 PM ---------- hey brother. Again thank you so much. I m trying to decrease the distance from the unit and the flag. i believe hat is the line on your code _unit distance _flagE < 8 but every time i change the number 8 to any smaller number it does work . Do you know why is that? Another thing. I was not able to make the lower flag work. So i got your code to lower the flag. _height = 0; _flagUP removeAction (_this select 2); _flagE = _flagUP getvariable "flagname"; _height = getpos _flagUP select 2; while {(getpos _flagUP select 2) > -7 } do { _flagUP setpos [ getpos _flagE select 0, getpos _flagE select 1,_height]; _height =_height-0.015; sleep 0.01; }; _flagE addaction ["Raise Flag","fly_the_flag1.sqf"]; _flagE setvariable ["Flag",false,true]; _flagUP setvariable ["FlagName",nil,true]; deletevehicle _flagUP; copy and past on a notepad file. saved in to the game file. named it lower_the_flag.sqf put this on the trigger line flag2 addaction ["Raise the Flag","raise_the_flag.sqf"] ; flag2 addaction ["Lower the Flag","lower_the_flag.sqf"] ; I m getting a error msg lower_the_flag.sqf is missing or something like that! Any ideasAny ideas? Share this post Link to post Share on other sites
f2k sel 145 Posted July 21, 2012 Yea I stuffed up. I've corrected the above posts and removed a bug. I've also put them in their own sub folder, you will need to make one. make a folder inside the mission folder named scripts then a second inside that named flags and put the files inside that one. Use the new addaction this addaction ["Raise Flag","scripts\flags\fly_the_flag.sqf",[],1,false,true,""," _this distance _target < 5"]; placed in the flag init. I've reduced the range at which you can raise and lower the flag to 5 as well. You can't go any less as addaction won't show. You don't need to add another action to lower the flag the script will do it for you. Share this post Link to post Share on other sites
odyseus 19 Posted July 22, 2012 Yea I stuffed up. I've corrected the above posts and removed a bug.I've also put them in their own sub folder, you will need to make one. make a folder inside the mission folder named scripts then a second inside that named flags and put the files inside that one. Use the new addaction this addaction ["Raise Flag","scripts\flags\fly_the_flag.sqf",[],1,false,true,""," _this distance _target < 5"]; placed in the flag init. I've reduced the range at which you can raise and lower the flag to 5 as well. You can't go any less as addaction won't show. You don't need to add another action to lower the flag the script will do it for you. Ok let me see if i understood. I have done all you asked. made a folder inside the mission folder named scripts then a second inside that named flags and i put 2 new files inside you posted. raise_the_flag.sqf and lower_the_flag.sqf . Here is where i m confused. this addaction ["Raise Flag","scripts\flags\fly_the_flag.sqf",[],1,false,true,""," _this distance _target < 5"]; placed in the flag init. there is no fly_the_flag.sqf right?? what should i replace it for?? Share this post Link to post Share on other sites