Preventing a player from bearing arms
Preventing a player from bearing arms
How could I stop a player from arming themselves? I've noted the events for when a player has changed their gun or ammo inventories, but the events seem to occur after the changes, I.e. After they have added a gun or ammo.
Re: Preventing a player from bearing arms
Hmm, I'm guessing I can get the player's gun/ammo inventory when this event occurs and return it to their main inventory. I'll try that.
-
- Filter Inserter
- Posts: 841
- Joined: Mon Sep 14, 2015 7:40 am
- Contact:
Re: Preventing a player from bearing arms
Here's an old approach of mine I used a while back: https://github.com/Suprcheese/Satellite ... #L102-L108
Re: Preventing a player from bearing arms
Thanks. I have something that works now. This code returns any gun that a player tries to arm themselves with back to their main inventorySupercheese wrote:Here's an old approach of mine I used a while back: https://github.com/Suprcheese/Satellite ... #L102-L108
code
Do you have any idea what event goes off when ammo is placed in a tank or car or artillery turret please?- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Preventing a player from bearing arms
All factorio events fire after something happens.
A quick look at your code looks like it'll delete any guns that are still in the gun inventory if the player inventory is full. I.e. if a player with an already full inventory takes a gun out of a chest.
A quick look at your code looks like it'll delete any guns that are still in the gun inventory if the player inventory is full. I.e. if a player with an already full inventory takes a gun out of a chest.
No events are ever fired for changes to inventories other than the player inventory. You're only chance would be cursor_stack_changed i guess. But then again one can just build an inserter next to the tank and put the item on the ground for it to be grabbed :PDRY411S wrote: Do you have any idea what event goes off when ammo is placed in a tank or car or artillery turret please?
Re: Preventing a player from bearing arms
Wouldn't it be easier to simply mod out weapons and guns out of vehicles?
Re: Preventing a player from bearing arms
Thanks. I'll check that edge case. I was expecting the gun to be tossed on the ground, like when players mine things when their inventory is full, or change armor to one where there are less inventory slots.eradicator wrote:<snip>
A quick look at your code looks like it'll delete any guns that are still in the gun inventory if the player inventory is full. I.e. if a player with an already full inventory takes a gun out of a chest.
OK. I'm thinking I'll try emptying the ammo from a vehicle's guns when the player enters it, (if they are the only occupant, or the passenger), or maybe see what affects removing the permission to change shooting stance has.eradicator wrote: No events are ever fired for changes to inventories other than the player inventory. You're only chance would be cursor_stack_changed i guess. But then again one can just build an inserter next to the tank and put the item on the ground for it to be grabbed
The emptying when they enter idea doesn't take care of what may happen if they then add ammo after they've entered the vehicle.
If none of those ideas work I may may need to redefine the 'bear arms' concept to be personal firearms only.
Last edited by DRY411S on Wed Apr 11, 2018 5:48 pm, edited 1 time in total.
Re: Preventing a player from bearing arms
Fair point, but this is for a role-based scenario concept, where only certain roles can fire weapons.orzelek wrote:Wouldn't it be easier to simply mod out weapons and guns out of vehicles?
Re: Preventing a player from bearing arms
Edge case failed. Gun disappears into the ether as you suspected.
Now looking at at setting the player's shooting state to 'not shooting' and removing the permission to change it, as a workaround.
Now looking at at setting the player's shooting state to 'not shooting' and removing the permission to change it, as a workaround.
Re: Preventing a player from bearing arms
You could make a blank not working gun and set that as equipped.
You would still have to test if someone were to remove/replace it, but then that edge case shouldn't happen.
As an added bonus, shiftclicking will not equip a gun.
I would also check if gun inventory amount is part of the player prototype, if it is you could add a player entity without any gun slots.
You would still have to test if someone were to remove/replace it, but then that edge case shouldn't happen.
As an added bonus, shiftclicking will not equip a gun.
I would also check if gun inventory amount is part of the player prototype, if it is you could add a player entity without any gun slots.
Re: Preventing a player from bearing arms
Been away from this for a while but now have a fix for that. The items get spilled on the ground.eradicator wrote:A quick look at your code looks like it'll delete any guns that are still in the gun inventory if the player inventory is full. I.e. if a player with an already full inventory takes a gun out of a chest.
New code