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); }
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(&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 functionfunctionon_player_connect()//paste the rest at the bottom of your script{spots_p1=struct::get_array("pistol_def_tp_spot_00","targetname");//Player1 Tp spotsspots_p2=struct::get_array("pistol_def_tp_spot_01","targetname");//Player2 Tp spotsspots_p3=struct::get_array("pistol_def_tp_spot_02","targetname");//Player3 Tp spotsspots_p4=struct::get_array("pistol_def_tp_spot_03","targetname");//Player4 Tp spotsplayers=GetPlayers();for(q=0;q<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>=1){players[0]threadpistol_def_tp(spots_p1);}if(people>=2){players[1]threadpistol_def_tp(spots_p2);}if(people>=3){players[2]threadpistol_def_tp(spots_p3);}if(people==4){players[3]threadpistol_def_tp(spots_p4);}}functionpistol_def_tp(spots){while(1){levelwaittill("end_of_round");selfthreadlui::screen_fade_out(1);levelwaittill("start_of_round");loc=array::random(spots);selfSetOrigin(loc.origin+(0,0,20));selfSetPlayerAngles(loc.angles);selfthreadzm::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(&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 functionfunctionon_player_connect()//paste the rest at the bottom of your script{spots_p1=struct::get_array("pistol_def_tp_spot_00","targetname");//Player1 Tp spotsspots_p2=struct::get_array("pistol_def_tp_spot_01","targetname");//Player2 Tp spotsspots_p3=struct::get_array("pistol_def_tp_spot_02","targetname");//Player3 Tp spotsspots_p4=struct::get_array("pistol_def_tp_spot_03","targetname");//Player4 Tp spotsplayers=GetPlayers();for(q=0;q<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>=1){players[0]threadpistol_def_tp(spots_p1);}if(people>=2){players[1]threadpistol_def_tp(spots_p2);}if(people>=3){players[2]threadpistol_def_tp(spots_p3);}if(people==4){players[3]threadpistol_def_tp(spots_p4);}}functionpistol_def_tp(spots){while(1){levelwaittill("end_of_round");selfthreadlui::screen_fade_out(1);levelwaittill("start_of_round");loc=array::random(spots);selfSetOrigin(loc.origin+(0,0,20));selfSetPlayerAngles(loc.angles);selfthreadzm::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.