blasko 0 Posted March 24, 2007 Hello all, I have a problem with a random positions script in a MP map. At the beginning of the mission, I want a ammo crate named "ammo"to be randomly located on the map in one of these 5 positions "pos1", "pos2", "pos3", "pos4" and "pos5". Here is my alea.sqs script text : Quote[/b] ]_x = _this select 0_aleatoire = random 25 if(_aleatoire < 5) then {_x setpos getpos pos1;lieua=true;publicVariable"lieua";goto "end"} if(_aleatoire > 4 AND _aleatoire<10) then {_x setpos getpos pos2;lieub=true;publicVariable"lieub";goto "end"} if(_aleatoire > 9 AND _aleatoire<15) then {_x setpos getpos pos3;lieuc=true;publicVariable"lieuc";goto "end"} if(_aleatoire > 14 AND _aleatoire<20) then {_x setpos getpos pos4;lieud=true;publicVariable"lieud";goto "end"} if(_aleatoire > 19 AND _aleatoire<26) then {_x setpos getpos pos5;lieue=true;publicVariable"lieue";goto "end"} #end exit And when I write in init.sqs : Quote[/b] ][ammo] exec"alea.sqs" The ammo crate successfully goes in one of the 5 positions in the map for me only : but when I played the MP with a friend, he forever sees the crate at the same position, this position is where I placed the ammo crate in the map when I was editing, so I conclude that the ammo crate didn't launch the script text in my friend's computer because it is not in one of the 5 positions that it has to be. My friend can watch the ammo crate whereas I can't see it and I see the ammo crate in one of the 5 positions and not my friend ! I hope you understood my problem and if you have got a solution to this matter it would be very appreciated Best regards. Blasko. Share this post Link to post Share on other sites
fasad 1 Posted March 24, 2007 The problem is one of locality rather than the random command. Locality can get very confusing very quickly, as some commands require local arguments and some commands will only have a local effect. Do you have a script running on the client to setPos the ammo crates to the appropriate location? Share this post Link to post Share on other sites
celery 8 Posted March 24, 2007 Sorry to say, but placing a static object such as an ammo crate is not possible whatever you do because ArmA still has the bug of not transmitting setPos of static objects to other players than the host. It's not the fault of your scripts. Share this post Link to post Share on other sites
fasad 1 Posted March 24, 2007 Quote[/b] ]...placing a static object such as an ammo crate is not possible whatever you do... Surely you just execute code to setPos the object on each client!? Share this post Link to post Share on other sites
blasko 0 Posted March 24, 2007 Thank you for the answers, I think I will place a static ammo crate then If the solution fasad suggests works, it would be great Share this post Link to post Share on other sites
celery 8 Posted March 24, 2007 Quote[/b] ]...placing a static object such as an ammo crate is not possible whatever you do... Surely you just execute code to setPos the object on each client!? Wanna try that for yourself before you believe? Share this post Link to post Share on other sites
Blanco 0 Posted March 24, 2007 Why do you need a script anyway? Create your ammobox & 5 empty markers Group (F2) each marker with the ammobox and you're done. The ammobox will appear randomly on one the markerpositions. Simple as that. Should work in SP & MP Same goes for troops btw, group the leader of the group with each marker and the whole group will randomly appear on one of these markerpositions. http://www.flashpoint1985.com/cgi-bin....t=59915 Share this post Link to post Share on other sites
Maddmatt 1 Posted March 24, 2007 Why do you need a script anyway?Create your ammobox & 5 empty markers Group (F2) each marker with the ammobox and you're done. The ammobox will appear randomly on one the markerpositions. Simple as that. Should work in SP & MP Same goes for troops btw, group the leader of the group with each marker and the whole group will randomly appear on one of these markerpositions. http://www.flashpoint1985.com/cgi-bin....t=59915 Hey I never knew that. Thanks, it could be useful to me. Share this post Link to post Share on other sites
F2kSel 0 Posted March 24, 2007 Thats something I didn't know either, I also noticed you can group several objects to the same markers and as long as you spread them using the placement option you can really random things up. Share this post Link to post Share on other sites
fasad 1 Posted March 25, 2007 Wow, that is a neat trick! The object will also randomly appear at it's mission editor location. Share this post Link to post Share on other sites
Teufelsklaue 0 Posted March 25, 2007 Create your ammobox & 5 empty markers Group (F2) each marker with the ammobox and you're done. The ammobox will appear randomly on one the markerpositions. Simple as that. Should work in SP & MP This is good working feature for troops in SP and MP For ammo-crates this is just working in Sp, and not in MP! I already tested it Share this post Link to post Share on other sites
shuko 59 Posted March 25, 2007 This is good working feature for troops in SP and MPFor ammo-crates this is just working in Sp, and not in MP! I already tested it Probably same thing as with any other static/building type of object. Cant setpos etc them in MP. Share this post Link to post Share on other sites
F2kSel 0 Posted March 25, 2007 Why not just use the probability of presence option when you place them on the map. Share this post Link to post Share on other sites
fasad 1 Posted March 25, 2007 Could you first choose the location, then create the ammo box? The can't move static thing is weird. Did the same problem exist in OFP? Share this post Link to post Share on other sites
Rune 0 Posted March 25, 2007 For a scriptbased solution like the original one, though: If Celery is correct that this is only about not transmitting the new position after a 'setPos' in multiplayer, then all you have to do is randomize the number on the server and publicVariable it to clients before working out which position has been selected. For instance like below in your init.sqs(disclaimer: untested code and requires logic on map with name "Server"). <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">... MyTag_aleatiore = -1 if (local Server) then {MyTag_aleatoire = random 25; publicVariable MyTag_aleatoire;} @(MyTag_alaetiore != -1) if(MyTag_aleatoire < 5) then {_x setpos getpos pos1;} if(MyTag_aleatoire < 10) then {_x setpos getpos pos2;} if(MyTag_aleatoire < 15) then {_x setpos getpos pos3;} if(MyTag_aleatoire < 20) then {_x setpos getpos pos4;} if(MyTag_aleatoire < 26) then {_x setpos getpos pos5:} lieue=true publicVariable"lieue" ... Share this post Link to post Share on other sites
celery 8 Posted March 25, 2007 setPos doesn't work for clients, no matter how local you make it. There's a bug report of it: http://bugs.armed-assault.net/view.php?id=2166 Share this post Link to post Share on other sites
Rune 0 Posted March 25, 2007 ArmA still has the bug of not transmitting setPos of static objects to other players than the host. You were somewhat unclear then I took what you said about 'transmitting' to mean that running setPos on one machine would not update the others. Not that it would do nothing locally. The scripting I suggested was to work around the bug I understood it to be...sorry to hear that it is an even worse bug than that Share this post Link to post Share on other sites