Jump to content

Spawning an object through using/firing a weapon?


MrCakehat

Recommended Posts

Hey all, I am wondering how I would go about spawning an object, say for example a box or a barrel or whatever, when the player fires a specific weapon?

What I'm thinking of is just messing around with something the player can equip, which will "Auto-create" something else, maybe a box, or another weapon or something, when the equipped weapon is fired, how would I go about starting to do something like that?

Link to comment
Share on other sites

It depends on what "spawning" means to you.

 

If you want a new item in the inventory after the weapon is fired then you could use the "OnWeaponHitCharacter" event and "AddItem" to spawn stuff in the player's inventory when he hits something. If you want it to happen when he uses the weapon the event "OnWeaponSwing" would be your friend.

 

For more events check out the event reference on pz-mods.net.

 

If you want to spawn a world object ... then well you should look at some of the carpentry code :)

Link to comment
Share on other sites

I just updated my tutorial and included a small part on how to use events.

 

There should be a method to drop items directly on the ground (what's used when cutting down a tree for example) but I'm not sure which one it is right now. I'll see if I can find out later :)

 

P.S.: May I make a guess? Will your mod spawn empty shells on the ground when shooting a pistol? :)

Link to comment
Share on other sites

Thanks for that, It's a bit better to understand

haha yeah something like that, and also the objects, or shells or whatever would also have a life time and be removed. I was just going to use this as a practice mod for myself, then expand it use it on an idea I've got

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