grimmsdottir Posted May 15, 2015 Share Posted May 15, 2015 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 Link to comment https://forums.kleientertainment.com/forums/topic/54027-how-to-make-a-mod-work-when-it-is-a-client/ Share on other sites More sharing options...
DarkXero Posted May 16, 2015 Share Posted May 16, 2015 For instance, the onattack_blaster only runs on the host.Therefore, all the ThePlayer vars you have there reference the host. Instead, you should dolocal owner = inst.components.inventoryitem.ownerto 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 = nilso that you can access the entity that is wielding the gun. Link to comment https://forums.kleientertainment.com/forums/topic/54027-how-to-make-a-mod-work-when-it-is-a-client/#findComment-637914 Share on other sites More sharing options...
grimmsdottir Posted May 16, 2015 Author Share Posted May 16, 2015 Oh, thanks man, I had absolutely no idea it was so easy to get the instance of the user, which is why I was using ThePlayer, which in hindsight was a terrible idea. I'll be sure to fix my code. Link to comment https://forums.kleientertainment.com/forums/topic/54027-how-to-make-a-mod-work-when-it-is-a-client/#findComment-637920 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now