would be happy to know if theres a method / hook for that .
i tried
void OnStructureRotate(BaseCombatEntity entity, BasePlayer player)
{
doesnt work..
Block vending machine rotation?
Discussion in 'Rust Development' started by Crushed, Mar 3, 2017.
-
No, there's not a hook for it. The only way to prevent rotation is to put items in it or building block it.
-
@Crushed
I found a way, but its hacky.
1. Create a Dictionary to save a VendingMachine + the placement rotation
Code:Dictionary<VendingMachine, Quaternion> vendings = new Dictionary<VendingMachine, Quaternion>();
Code:void OnEntityBuilt(Planner plan, GameObject gameObject) { VendingMachine vending = gameObject.GetComponent<VendingMachine>(); if(vending != null) { vendings.Add(vending, vending.transform.rotation); } }
Code:void OnTick() { foreach(var vending in vendings) { if(vending.Key.transform.rotation != vending.Value) { vending.Key.transform.rotation = vending.Value; vending.Key.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); } } }
This is not the best way to do it. It's just a quick example how to achieve the "rotation block".
Improvements would be to check only one vendingMachine per tick (to keep the "check" impact low), delete the VendingMachine from the dictionary if it doesn't exist anymore, save and load vendingmachines on server start/stop, etc.
Greetings,
BlackangesLast edited by a moderator: Mar 3, 2017 -
Wulf Community Admin
Latest snapshot has a hook for this.
OnRotateVendingMachine(VendingMachine vending, BasePlayer player)
Return anything other than null to block it. -
HAH! awesome. Thanks Mr. wulf!
i assume the Oxide Docs ...are not completed?` i feel like theres nothing thats being added.... -
Wulf Community Admin