meatball 25 Posted November 18, 2013 I've done something similar in previous missions using scripts that randomize starting locations, but I'm wondering if anyone knows a simple way that I can let the players choose (through parameters) one of multiple starting locations and then respawn at that location going forward. Share this post Link to post Share on other sites
KevsNoTrev 44 Posted November 18, 2013 I would suggest putting a simple named marker on the map - in example below - 0,1,2,3 etc. for all your starting locations. Then in description.ext set up a param in the paramsarray to pick the starting location. Then move the respawn marker to that known starting location using setmarkerposlocal - this needs to be done for all units at start and JIP to make sure they are in the correct place. In description.ext class Params { class StartLocation { title="Starting Location:"; values[]={0,1,2,3}; texts[]={"Frini","Sofia","Stavros","Airbase"}; }; }; Init.sqf _startingLocation = paramsarray select 0; //number needs to be adjusted if there are other params in the file. "respawn_west" setmarkerposlocal getmarkerpos (str _startingLocation); It will need markers named as the 'values' above. untested but should work. Share this post Link to post Share on other sites
meatball 25 Posted November 18, 2013 That's part of it. That definitely moves the respawn location. I just my primary issue at this point is how do I force the units to move from their original starting location on the map to the chosen start location at the start of the game? Share this post Link to post Share on other sites
KevsNoTrev 44 Posted November 18, 2013 oops. forgot that part, just setpos to the new marker location if you use Shuko's move objects script then the 'base' can be moved as well to eliminate having to set up multiple bases around the possible locations on the map. Share this post Link to post Share on other sites
meatball 25 Posted November 18, 2013 (edited) Thanks. I've used Shuko's random starting position scripts before. I've been able to use that as a template for making it work by adding this to my Params classes description.ext // paramArray[4] class startingLocation { title = "Starting Location?"; values[] = {0,1}; texts[] = {"Atsalis (North)","Monisi (South)"}; default = 0; }; And then the following in my init.sqf: _startingLocation = paramsarray select 4; "respawn_west" setmarkerposlocal getmarkerpos (str _startingLocation); if (_startingLocation == 1) then { private "_fncMove"; _fncMove = { private ["_dir","_dst","_obj","_new","_old"]; _obj = _this select 0; _old = _this select 1; _new = _this select 2; _dir = ((getpos _obj select 0) - (_old select 0)) atan2 ((getpos _obj select 1) - (_old select 1)); _dst = _old distance _obj; _obj setpos [((_new select 0) + (_dst * sin _dir)),((_new select 1) + (_dst * cos _dir)),(getpos _obj select 2)]; }; _oldPos = getmarkerpos "0"; _newPos = getmarkerpos "1"; [player,_oldPos,_newPos] call _fncMove; }; Seems to work great with the exception of JIP players end up at the default location no matter what... Edited November 18, 2013 by Meatball Share this post Link to post Share on other sites
KevsNoTrev 44 Posted November 18, 2013 (edited) damn - its back the age old JIP issue again. maybe rely upon InitplayerLocal.sqf to fire the move of the player for JIP. isJIP = if (time>0) then {false;} else {true;}; then use isJIP to determine if the player is actually JIP or not - I am sure there are other way, but this is the simplest I can think of right now. Edited November 19, 2013 by KevsnoTrev Clarity Share this post Link to post Share on other sites
meatball 25 Posted November 19, 2013 Yeah, I've already got code in my init to determine if the player is JIP, just no matter how I try to push the JIP player through the move, they keep spawning at the original location. Share this post Link to post Share on other sites
wok 1 Posted November 19, 2013 (edited) EDIT: Oops, sorry I missed the part where you said you wanted to set it via mission parameters. I will leave the mission here anyway in case someone find it useful. -------------------------------------------------------------------------------------------- Here's a quick and dirty mission sample to show you how to use dialogs to select a spawn location when mission starts and when player dies: http://pastelink.me/dl/8f4b70 I have 0 experience with multiplayer scripting so it probably needs some fixes, it's just to show you how easily you can use the dialogs. To test it, put the mission folder in your ArmaProfileFolder/MPMissions, then open the game, click PLAY > MULTIPLAYER > NEW, create a new LAN game and select the Test2 mission. Once the mission starts you should see a dialog with 4 buttons, each button moves the player to a different marker position. Then use your grenades to kill yourself and the dialog will appear again. Edited November 19, 2013 by wok Share this post Link to post Share on other sites
KevsNoTrev 44 Posted November 19, 2013 (edited) Yeah, I've already got code in my init to determine if the player is JIP, just no matter how I try to push the JIP player through the move, they keep spawning at the original location. Are you delaying the move until after player == player? Have you tried moving everyone as they spawn regardless of JIP? EDIT: Have you tried using publicvariable? Thanks Wok, that may prove useful for someone else reading. Edited November 19, 2013 by KevsnoTrev Share this post Link to post Share on other sites
meatball 25 Posted November 19, 2013 (edited) Yeah, I am delaying the JIP players code runs with a "waituntil {!isnull player};". I've been messing around with publicVariables and the sort. Even tried to force JIP players to use "respawn_west" as the spawn location because that gets moved to the actual starting point without luck so far. I'll get it eventually. :) I'm wary to mess with forcing it to happen on Spawn as I'm using BTC revive and I believe that uses the spawn calls as well. Edited November 19, 2013 by Meatball Share this post Link to post Share on other sites
wok 1 Posted November 19, 2013 Here's some related discussion http://forums.unitedoperations.net/index.php/topic/14248-changing-jip-spawn-area/ Share this post Link to post Share on other sites
KevsNoTrev 44 Posted November 20, 2013 Good find there Wok. i found this on this page initPlayerServer.sqf Executed only on server when a player joins mission (includes both mission start and JIP). initPlayerLocal.sqf Executed locally when player joins mission (includes both mission start and JIP). See initialization order for details about when the script is exactly executed. [player:Object,didJIP:Boolean] initplayerlocal.sqf could help - I am just wondering if this indicates didJIP is a BIS variable that we can use to test for JIP without having to script it in ourselves. Share this post Link to post Share on other sites
meatball 25 Posted November 21, 2013 Instead of killing myself trying to figure this out, I finally just created a few teleport flag poles to let people move themselves to whatever starting location they wanted. Accomplishes the same thing that I was looking for. Share this post Link to post Share on other sites
shuko 59 Posted November 21, 2013 Did you try waiting until the player is not null? Maybe the setpos is run too early. Thanks. I've used Shuko's random starting position scripts before. I've been able to use that as a template for making it work by adding this to my Params classes description.ext // paramArray[4] class startingLocation { title = "Starting Location?"; values[] = {0,1}; texts[] = {"Atsalis (North)","Monisi (South)"}; default = 0; }; And then the following in my init.sqf: _startingLocation = paramsarray select 4; "respawn_west" setmarkerposlocal getmarkerpos (str _startingLocation); if (_startingLocation == 1) then { private "_fncMove"; _fncMove = { private ["_dir","_dst","_obj","_new","_old"]; _obj = _this select 0; _old = _this select 1; _new = _this select 2; _dir = ((getpos _obj select 0) - (_old select 0)) atan2 ((getpos _obj select 1) - (_old select 1)); _dst = _old distance _obj; _obj setpos [((_new select 0) + (_dst * sin _dir)),((_new select 1) + (_dst * cos _dir)),(getpos _obj select 2)]; }; _oldPos = getmarkerpos "0"; _newPos = getmarkerpos "1"; [player,_oldPos,_newPos] call _fncMove; }; Seems to work great with the exception of JIP players end up at the default location no matter what... Share this post Link to post Share on other sites