#hodor

1 messages · Page 1 of 1 (latest)

tropic salmon
#

Is there a reason you want to call the action from script instead of using the door component directly?

Also if you would use the action the persistence from my framework there is already taken care of as I mod the vanilla user action. But that's just a fun fact on the side.

tribal shuttle
#
            IEntity doorEntity = GetOwner().GetWorld().FindEntityByName(door);
            Print(doorEntity);
            DoorComponent doorComponent = DoorComponent.Cast(doorEntity.FindComponent(DoorComponent));
            Print(doorComponent);
            if (doorComponent)
            {
                vector doorOpeningVecWS = doorEntity.VectorToParent(vector.Forward);
                if (doorComponent.GetAngleRange() < 0.0)
                    doorOpeningVecWS = -1.0 * doorOpeningVecWS;
                float controlValue = 1.0;
                float currentState = doorComponent.GetDoorState();
                if ((currentState <= 0.0)  || (currentState < 0.0))
                    controlValue = -1.0;
                if (Math.AbsFloat(doorComponent.GetControlValue()) > 0.5)
                    controlValue = 0.0;
                doorComponent.SetControlValue(controlValue);
                doorComponent.SetActionInstigator(doorEntity);
                Replication.BumpMe();
            }
#

doesn't work outside of the Workbench and only clientside which is where I'm stuck atm I've tried using replication to trigger it on the client/server and just calling it without doing that

#

The aim is to have a Button entity essentially open two doors at the same time and then after a set amount of time close them for a map I am building, Currently I have a UserAction for the button entity which triggers the ScriptedComponent that is attached to a GenericEntity that has the doors and the button in it's children It's a bit complicated

tropic salmon
#

When you have the target door component, all you need to do is SetActionInstigator(playerEntity) and to open SetControlValue(1.0) - BUT this needs to be done on the authority(server). In workbench it works because you are both client and server, but outside of it it won't. The user actions are automatically network replicated but only if they are used in their intended setup though the action manager.

If your action should be triggered from UI this likely means this is client side only? In which case you will need to create a component on your character prefab to send an RPC to the server, probably with the target entity that has your doors as argument (via RplId) and have the server do the door component calls.
This sound all spooky at first, but its not that hard. Go step by step.

First you want to be able to send a hello world rpc from when you press your button to arrive on the server. We need to put this on the character because a client can only send rpcs for things he has network ownership for. So your own character entity is the most simple one. https://community.bistudio.com/wiki/Arma_Reforger:Multiplayer_Scripting

#

Goal is button press -> rpc through char to server -> rpc argument says which entity -> on server find entity by rplid -> find door components -> call door component methods -> queue close actions for later (maybe through CallLater) -> doors opening will replicate back from server to all clients

tribal shuttle
#

Honestly this is very new to me, I'm used to net calls and specific serverside/clientside code so I apologise if I sounded dumb before because I kinda am when it comes to this but still it's really interesting

#

I'll give that a shot now

tropic salmon
#

Feel free to ask when you get stuck somewhere and you can't find a usage example in vanilla scripts or on the page I linked you 🙂

tribal shuttle
#

I can't seem to get the owner to pass it exists but when I try to FindId it returns -1

tropic salmon
#

you do not need to send the user, it will be the owner of the character component from where you sent the rpc

#

Also a bit more context for the code please, i do not know where you call this own

tribal shuttle
#

was being called via the useraction on the button it tried both GetOwner() and the pOwnerEntity which returns the button but when grabbing the ID returns -1

tropic salmon
#

check if the parent even has a replication component

tribal shuttle
#

all the siblings and parent have replication components and hierarchy components

#

This is the parent and button

#

one of two doors within the same parent

#

Could it be related to how the client side works with the UI? Since the pOwnerEntity seems to return the Button entity but any attempt to lookup the Replication ID fails

tropic salmon
#

where is the button returned?

#

powner is the entity where the action is on

#

puser is the person that executes the action

tribal shuttle
#

The button is the entity with the action script

tribal shuttle
#

Weird thought might be the entity type

#

as in a GenericEntity won't stream so it could be that

tribal shuttle
#

creating a custom entity with this seems to initialise it on the server allowing the RplId to transition across

tribal shuttle
#

I've gotten it to pass the RplIds but it's not replicating still

#

it's logging correctly just not activating the door

#

It's definitely updating the door but not triggering not sure what I can do

tribal shuttle
#

Solved it the doors themselves had to be genericentities and I had to pull the children from the custom entity that was replicated