Sign in to follow this  
Bodymenn

C# Bridge Trigger .js Client Package?

Recommended Posts

Hey guys , is it possible to trigger a Client Package Function with a C# Brdige Command? 
 

C# Bridge

        [Command("command")]
        public void command(Client player, String color)
        {
            //THE CALL TO .js CLIENT PACKAGE?
        }

JS Client Package

function test(test, color) {

}


I hope u guys know what i mean :3

Share this post


Link to post
Share on other sites

You should create an event on clientside which triggers your function when you call it. Also, you can call it using "TriggerEvent" on the serverside.

JS Client Side:

mp.events.add("TEST_EVENT", (test, color) => test(test, color));
        [Command("command")]
        public void command(Client player, String test, String color)
        {
            player.TriggerEvent("TEST_EVENT", test, color); //You can use it as an OOP method
        }

If you need more information about these functions, you can check links below:

https://wiki.gtanet.work/index.php?title=TriggerClientEvent

https://wiki.rage.mp/index.php?title=Events::add

Edited by Original
  • Like 1

Share this post


Link to post
Share on other sites

i tried , but nothing happend.

 

mp.events.add("TEST", (player, color) => {
        player.outputChatBox("Test");
});
        [Command("test")]
        public void Test(Client player, int color)
        {
            player.TriggerEvent("TEST", player, color);
        }

 

Edited by Bodymenn

Share this post


Link to post
Share on other sites

"outputChatBox" is a Node server-side function you cannot, use it on client side. For sending a text message to a player on client side you can use : mp.gui.chat.push("text");

Edited by Original
  • Like 1

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.