Heidelberg 2 Posted February 21, 2017 I've searched throughout the internet and forums, but I think there is a much more simple way of creating a script that allows a player to interact with a certain object, and then choose to teleport to one of several self-chosen spawn-points. How can I do that? Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted February 21, 2017 Check this out: //GOM_fnc_fastTravelSystem.sqf V0.9 - created by Grumpy Old Man //version as is, since it's not released or tested thoroughly //to use it: //travel object (flagpole or whatever): [this] call GOM_fnc_FastTravelSystem; // //into init.sqf: //[] execVM "GOM_fnc_FastTravelSystem.sqf"; // //to add custom name to teleport: //this setvariable ["GOM_fnc_FastTravelName","WHATEVERYOUWANT"]; // //you can also only allow certain destinations from a teleport: //this setvariable ["GOM_fnc_FastTravelAllowedDestinations"[teleport2,teleport4]]; // //you can also exclude destinations: //this setvariable ["GOM_fnc_FastTravelExcludedDestinations",[teleport3,teleport4]]; //if you want to add teleport points mid mission simply run the script again with the updated input array of teleport objects if (count _this isEqualTo 1) exitWith { params ["_travelPoint"]; _travelArray = missionNamespace getVariable ["GOM_fnc_FastTravelArray",[]]; _travelArray pushBackUnique _travelPoint; missionNamespace setVariable ["GOM_fnc_FastTravelArray",_travelArray,true]; }; params [["_travelCooldown",60],["_travelDurationperKM",5],["_travelMinDuration",10],["_travelArray",[]]]; _travelArray = missionNamespace getVariable ["GOM_fnc_FastTravelArray",[]]; if (_travelArray isEqualTo []) exitWith {diag_log "GOM_fnc_FastTravel: No valid travelpoints found!";systemchat "GOM_fnc_FastTravel: No valid travelpoints found!"}; { _ID = _x getVariable ["GOM_fnc_travelActionID",-1]; _x removeAction _ID; } foreach _travelArray; { _travelPoint = _x; _allowedDestinations = _x getVariable ["GOM_fnc_FastTravelAllowedDestinations",_travelArray]; _excludedDestinations = _x getVariable ["GOM_fnc_FastTravelExcludedDestinations",[]]; _tempTravelArray = _travelArray - [_travelPoint]; diag_log str _excludedDestinations; diag_log str _tempTravelArray; _tempTravelArray = _tempTravelArray - [_excludedDestinations]; diag_log str _tempTravelArray; { _travelName = _x getvariable ["GOM_fnc_FastTravelName",""]; _nearLocation = nearestLocation [getPosATL _x,""]; if (_travelName isEqualTo "" AND !(text _nearLocation isEqualTo "")) then { _travelName = text _nearLocation; }; if (_travelName isEqualTo "" AND (text _nearLocation isEqualTo "")) then { _travelName = format ["Point %1",(_foreachIndex) + 1]; }; _distance = round ((_travelPoint distance2d _x) / 1000); _traveltime = _distance * _travelDurationperKM; if (_traveltime < _travelMinDuration) then {_traveltime = _travelMinDuration}; if (_x in _allowedDestinations AND !(_x in _excludedDestinations)) then { _ID = _travelPoint addAction [format ["Travel to %1 (%2km - %3s)",_travelName,_distance,_traveltime ],{ params ["_travelPoint","_caller","_ID","_params"]; _params params ["_travelTarget","_targetName","_traveltime","_travelCooldown"]; _lockOut = _caller getvariable ["GOM_fnc_travelCooldown",-60]; if (time < _lockOut) exitWith {cutText [format ["Next travel possible in %1s.",round (_lockOut - time)], "PLAIN DOWN",1];true}; _teleport = [_caller,_travelPoint,_travelTarget,_targetName,_traveltime,_travelCooldown] spawn { params ["_caller","_travelPoint","_travelTarget","_targetName","_traveltime","_travelCooldown"]; cutText [format ["You will be transported to %1 in %2 seconds.\nMove away if you wish to stay.",_targetName,_traveltime], "PLAIN DOWN",1]; _travelPoint setvariable ['GOM_fnc_travelInProgress',true]; playSound "click"; _caller setvariable ["GOM_fnc_travelCooldown",time + _travelCooldown]; sleep _traveltime; _hasVehicle = false; _vehicle = assignedVehicle _caller; if (!(_vehicle isEqualTo objNull) AND alive _vehicle AND _vehicle distance2D _caller < 20) then {_check = typeof assignedVehicle _caller;_hasVehicle = true;}; if (_caller distance2D _travelPoint < 20) then { _safePos = getposatl _travelTarget findEmptyPosition [10,30,typeof _caller]; if (_safePos isEqualTo []) then { _safePos = getposatl _travelTarget findEmptyPosition [10,150,typeof _caller]; }; if (_safePos isEqualTo []) then { _safePos = getPosATLVisual _travelTarget; }; _caller setdir random 360; _caller allowdamage false; _caller setposatl _safePos; _caller allowdamage true; if (_hasVehicle) then { _safePos = _safePos findEmptyPosition [10,150,typeof _vehicle]; _vehicle setdir random 360; _vehicle allowdamage false; _vehicle setposatl _safePos; _vehicle allowdamage true; }; cutText [format ["You arrived at %1.\n%2",_targetName,selectRandom ["Enjoy your stay.","Stay safe.","Watch your step.","Grab your towel and don't panic.","Have a nice stay.","Welcome."]], "PLAIN DOWN",1]; _travelPoint say3d "Spawn"; sleep 5; _travelPoint setvariable ['GOM_fnc_travelInProgress',false]; } else { cutText [format ["Transport to %1 aborted. You need to stay near the departure point.",_targetName], "PLAIN DOWN",1]; _travelPoint say3d "click"; sleep 5; _travelPoint setvariable ['GOM_fnc_travelInProgress',false]; hint ""; }; }; },[_x,_travelName,_traveltime,_travelCooldown],0,false,true,"","!(_target getvariable ['GOM_fnc_travelInProgress',false]) AND _this distance2d _target < 20"]; _travelPoint setVariable ["GOM_fnc_travelActionID",_ID]; }; } foreach _tempTravelArray; } foreach _travelArray; true Adds actions to objects, you can also use whitelist / blacklist destinations etc., all in the description. It's working but hasn't been tested so take it as is. Just save the content of the code field into a .sqf file and launch it from init.sqf and follow the instructions. Cheers Share this post Link to post Share on other sites
Heidelberg 2 Posted February 21, 2017 8 minutes ago, Grumpy Old Man said: <reply> So i create an sqf out of this, and execute it through the init. But first I have to add a sign as an example, where the base is, which allows you to be teleported to several points in another place. What do I have to write in the init at the base and the inits at the other points of the map? Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted February 21, 2017 All in the documentation at the beginning. Just read it. In case you're still confused: Entire script goes into GOM_fnc_FastTravelSystem.sqf. Then in init.sqf you put this: [] execVM "GOM_fnc_FastTravelSystem.sqf"; Put 2 objects, flagpoles or whatever named "portStart" and "portEnd" at the positions you want to travel between and paste this into their inits: [this] call GOM_fnc_FastTravelSystem; Now in the destination points ("portEnd") init use this to make the departure object one way only: this setvariable ["GOM_fnc_FastTravelExcludedDestinations",[portStart]]; Cheers 2 Share this post Link to post Share on other sites
Heidelberg 2 Posted February 21, 2017 33 minutes ago, Grumpy Old Man said: <reply> I've done exactly as you've said. Not working unfortunately. (doing it on multiplayer if that should do any help). Nothing happens when I try scrollwheeling on the object (sign). Share this post Link to post Share on other sites
Guest Posted February 21, 2017 this addAction ["Teleport to 1", {player setPos [1500,1500,2]}]; this addAction ["Teleport to 2", {player setPos [1500,1250,2]}]; this addAction ["Teleport to 3", {player setPos [1500,1000,2]}]; Very simple way EDIT : Useful links https://community.bistudio.com/wiki/addAction https://community.bistudio.com/wiki/setPos Share this post Link to post Share on other sites
serena 151 Posted February 21, 2017 player addAction ["Jump Forward 1km", {player setPos (player getPos [1000, getDir player])}]; Share this post Link to post Share on other sites
Tobur 37 Posted February 22, 2017 run this via the init of any object: openMap true; titleText ["Teleport-position", "PLAIN"]; onMapSingleClick "vehicle player setPos _pos; onMapSingleClick ''; true;"; doesn't work so well in multiplayer though... Share this post Link to post Share on other sites
Heidelberg 2 Posted February 22, 2017 37 minutes ago, tobur said: run this via the init of any object: openMap true; titleText ["Teleport-position", "PLAIN"]; onMapSingleClick "vehicle player setPos _pos; onMapSingleClick ''; true;"; doesn't work so well in multiplayer though... 1 The player must not have the availability of choosing where to teleport. The design is that you should scroll wheel on an object that gives you the option of teleporting to battle. Just one-way, no option of choosing where to teleport. If anybody have played on the German Academy Deathmatch servers, it's the exact same way I wish it to work like. - scroll wheel on sign that says "teleport to battle" - takes the player into one of many available spawn points in that battle-arena. Share this post Link to post Share on other sites
Guest Posted February 22, 2017 this addAction ["Teleport to battle", {player setPos getMarkerPos (selectRandom ["marker_battle","marker_battle2","marker_battle3"])}]; Like this maybe ? Share this post Link to post Share on other sites
killzone_kid 1331 Posted February 22, 2017 45 minutes ago, tobur said: doesn't work so well in multiplayer though... This shouldn't work at all as it contains syntax errors 1 Share this post Link to post Share on other sites
Heidelberg 2 Posted February 22, 2017 1 hour ago, harmdhast said: this addAction ["Teleport to battle", {player setPos getMarkerPos (selectRandom ["marker_battle","marker_battle2","marker_battle3"])}]; Like this maybe ? This looks promising, might try it out. Share this post Link to post Share on other sites
Chuc 83 Posted March 7, 2017 I use this pole1 addaction ["Teleport to pole 2", {_this select 1 setpos getpos pole2;}]; pole2 addaction ["Teleport to pole 1", {_this select 1 setpos getpos pole1;}]; I place flag poles down and give them names. No scripts needed. Share this post Link to post Share on other sites