Jump to content
Banjo

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

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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Posted (edited)

Thanks so much for that!

 

How do I get "z" co-ordinates (presumably height)? I used RoboMat's co-ordinates viewer to get x and y.

Edited by Banjo

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...