Modme Forums

Random teleport

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: ByKris
I needs a script for teleport me every 2 rounds to a random room (5 rooms). How in Gun defense

How i can do it?


ModmeBot:

Reply By: natesmithzombies
As usual I dont have time to test but give this a shot:



Instructions

--------------

1) Add this to the bottom of mapname.gsc

function teleport_every_Xrounds( rounds_to_tele )
{
	level endon( "intermission" ); 
	
	level.rand_tele_spots = struct::get_array( "rand_tele_struct", "targetname" ); 
	foreach( spot in level.rand_tele_spots )
		spot.cooldown = false; 
	
	
	temp_array = undefined; 
	while(1)
	{
		
		tele_this_round = level.round_number + rounds_to_tele; 
		while( level.round_number < tele_this_round )
			wait(0.05); 
		
		if( !isDefined(temp_array) )
		{
			foreach( spot in temp_array )
				spot.cooldown = false; 
		}
		
		level.rand_tele_spots = array::randomize( level.rand_tele_spots ); 
		choice = level.rand_tele_spots[0].script_noteworthy; 
		
		while( level.rand_tele_spots > 0 && !level.rand_tele_spots[0].cooldown )
		{
			level.rand_tele_spots = array::randomize( level.rand_tele_spots ); 
			choice = level.rand_tele_spots[0].script_noteworthy; 
		}
		
		temp_array = struct::get_array( choice, "script_noteworthy" ); 
		players = GetPlayers(); 
		for( i=0;i<players.size;i++ )="" {="" temp_array[i].cooldown="true;" players[i]="" setelectrified(="" 2="" );="" players[i]="" setorigin(="" temp_array[i].origin="" );="" }="" wait(0.05);="" }=""></players.size;i++>



2) Underneath this in mapname.gsc:

function main()
{

Add this:

level thread teleport_every_Xrounds(2); // change 2 to any number of rounds you would like



3) In radiant go to Entity Browser and insert a script>struct and give it the following KVPs:

targetname - rand_tele_struct

script_noteworthy - zone_name



Note: Make zone_name anything you want just be sure that there are 4 of the same structs with the same script_noteworthy KVP on each struct.



Be aware that this is truly random. Players will get pissed about teleporting to random locations that they may have already been too, but hey that is part of the challenge ;) haha. Report back and let me know if it works. Also this is the type of thing that can take a while to test so here is a tip: in console type "/timescale 2" to make everything double speed for testing purposes. Good luck!


ModmeBot:

Reply By: ByKris

natesmithzombiesAs usual I dont have time to test but give this a shot:



Instructions

--------------

1) Add this to the bottom of mapname.gsc

function teleport_every_Xrounds( rounds_to_tele )
{
	level endon( "intermission" ); 
	level.rand_tele_spots = struct::get_array( "rand_tele_struct", "targetname" ); 
	
	while(1)
	{
		tele_this_round = level.round_number + rounds_to_tele; 
		while( level.round_number < tele_this_round )
			wait(0.05); 
		
		level.rand_tele_spots = array::randomize( level.rand_tele_spots ); 
		choice = level.rand_tele_spots[0].script_noteworthy; 
		
		temp_array = struct::get_array( choice, "script_noteworthy" ); 
		players = GetPlayers(); 
		for( i=0;i<players.size;i++ )="" {="" players="" setelectrified(="" 2="" );="" players[i]="" setorigin(="" temp_array[i].origin="" );="" }="" }=""></players.size;i++>



2) Underneath this in mapname.gsc:

function main()
{

Add this:

level thread teleport_every_Xrounds(2); // change 2 to any number of rounds you would like



3) In radiant go to Entity Browser and insert a script>struct and give it the following KVPs:

targetname - rand_tele_struct

script_noteworthy - zone_name



Note: Make zone_name anything you want just be sure that there are 4 of the same structs with the same script_noteworthy KVP on each struct.



Be aware that this is truly random. Players will get pissed about teleporting to random locations that they may have already been too, but hey that is part of the challenge ;) haha. Report back and let me know if it works. Also this is the type of thing that can take a while to test so here is a tip: in console type "/timescale 2" to make everything double speed for testing purposes. Good luck!


Doesnt work, when I enter the screen is black http://paste.md-5.net/piwadikoyi.tex


ModmeBot:

Reply By: natesmithzombies

ByKrisDoesnt work, when I enter the screen is black http://paste.md-5.net/piwadikoyi.tex


I edited the code to add a line. I missed a wait, that is probably your issue. It should work now


ModmeBot:

Reply By: ByKris

natesmithzombies
ByKrisDoesnt work, when I enter the screen is black http://paste.md-5.net/piwadikoyi.tex


I edited the code to add a line. I missed a wait, that is probably your issue. It should work now


I need that the zombies pass for a site but I cant pass


ModmeBot:

Reply By: natesmithzombies

ByKrisI need that the zombies pass for a site but I cant pass


Not sure what you mean here, but it sounds like another topic. If so, post another topic with greater clarity on what you need


ModmeBot:

Reply By: ByKris
the teleport only teleporting me to 1 room all time, dont change


ModmeBot:

Reply By: natesmithzombies

ByKristhe teleport only teleporting me to 1 room all time, dont change


As I said originally this is truly random. You could be having just bad luck and teleporting to the same room, or you have not inserted the second script_struct correctly. I can confirm that this script does work. I have tested it since my OP. Use console to enter "timescale" to test and you will see that eventually you will make it to another correctly placed struct.


ModmeBot:

Reply By: ByKris

natesmithzombies
ByKristhe teleport only teleporting me to 1 room all time, dont change


As I said originally this is truly random. You could be having just bad luck and teleporting to the same room, or you have not inserted the second script_struct correctly. I can confirm that this script does work. I have tested it since my OP. Use console to enter "timescale" to test and you will see that eventually you will make it to another correctly placed struct.


I've done everything right but only teleport me to 1 room, i have tested it for 30 rounds and all time same


ModmeBot:

Reply By: natesmithzombies

ByKris
natesmithzombies
ByKristhe teleport only teleporting me to 1 room all time, dont change


As I said originally this is truly random. You could be having just bad luck and teleporting to the same room, or you have not inserted the second script_struct correctly. I can confirm that this script does work. I have tested it since my OP. Use console to enter "timescale" to test and you will see that eventually you will make it to another correctly placed struct.


I've done everything right but only teleport me to 1 room, i have tested it for 30 rounds and all time same


Updated the original code again. If you dont teleport to another room now I can assure you that you didnt properly place the structs


ModmeBot:

Reply By: ByKris

natesmithzombies
ByKris
natesmithzombies
ByKristhe teleport only teleporting me to 1 room all time, dont change


As I said originally this is truly random. You could be having just bad luck and teleporting to the same room, or you have not inserted the second script_struct correctly. I can confirm that this script does work. I have tested it since my OP. Use console to enter "timescale" to test and you will see that eventually you will make it to another correctly placed struct.


I've done everything right but only teleport me to 1 room, i have tested it for 30 rounds and all time same


Updated the original code again. If you dont teleport to another room now I can assure you that you didnt properly place the structs


What am I doing wrong? i have 5 structs with the target name rand_tele_struct and script_noteworthy zone_name but only teleport me to 1 room


ModmeBot:

Reply By: ByKris

natesmithzombies
ByKris
natesmithzombies
ByKristhe teleport only teleporting me to 1 room all time, dont change


As I said originally this is truly random. You could be having just bad luck and teleporting to the same room, or you have not inserted the second script_struct correctly. I can confirm that this script does work. I have tested it since my OP. Use console to enter "timescale" to test and you will see that eventually you will make it to another correctly placed struct.


I've done everything right but only teleport me to 1 room, i have tested it for 30 rounds and all time same


Updated the original code again. If you dont teleport to another room now I can assure you that you didnt properly place the structs


Hi?


ModmeBot:

Reply By: Exofile

ByKrisHi?


Give people time, you don't need to "bump" a thread or alike. Men have their own lives to live besides helping people online.


ModmeBot:

Reply By: natesmithzombies

ByKrisWhat am I doing wrong? i have 5 structs with the target name rand_tele_struct and script_noteworthy zone_name but only teleport me to 1 room


Sounds like your KVPs are wrong. You may not be understanding what I meant entirely. Here are some screenshots of my structs to make things a bit more clear: