Jump to content
  • 0

Teleport script?


Barrikade

Question

Hi,

is there a way to add a teleport system to my server?

 

What I would like to do is add teleportation points that would teleport players to different areas of the map

Maybe with a cost and text attached for example..

 

"This unit will teleport you to bandit city one for 1 10oz gold bar, do you accept?"

And a scroll wheel selection to give the player the chioce

1-Take me there

2-I'm staying put

 

Or maybe just a simple box that I could create in the editor that the player walks into and comes out at the other end

I'm thinking like Jeff Goldblum in The Fly (without the side effects lol)

 

I've been working hard on map edits for my Napf server and i just want to add a little extra something and teleporting would be a great way to get players to these new areas

I've seen reference to teleporting in similar context but no actual scripts, searching usually just comes up with admin tools

Any help would be much appreciated.

Thanks.

 

 

 

Link to comment
Share on other sites

21 answers to this question

Recommended Posts

  • 0

bots will be bot

 

anyway, you can quite easy do this, just add a selfaction that will activate by some object you place in the editor then simply place units where you want the players to be teleported to and use those positions, then player setpos to that position

 

might be a good idea to add a few positions into an array and choose one random or use findsafepos to avoid player deaths incase two players teleport to exact same position same time

Link to comment
Share on other sites

  • 0

Thanks for your reply/index.php?/user/10011-halvhjearne/" title=""> Halvhjearne

I kind of understand what you are saying here but unfortunatley i do not have the experience to implement it practically

Although, now you have told  me what i need to do i can start to research the different aspects and hopefully come to some form of conclusion.

I am quite new to all this right now but i have started to learn a few things along the way.

 

Just to get me started though, the selfaction.. would i be looking for a few lines of code to add to my fn_selfActions.sqf or would it be a block of code that is in there already that i can copy and paste to alter to suit my needs?

Link to comment
Share on other sites

  • 0

how about some teleportin beans?

 

modify the deploy bike self action for - say a un-used food item,  lets for giggles say " AngelCookies " , because they are not currently in the loot piles, so you could maybe make them purchasable at a vendor

//--------------------------------------- deployable angel cookies-----------------------------------------------
	


_weapons = [currentWeapon player] + (weapons player) + (magazines player);

//BIKE DEPLOY- edited for angelcookies
if ("AngelCookies" in _weapons) then {
        hasBikeItem = true;
    } else { hasBikeItem = false;};
    if((speed player <= 1) && hasBikeItem && _canDo) then {
        if (s_player_deploybike < 0) then {
            s_player_deploybike = player addaction[("<t color=""#007ab7"">" + ("AngelCookie Teleport!") +"</t>"),"custom\angelcookietp.sqf","",5,false,true,"", ""];
        };
    } else {
        player removeAction s_player_deploybike;
        s_player_deploybike = -1;
};

//--------------------------------------end angel cookie deploy--------------------------------------------

angelcookietp.sqf  (aka safeteleport)

if !("ItemMap" in items player) then {player addweapon "ItemMap";};

if (isNil "ViLayer") then {ViLayer = true;};
if (ViLayer) then {player setVariable["lastPosition",1337]; player setVariable ["lastTimes", 1337];};

openMap [true, false];
onMapSingleClick "[_pos select 0, _pos select 1] call abcd";

abcd={
	
	_dir = getDir (vehicle player);
	thingtoattachto = "Can_small" createVehicleLocal [_pos select 0, _pos select 1];

	(vehicle player) attachTo [thingtoattachto, [0,0,0.5]];
	(vehicle player) setDir _dir;

onMapSingleClick "";
openMap [false, false];
	};

_mapside = 15000;
maphalf = _mapside/2; mapscanrad = sqrt (2*maphalf*maphalf);
startITEMlist = nearestObjects [[maphalf,maphalf],["Can_small"],mapscanrad];
startanzahlITEMs = count startITEMlist;

countlocalspawnedshitxyz = true;

while {countlocalspawnedshitxyz} do {

_mapside = 15000;
maphalf = _mapside/2; mapscanrad = sqrt (2*maphalf*maphalf);
activeITEMlist = nearestObjects [[maphalf,maphalf],["Can_small"],mapscanrad];
activeITEMlistanzahl = count activeITEMlist;

if !(startanzahlITEMs==activeITEMlistanzahl) then {

deleteVehicle thingtoattachto;
countlocalspawnedshitxyz = false;

startanzahlITEMs=activeITEMlistanzahl;


};

sleep 0.2;
deleteVehicle thingtoattachto;
detach (vehicle player);
player removeMagazine "AngelCookies";
};

just a thought - and re-purposing some already existing code

Link to comment
Share on other sites

  • 0

Thanks for your input MassAsster, so this code would be for an item that a player actually carries around with them (the cookie) and deploys it wherever they want? but takes them to a fixed location? (the can)

Am i reading that correctly ?

All im looking to do is have the player move from one existing fixed location  to another, i have already created the model in the editor wich i can copy and paste to several points of interest around the map.

 

Player walks up to the tp and the scroll menu opens with the option to teleport. I've found a couple of guides and taken some from each using attachto and/or setpos commands.

 

Unless i'm looking at your code wrong, i'll try it out though on my test server to see what effects i get,  cheers :D

Link to comment
Share on other sites

  • 0

YEah, the item was angelcookies - but that apparently doesnt have an in game icon - so I've changed it around to another - muffins

 

but the long and short of it , it's dynamic teleport and it opens the map, the player clicks a map location and it takes them there - but it doesn't have to be , with some tweaking, you could set fixed locations and set multiple selfactions to come up with a list of places that call upon a fixed location- sooo

you could be holding muffins and get the option to teleport to any trader , and upon completion it takes the muffins from you

Link to comment
Share on other sites

  • 0

I like the idea of the list of locations opening up, i was playing around with a couple of things earlier and  then i got sidetracked with angel cookies and started adding items to the traders lol

Anyhow i like the sound of your idea here, i will come back to it tomorrow with a fresh pair of eyes and take another look.

i've looked at so many guides about coding and editing today i'm in overload, so right now i'm hitting the hay, try and process some info

Thanks for your help with this MassAsster :D

Link to comment
Share on other sites

  • 0

how about some teleportin beans?

 

modify the deploy bike self action for - say a un-used food item,  lets for giggles say " AngelCookies " , because they are not currently in the loot piles, so you could maybe make them purchasable at a vendor

//--------------------------------------- deployable angel cookies-----------------------------------------------
	


_weapons = [currentWeapon player] + (weapons player) + (magazines player);

//BIKE DEPLOY- edited for angelcookies
if ("AngelCookies" in _weapons) then {
        hasBikeItem = true;
    } else { hasBikeItem = false;};
    if((speed player <= 1) && hasBikeItem && _canDo) then {
        if (s_player_deploybike < 0) then {
            s_player_deploybike = player addaction[("<t color=""#007ab7"">" + ("AngelCookie Teleport!") +"</t>"),"custom\angelcookietp.sqf","",5,false,true,"", ""];
        };
    } else {
        player removeAction s_player_deploybike;
        s_player_deploybike = -1;
};

//--------------------------------------end angel cookie deploy--------------------------------------------

angelcookietp.sqf  (aka safeteleport)

if !("ItemMap" in items player) then {player addweapon "ItemMap";};

if (isNil "ViLayer") then {ViLayer = true;};
if (ViLayer) then {player setVariable["lastPosition",1337]; player setVariable ["lastTimes", 1337];};

openMap [true, false];
onMapSingleClick "[_pos select 0, _pos select 1] call abcd";

abcd={
	
	_dir = getDir (vehicle player);
	thingtoattachto = "Can_small" createVehicleLocal [_pos select 0, _pos select 1];

	(vehicle player) attachTo [thingtoattachto, [0,0,0.5]];
	(vehicle player) setDir _dir;

onMapSingleClick "";
openMap [false, false];
	};

_mapside = 15000;
maphalf = _mapside/2; mapscanrad = sqrt (2*maphalf*maphalf);
startITEMlist = nearestObjects [[maphalf,maphalf],["Can_small"],mapscanrad];
startanzahlITEMs = count startITEMlist;

countlocalspawnedshitxyz = true;

while {countlocalspawnedshitxyz} do {

_mapside = 15000;
maphalf = _mapside/2; mapscanrad = sqrt (2*maphalf*maphalf);
activeITEMlist = nearestObjects [[maphalf,maphalf],["Can_small"],mapscanrad];
activeITEMlistanzahl = count activeITEMlist;

if !(startanzahlITEMs==activeITEMlistanzahl) then {

deleteVehicle thingtoattachto;
countlocalspawnedshitxyz = false;

startanzahlITEMs=activeITEMlistanzahl;


};

sleep 0.2;
deleteVehicle thingtoattachto;
detach (vehicle player);
player removeMagazine "AngelCookies";
};

just a thought - and re-purposing some already existing code

 

first off ...

 

for obvius reasons  it is an extreemly bad idea to begin with to have players teleport by will, but having them beeing able to teleport from some object they can buy at the vendors, is an even worse idea imo.

imagine the abuse that can come from this, most likely it will end with players combatteleporting instead of combatlogging. (not to mention the use for teleporting back to someone who just killed the player)

 

 

second off, that is a lot of code to do something you can simply do with setpos. (most of this code is absolete and irrelevant to this)

 

third, if you have an activating item you want removed on activation, you better do this first or players might find a way to remove the item from inventory before it is removed by the game, giving them the ability to teleport unlimited.

 

 

and at last, whats the point of setting a variable you are not going to use anywhere?

 

now as a note/hint to this, the entire teleport part could be done in the onmapsingleclick command line, the whole script could be done in a few lines, however having players teleport where they want is an extreemly bad idea aswell ... you should atleast use findsafepos, within 1.5km atleast ... imagine the abuse that could come from this, not to mention the griefing players could use it for, like teleporting into places they are not sopposed to go, through buildings and into other players locked bases. (not to mention all the deaths you will have from players teleporting to a bad location.)

 

the idea to have predefined places to teleport from and randomized places (within the area he wants) to teleport to however is acceptable, since players never knows exactly where he will go, and he will have to go to a certain place to activate this aswell, that should make it a bit harder to abuse.

Link to comment
Share on other sites

  • 0

Yeah, this was simply old code that was being re-purposed as stated, the variable had to do with the original authors usage, and nothing to do with the current usage... it wasn't final code... or even suggested to use as is, as he wanted defined locations, not player selected. Every great Idea starts somewhere... and well played posting no example code to make your point valid...

 

I appreciate most of your suggestions, but there's no need to "Seagull post" to make them.

Link to comment
Share on other sites

  • 0

Yeah, this was simply old code that was being re-purposed as stated, the variable had to do with the original authors usage, and nothing to do with the current usage... it wasn't final code... or even suggested to use as is, as he wanted defined locations, not player selected. Every great Idea starts somewhere... and well played posting no example code to make your point valid...

 

I appreciate most of your suggestions, but the majority of your post is "Seagull posting".

 

you really are a idiot i guess ...

 

besides the fact that your example is using an extreem amount of code to do something rather simple it will also allow to teleport with a vehicle, also when you share code and you know some of it is unused or irrelevant, then remove it from the script ... its text and quite easy to edit.

 

i guess its hard to understand what i wrote in the first post, but ill explain better here with some sample code you so desperatly need:

_pos = [[1521.7786, 13230.855, 0.02],[1513.8726, 13241.563, 0.02],[1505.9368, 13252.447, 0.02],[1499.5918, 13260.975, 0.02]] call bis_fnc_selectrandom;
player setPos _pos;

now as i explained in my initial post, you can now get the positions you need in the editor by placing units or vehicles where you want to teleport to, you could even make this script even more versatile like this:

_pos = _this call bis_fnc_selectrandom;
player setPos _pos;

and when executing you put the positions here like this:

[[1521.7786, 13230.855, 0.02],[1513.8726, 13241.563, 0.02],[1505.9368, 13252.447, 0.02],[1499.5918, 13260.975, 0.02]] execVM "setPos.sqf";

 

now these are just some random postions from my convoy mission somewhere by skalka, so find your own positions to use

 

as i mentioned before, this is quite simple, so no need to complicate it much further than this ... i wont mind helping the op figure this out either so if you stop trolling and start reading, we can move on.

 

@Barrikade

as i said, go to the editor and find some suitable locations in the editor and add a comment to the units so you can see in the script, which positions goes where, when you done that write back and ill help you figure some nicer code for this ... i might alread have something halfdone you can use

Link to comment
Share on other sites

  • 0

I've finaly got something off the ground, a very basic teleport code that teleports the player from one fixed location to another.

I also added

cut Text, BLACK OUT, and WHITE IN along with sleep 2 and its doing exactly what i wanted

I'm just researching arrays now so I can give the player the option to teleport to location A, B or C

 

Edit

thanks for that Halvhjearne i will take a closer look at your code

 

after reading through it a couple of times i think its clicked i'll play around with it now,  thanks :D

Yeah i'm getting old and things dont sink in as fast these days lol.

Link to comment
Share on other sites

  • 0

@Barrikade

as i said, go to the editor and find some suitable locations in the editor and add a comment to the units so you can see in the script, which positions goes where, when you done that write back and ill help you figure some nicer code for this ... i might alread have something halfdone you can use

Link to comment
Share on other sites

  • 0

So close, i have tried your code and a few variations of and the closest i have got is teleporting to the same location over 5 tests

I added the cutText and BLACK OUT so i know the script is running but now i'm not moving anywhere.

On the object in game i have ..

 

this addAction ["Teleport", "setpos.sqf"];

 

and my setpos.sqf is ..

 

_POS = [[5160.2446, 4824.1216, 0.02],[14433.098, 16839.963, 0.02],[18130.816, 2031.8955, 0.02],[16309.836, 18425.389, 0.02]] call bis_fnc_selectrandom;
cutText ["Hold Tight","BLACK OUT"];
sleep 1;
cutText ["","WHITE IN"];
player setPos _pos;
 

First time i had it working i had forgot the [] around the co-ords it was working but only to first location

After i added the [] it stopped working but the cutText etc are showing up.

 

I'll play around with it some more when i get home from work tomorrow.

Link to comment
Share on other sites

  • 0

So close, i have tried your code and a few variations of and the closest i have got is teleporting to the same location over 5 tests

I added the cutText and BLACK OUT so i know the script is running but now i'm not moving anywhere.

On the object in game i have ..

 

this addAction ["Teleport", "setpos.sqf"];

 

and my setpos.sqf is ..

 

_POS = [[5160.2446, 4824.1216, 0.02],[14433.098, 16839.963, 0.02],[18130.816, 2031.8955, 0.02],[16309.836, 18425.389, 0.02]] call bis_fnc_selectrandom;

cutText ["Hold Tight","BLACK OUT"];

sleep 1;

cutText ["","WHITE IN"];

player setPos _pos;

 

First time i had it working i had forgot the [] around the co-ords it was working but only to first location

After i added the [] it stopped working but the cutText etc are showing up.

 

I'll play around with it some more when i get home from work tomorrow.

Link to comment
Share on other sites

  • 0

pls put code in codebrackets, it makes it a lot easier to look through ...

 

that being said, im pretty sure private variables are case sensitve ... so change either

_pos

or

_POS

to same as the other and it should work again ... however, this will select a random location from the 4 you put in the array (not sure if that was the intension?)

 

also you might want to change the part in the bigining so its not adding the action every time you run the script 

Link to comment
Share on other sites

  • 0

not sure where you went wrong, i think i will need to see the script ... try post the whole script for me to see or send it in pm, if you dont want to share with everyone before its done.

 

what i suggested was to change it like this: 

_pos = [[5160.2446, 4824.1216, 0.02],[14433.098, 16839.963, 0.02],[18130.816, 2031.8955, 0.02],[16309.836, 18425.389, 0.02]] call bis_fnc_selectrandom;
cutText ["Hold Tight","BLACK OUT"];
sleep 1;
cutText ["","WHITE IN"];
player setPos _pos;

idk how well it works with attaching the addaction to the object, but i think i would have just added it into fn_selfactions.sqf like this:

_isTpObj = cursorTarget isKindOf "Notebook";
if ((speed player <= 1) && _isTpObj && _canDo && (player distance cursorTarget < 4)) then {
	if (s_player_Teleport < 0) then {
		s_player_Teleport = player addAction [("<t color=""#0096ff"">" + ("Teleport") +"</t>"),"setpos.sqf","", 0, false, true, "",""];
	};
} else {
	player removeAction s_player_Teleport;
	s_player_Teleport = -1;
};

this will add the action when looking at a notebook, but you could change the classname to any other classname

Link to comment
Share on other sites

  • 0

I will try it with the self action as you recommend as you did in your first post, I just didn't understand completely.
I am at work right now but when I get home I will try and see where I get.

 

Edit

Removed the

addAction

from the object

Added your code to fn_selfAction.sqf

but still no dice.

PM'd.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...