ihatetn931

Client Event Trigger

Recommended Posts

Posted (edited)

This is prolly a stupid question but how do you use csharp

onClientEventTrigger

these days, I've searched for several hours and gave up now a few days later here I am trying to figure it out again.

Edited by ihatetn931
typos

Share this post


Link to post
Share on other sites
Posted (edited)

Serverside:

NAPI.ClientEvent.TriggerClientEvent(client, "name_of_the_event");

Clientside:

// Constructor of some class.
public MyClass()
{
     RAGE.Events.Add("name_of_the_event", eventHandlerFunction); // eventHandlerFunction is just a placeholder name, you name it
     RAGE.Events.Add("name_another_event", anotherEventHandler);
}

public void eventHanderFunction(object[] args)
{
 	/*
     *	CODE TO EXECUTE WHEN THE EVENT GETS TRIGGERED
     */
  	Events.CallRemote("name_of_server_event"); // This is the way you trigger server events, from clientside
}

 

Example of Remote event (Called from client)

[RemoteEvent("name_of_server_event")]
public void functionHandlerName(Client client, int sex)
{
  	/*
	*	CODE TO EXECUTE ON TRIGGER
	*/
}

 

Hope this helps.

There are tutorials on this forum about this already ;)

Edited by Soul

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.