Player Specific Teleportation Spots
Game Modding | Call of Duty: Black Ops 3 | Scripting
Nikon :
This might sound like a repeat of my random teleportation thread I posted a while ago but I just need something added. I need a script to allow the random teleportation spots to be player assigned from player 1 to 4. An example would be there are four random teleportation spots in the middle of the map. Each spot has a player assigned to it so that way players won't spawn on top of each other and die. Edit: Here's the teleportation script if you need to edit it. function pistol_def_tp() { spots = struct::get_array("pistol_def_tp_spot", "targetname"); while(1) { level waittill("end_of_round"); foreach(player in GetPlayers()) { player thread lui::screen_fade_out(1); } level waittill( "start_of_round" ); foreach(player in GetPlayers()) { loc = array::random(spots); player SetOrigin(loc.origin + (0,0,20)); player SetPlayerAngles(loc.angles); player thread zm::screen_fade_in(2); } } }
eDeK :
Maybe something like this...
function pistol_def_tp ()
{
p1_struct = struct :: get ( "p1_struct" , "targetname" );
p2_struct = struct :: get ( "p2_struct" , "targetname" );
p3_struct = struct :: get ( "p3_struct" , "targetname" );
p4_struct = struct :: get ( "p4_struct" , "targetname" );
level endon ( "end_game" );
level endon ( "intermission" );
while ( 1 )
{
level waittill ( "end_of_round" );
players = GetPlayers ();
player_1 = players [ 0 ];
player_2 = players [ 1 ];
player_3 = players [ 2 ];
player_4 = players [ 3 ];
if ( isdefined ( player_1 ) )
{
player_1 thread lui :: screen_fade_out ( 1 );
}
if ( isdefined ( player_2 ) )
{
player_2 thread lui :: screen_fade_out ( 1 );
}
if ( isdefined ( player_3 ) )
{
player_3 thread lui :: screen_fade_out ( 1 );
}
if ( isdefined ( player_4 ) )
{
player_4 thread lui :: screen_fade_out ( 1 );
}
level waittill ( "start_of_round" );
if ( isdefined ( player_1 ) )
{
player_1 SetOrigin ( p1_struct . origin + ( 0 , 0 , 20 ) );
player_1 SetPlayerAngles ( p1_struct . angles );
player_1 thread zm :: screen_fade_in ( 2 );
}
if ( isdefined ( player_2 ) )
{
player_2 SetOrigin ( p2_struct . origin + ( 0 , 0 , 20 ) );
player_2 SetPlayerAngles ( p2_struct . angles );
player_2 thread zm :: screen_fade_in ( 2 );
}
if ( isdefined ( player_3 ) )
{
player_3 SetOrigin ( p3_struct . origin + ( 0 , 0 , 20 ) );
player_3 SetPlayerAngles ( p3_struct . angles );
player_3 thread zm :: screen_fade_in ( 2 );
}
if ( isdefined ( player_4 ) )
{
player_4 SetOrigin ( p4_struct . origin + ( 0 , 0 , 20 ) );
player_4 SetPlayerAngles ( p4_struct . angles );
player_4 thread zm :: screen_fade_in ( 2 );
}
wait 0.05 ;
WAIT_SERVER_FRAME ;
}
}
Sleepy216 :
I noticed eDek's script no longer randomly teleports the player, just teleports them to their own struct. I haven't tested this out, but I think it should work how you want. My usual disclaimer, I am no expert, so this probably isn't the best method but it should work!
callback :: on_connect ( & amp ; on_player_connect ); //put this under zm_usermap::main();
//if you already have a "on_player_connect" function, just add my bit of code to your already existing function
function on_player_connect () //paste the rest at the bottom of your script
{
spots_p1 = struct :: get_array ( "pistol_def_tp_spot_00" , "targetname" ); //Player1 Tp spots
spots_p2 = struct :: get_array ( "pistol_def_tp_spot_01" , "targetname" ); //Player2 Tp spots
spots_p3 = struct :: get_array ( "pistol_def_tp_spot_02" , "targetname" ); //Player3 Tp spots
spots_p4 = struct :: get_array ( "pistol_def_tp_spot_03" , "targetname" ); //Player4 Tp spots
players = GetPlayers ();
for ( q = 0 ; q & lt ; players . size ; q ++ )
{
/*
This next part is probably not the best way to thread them, but it works.
I got an error before testing a similar script when I just setorigin on all TP locations
to 4 players, even if there was only one player in game. So I started using this method.
I had to fix one thing, so I also cleaned up the threading, it should still work the same, just looks less cluttered.
If it doesn't work let me know, and I'll change it back to the other way.
*/
people = players . size ;
if ( people & gt ; = 1 )
{
players [ 0 ] thread pistol_def_tp ( spots_p1 );
}
if ( people & gt ; = 2 )
{
players [ 1 ] thread pistol_def_tp ( spots_p2 );
}
if ( people & gt ; = 3 )
{
players [ 2 ] thread pistol_def_tp ( spots_p3 );
}
if ( people == 4 )
{
players [ 3 ] thread pistol_def_tp ( spots_p4 );
}
}
function pistol_def_tp ( spots )
{
while ( 1 )
{
level waittill ( "end_of_round" );
self thread lui :: screen_fade_out ( 1 );
level waittill ( "start_of_round" );
loc = array :: random ( spots );
self SetOrigin ( loc . origin + ( 0 , 0 , 20 ));
self SetPlayerAngles ( loc . angles );
self thread zm :: screen_fade_in ( 2 );
}
}
Nikon :
I noticed eDek's script no longer randomly teleports the player, just teleports them to their own struct. I haven't tested this out, but I think it should work how you want. My usual disclaimer, I am no expert, so this probably isn't the best method but it should work!
callback :: on_connect ( & amp ; on_player_connect ); //put this under zm_usermap::main();
//if you already have a "on_player_connect" function, just add my bit of code to your already existing function
function on_player_connect () //paste the rest at the bottom of your script
{
spots_p1 = struct :: get_array ( "pistol_def_tp_spot_00" , "targetname" ); //Player1 Tp spots
spots_p2 = struct :: get_array ( "pistol_def_tp_spot_01" , "targetname" ); //Player2 Tp spots
spots_p3 = struct :: get_array ( "pistol_def_tp_spot_02" , "targetname" ); //Player3 Tp spots
spots_p4 = struct :: get_array ( "pistol_def_tp_spot_03" , "targetname" ); //Player4 Tp spots
players = GetPlayers ();
for ( q = 0 ; q & lt ; players . size ; q ++ )
{
/*
This next part is probably not the best way to thread them, but it works.
I got an error before testing a similar script when I just setorigin on all TP locations
to 4 players, even if there was only one player in game. So I started using this method.
I had to fix one thing, so I also cleaned up the threading, it should still work the same, just looks less cluttered.
If it doesn't work let me know, and I'll change it back to the other way.
*/
people = players . size ;
if ( people & gt ; = 1 )
{
players [ 0 ] thread pistol_def_tp ( spots_p1 );
}
if ( people & gt ; = 2 )
{
players [ 1 ] thread pistol_def_tp ( spots_p2 );
}
if ( people & gt ; = 3 )
{
players [ 2 ] thread pistol_def_tp ( spots_p3 );
}
if ( people == 4 )
{
players [ 3 ] thread pistol_def_tp ( spots_p4 );
}
}
function pistol_def_tp ( spots )
{
while ( 1 )
{
level waittill ( "end_of_round" );
self thread lui :: screen_fade_out ( 1 );
level waittill ( "start_of_round" );
loc = array :: random ( spots );
self SetOrigin ( loc . origin + ( 0 , 0 , 20 ));
self SetPlayerAngles ( loc . angles );
self thread zm :: screen_fade_in ( 2 );
}
}
I tried linking and compiling the map again and got another error about no generated data. Thanks for helping again man, really means alot since I'm still new to the modding scene and still need to learn how to script myself.
eDeK :
He forgot one " } "
function on_player_connect ()
{
spots_p1 = struct :: get_array ( "pistol_def_tp_spot_00" , "targetname" );
spots_p2 = struct :: get_array ( "pistol_def_tp_spot_01" , "targetname" );
spots_p3 = struct :: get_array ( "pistol_def_tp_spot_02" , "targetname" );
spots_p4 = struct :: get_array ( "pistol_def_tp_spot_03" , "targetname" );
players = GetPlayers ();
for ( q = 0 ; q & lt ; players . size ; q ++ )
{
people = players . size ;
if ( people & gt ; = 1 )
{
players [ 0 ] thread pistol_def_tp ( spots_p1 );
}
if ( people & gt ; = 2 )
{
players [ 1 ] thread pistol_def_tp ( spots_p2 );
}
if ( people & gt ; = 3 )
{
players [ 2 ] thread pistol_def_tp ( spots_p3 );
}
if ( people == 4 )
{
players [ 3 ] thread pistol_def_tp ( spots_p4 );
}
}
}
function pistol_def_tp ( spots )
{
while ( 1 )
{
level waittill ( "end_of_round" );
self thread lui :: screen_fade_out ( 1 );
level waittill ( "start_of_round" );
loc = array :: random ( spots );
self SetOrigin ( loc . origin + ( 0 , 0 , 20 ) );
self SetPlayerAngles ( loc . angles );
self thread zm :: screen_fade_in ( 2 );
}
}
Nikon :
He forgot one " } "
function on_player_connect ()
{
spots_p1 = struct :: get_array ( "pistol_def_tp_spot_00" , "targetname" );
spots_p2 = struct :: get_array ( "pistol_def_tp_spot_01" , "targetname" );
spots_p3 = struct :: get_array ( "pistol_def_tp_spot_02" , "targetname" );
spots_p4 = struct :: get_array ( "pistol_def_tp_spot_03" , "targetname" );
players = GetPlayers ();
for ( q = 0 ; q & lt ; players . size ; q ++ )
{
people = players . size ;
if ( people & gt ; = 1 )
{
players [ 0 ] thread pistol_def_tp ( spots_p1 );
}
if ( people & gt ; = 2 )
{
players [ 1 ] thread pistol_def_tp ( spots_p2 );
}
if ( people & gt ; = 3 )
{
players [ 2 ] thread pistol_def_tp ( spots_p3 );
}
if ( people == 4 )
{
players [ 3 ] thread pistol_def_tp ( spots_p4 );
}
}
}
function pistol_def_tp ( spots )
{
while ( 1 )
{
level waittill ( "end_of_round" );
self thread lui :: screen_fade_out ( 1 );
level waittill ( "start_of_round" );
loc = array :: random ( spots );
self SetOrigin ( loc . origin + ( 0 , 0 , 20 ) );
self SetPlayerAngles ( loc . angles );
self thread zm :: screen_fade_in ( 2 );
}
}
Thanks man! It works just as I wanted it to!