Jump to content

Is it possible to spawn inventory items based on map choice or spawn point?


Banjo

Recommended Posts

Is there a way to have an item spawn in the player's inventory *only* if they select a certain map when starting (for example, a map of Rosewood when starting in Rosewood) or for a specific spawn point (say, they key to the prison when spawning inside the prison).

I can do this based on traits or professions, but I have no idea what code to use to make it start spawn dependant! I presume you can't set it by spawn point (i.e. the house you randomly start it) as that would be even better, but I'm assuming doing this by map choice - or even better, spawn point - is possible?

For traits, it's:
if player:HasTrait("traitnamehere") then
player:getInventory():AddItem("Base.itemnamehere");
...right?

But does anyone know if (and how) this is possible if I wanted to give a key or weapon only to someone who starts in Rosewood or only spawns in the mall?
Link to comment
Share on other sites

I'd simply do this:

- take the area's coordinates from blindcoder's map

- check if the player's position is in that area when he spawns

- then use modData to check if he's already received the items, kinda like this:

 

if not player:getModData().startingItems then

  player:getInventory():AddItem("Base.itemnamehere")

  player:getModData().startingItems = true

end

 

Maybe there's a smarter way, but this should do the trick.

Link to comment
Share on other sites

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...