I want to start creating some simple c# scripts, maybe with some GUI.
I don’t know how to make the server script communicate with the client script.
Do you have a simple c# script where I can understand the basics of creating a script for fivem?
This link shows you how to setup a client script, loading the client lib and exporting correctly.
Do you know how to reference the correct libs for client scripting and server scripting?
If not then please read my post on this thread here:
As for server scripts communicating to client scripts you just need to use
TriggerClientEvent("EVENTNAME", parameters);
and add the following in the client script constructor:
public class ClassName : BaseScript
{
public ClassName() // CONSTRUCTOR
{
// SUBSCRIBING TO EVENT (WHICH WILL CALL MethodNameToRun WHEN EVENT IS TRIGGERED)
EventHandlers["EVENTNAME"] += new Action< parameter type >(MethodNameToRun);
}
}
To do a server call it is just TriggerServerEvent(“EVENTNAME”) right enough for triggering server events, triggerclientevent can go in any method what so ever as well.