Jump to content

Spawning a pistol fully loaded, spawning an item multiple times


Anathema

Recommended Posts

So here's the deal, I made some basic starter kits based on the occupation, but I'd like to be able to do things like spawning the pistol fully loaded as opposed to giving the player a handful of rounds to load manually (unsuccessful attempt below). Something else I've been wondering, is there a more elegant way of spawning an item multiple times? (see burgerflipper)

 

Spoiler

function GiveOccupationItems(player,square)
	local profession = player:getDescriptor():getProfession();
	
	if profession == "fireofficer" then
	player:getInventory():AddItem("Base.Axe");	
	
	elseif profession == "policeofficer" then
		local firearm = player:getInventory():AddItem("Base.Pistol");
		firearm.setClipSize(15);
		player:getInventory():AddItem("Base.Torch");

	--snip

	elseif profession == "burgerflipper" then
		player:getInventory():AddItem("Base.Pan");	
		player:getInventory():AddItem("Base.Pop");	
		player:getInventory():AddItem("Base.Pop");	
		player:getInventory():AddItem("Base.Pop");	

	--snip

	end

end

Events.OnNewGame.Add(GiveOccupationItems)

 

I've already tried my best in finding a solution for both, but I've come up with nothing. Most people just seem to resort to the more simple and crude solutions. Thank you in advance.

Link to comment
Share on other sites

So far I've figured out spawning an item multiple times:

Spoiler

	elseif profession == "burgerflipper" then
		player:getInventory():AddItem("Base.Pan");	
		player:getInventory():AddItems("Base.Pop", 2);		

 

I'd still like to know how to spawn a pistol with a full magazine inside it.

Link to comment
Share on other sites

  • 5 weeks later...

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
×
×
  • Create New...