Time for action – Using the client function
Now we're ready to write the client function and call it from the server.
Make sure that the game and the server are shut down.
Open
AwesomePawn
in ConTEXT.We're going to write our client function now:
reliable client function CallTheClient() { `log("Reliable client function called!"); }
One thing to note is that these modifiers go together; you can't have a client function without specifying whether it's reliable or unreliable. If you try, the compiler will give you an error.
Now that we have that function written, we need to call it from our
OnToggle
function:function OnToggle(SeqAct_Toggle InAction) { `log("I have been toggled!"); CallTheClient(); }
Now let's see what happens. Compile the code, then run the server and the game. Run over to the trigger.
We'll see this log show up on the server:
[0015.35] ScriptLog: I have been toggled!
And we'll see this log show up on the client:
[0009.81] ScriptLog: Reliable client function called!
We'll notice...