Jump to content

Recommended Posts

Hello, I created a character mod for DST. The character has a special blaster that requires batteries from the player's inventory, can cycle between lethal and stun, and can be upgraded as well.

 

All this works fine and dandy when I am testing, but only because I was the host. After getting a friend to start a server with my mod on it, the mod seems to only partially work. For one thing, my recipes and the like were working, but not blaster. 

 

Attached is my blaster's prefab. Right now, it fires irregardless of sufficient batteries, and on hit  it checks if there  are enough batteries. If there are, then it does damage, else, it will do nothing.

 

How do I make it work when the user is a client, and how can I fix other instances of this problem in my mod?

item_blaster.lua

For instance, the onattack_blaster only runs on the host.

Therefore, all the ThePlayer vars you have there reference the host.

 

Instead, you should do

local owner = inst.components.inventoryitem.owner

to get the entity wielding the gun on their inventory while attacking. The owner will be the player you want.

 

Then switch ThePlayer for owner.

 

Either that, or in the onequip and onunequip functions put

-- in onequip()inst.wielder = owner-- in onunequipinst.wielder = nil

so that you can access the entity that is wielding the gun.

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