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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.