Modme Forums
Menu:

Allow players to pick a starting pistol every game

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


ModmeBot:

Thread By: Sylvacre
I had trouble deciding which starting pistol I wanted to use in my map, so I instead created a script to allow the player to decide for themselves!
This script currently only allows for 2 options. It gives the player 10 seconds, then takes away whichever gun they aren't holding.

Instructions:

Open your mapname.gsc located in (Call of Duty Black Ops III\usermaps\map_name\scripts\zm)

At the top, somewhere within main, add this line and replace the text in quotes with the name of the second weapon you want as an option:

level thread choose_pistol("t7_pistol_m1911");

Then, at the bottom, add this function:

function choose_pistol(secondWep)
{
	level flag::wait_till( "initial_blackscreen_passed" );
	players = GetPlayers();
	secondary = GetWeapon(secondWep);

	foreach(player in players)
		player GiveWeapon(secondary);
		
	IPrintLnBold("Choose your starting pistol. The other will disappear in 10 seconds.");
	wait(7);
	for(i=3;i>0;i--)
	{
		IPrintLnBold(i+"");
		wait(1);
	}
	foreach(player in players)
	{
		choice = player GetCurrentWeapon();
		ammo_clip = player GetWeaponAmmoClip(choice);
		ammo_fuel = player GetWeaponAmmoFuel(choice);
		ammo_stock = player GetWeaponAmmoStock(choice);
		player TakeAllWeapons();
		player GiveWeapon(choice);
		player giveWeapon( level.weaponBaseMelee );
		player SetWeaponAmmoClip(choice,ammo_clip);
		player SetWeaponAmmoFuel(choice,ammo_fuel);
		player SetWeaponAmmoStock(choice,ammo_stock);
		level thread zm::award_grenades_for_survivors(); 
	}
	IPrintLnBold("Starting pistol locked in.");
}


Done!
When you load into your map it will give you your "second" weapon alongside your normal starting pistol and after 10 seconds will take away the one you aren't holding.


Disclaimer: I am by no means an experienced scripter and it's very possible there's a better way to make this script so if anyone has suggestions for how it can be made better I'm open to hearing them. I would think there's probably a better way to do the last part of the script in particular, but I tried many different things and wasn't able to figure out a "better" way.


ModmeBot:

Reply By: Wild
This is awesome, great tutorial!


ModmeBot:

Reply By: Azazel
oh my god thank you!!! i was literally thinking about this because i want to have all of the pistols from WAW - IW


ModmeBot:

Reply By: Sylvacre
Glad to help :)