Rozi Posted July 9, 2018 Share Posted July 9, 2018 Hello, so I just started scripting RageMP and I am using the bridge and C#. I wish to know how to properly use client-side scripting as there isn't much documentation about it. How would I properly go around and check when a player places a waypoint and relay the coordinates in the chat? Or for example when someone does a command, a notification will appear? Link to comment Share on other sites More sharing options...
FailerZ Posted July 9, 2018 Share Posted July 9, 2018 (edited) For clientside you need to use this event https://wiki.rage.mp/index.php?title=PlayerCreateWaypoint And to place it in chat you simply use https://wiki.rage.mp/index.php?title=Chat.push Example: mp.events.add("playerCreateWaypoint", (player, position) => { mp.gui.chat.push("You have placed a waypoint at " + position.x + ',' + position.y + ',' + position.z); }); For serverside commands in C# check this https://wiki.gtanet.work/index.php?title=Getting_Started_with_Commands Edited July 9, 2018 by FailerZ Link to comment Share on other sites More sharing options...
Rozi Posted July 9, 2018 Author Share Posted July 9, 2018 Just now, FailerZ said: For clientside you need to use this event https://wiki.rage.mp/index.php?title=PlayerCreateWaypoint And to place it in chat you simply use https://wiki.rage.mp/index.php?title=Chat.push Example: mp.events.add("playerCreateWaypoint", (player, position) => { mp.gui.chat.push("You have placed a waypoint at " + position.x + ',' + position.y + ',' + position.z); }); Thank you but I'm asking like how to do the client side stuff, I have no idea where to put the js files, how to call it in my C# code, etc. Link to comment Share on other sites More sharing options...
FailerZ Posted July 9, 2018 Share Posted July 9, 2018 (edited) 10 minutes ago, Rozi said: Thank you but I'm asking like how to do the client side stuff, I have no idea where to put the js files, how to call it in my C# code, etc. You need to open the client_packages inside the server-files then here open or create a file call it 'index.js' inside this file insert the scripts that you are going to use for example: require('./SomeScript.js'); Now create the SomeScript.js and it is now going to run clientside scripts inside. To send events from clientside to serverside use https://wiki.rage.mp/index.php?title=Events::callRemote and then inside your C# resource use https://wiki.gtanet.work/index.php?title=Getting_Started_with_Remote_Events to receive the function and the passed arguments, The other way around you do from your C# resource (Client).TriggerEvent() then you catch it inside your javascript file that you've just created by using the mp.events.add like you would when using any clientside event. Edited July 9, 2018 by FailerZ 2 Link to comment Share on other sites More sharing options...
Rozi Posted July 10, 2018 Author Share Posted July 10, 2018 10 hours ago, FailerZ said: You need to open the client_packages inside the server-files then here open or create a file call it 'index.js' inside this file insert the scripts that you are going to use for example: require('./SomeScript.js'); Now create the SomeScript.js and it is now going to run clientside scripts inside. To send events from clientside to serverside use https://wiki.rage.mp/index.php?title=Events::callRemote and then inside your C# resource use https://wiki.gtanet.work/index.php?title=Getting_Started_with_Remote_Events to receive the function and the passed arguments, The other way around you do from your C# resource (Client).TriggerEvent() then you catch it inside your javascript file that you've just created by using the mp.events.add like you would when using any clientside event. And what exactly would I go and write in the .js file? I tried: mp.events.add("playerCreateWaypoint", (player, position) => { mp.events.callRemote("Waypoint", position); }); But it didn't work Link to comment Share on other sites More sharing options...
FailerZ Posted July 10, 2018 Share Posted July 10, 2018 //JS Clientside mp.events.add("playerCreateWaypoint", (player, position) => { mp.events.callRemote("Waypoint", player, position); }); //C# Serverside [RemoteEvent("Waypoint")] public void OnPlayerPlaceWaypoint(Client player, Vector3 position) { player.SendChatMessage($"The player {player.Name} has placed waypoint on {position.X},{position.Y},{position.Z}"); } That's how you send the waypoint that a player placed from client to server Link to comment Share on other sites More sharing options...
Rozi Posted July 10, 2018 Author Share Posted July 10, 2018 4 minutes ago, FailerZ said: //JS Clientside mp.events.add("playerCreateWaypoint", (player, position) => { mp.events.callRemote("Waypoint", player, position); }); //C# Serverside [RemoteEvent("Waypoint")] public void OnPlayerPlaceWaypoint(Client player, Vector3 position) { player.SendChatMessage($"The player {player.Name} has placed waypoint on {position.X},{position.Y},{position.Z}"); } That's how you send the waypoint that a player placed from client to server Doing exactly that and it doesn't work Link to comment Share on other sites More sharing options...
FailerZ Posted July 10, 2018 Share Posted July 10, 2018 (edited) 35 minutes ago, Rozi said: Doing exactly that and it doesn't work Seems the playerCreateWaypoint event is not getting triggered, most likely ragemp issue Edited July 10, 2018 by FailerZ Link to comment Share on other sites More sharing options...
blake Posted July 10, 2018 Share Posted July 10, 2018 20 hours ago, Rozi said: Hello, so I just started scripting RageMP and I am using the bridge and C#. I wish to know how to properly use client-side scripting as there isn't much documentation about it. How would I properly go around and check when a player places a waypoint and relay the coordinates in the chat? Or for example when someone does a command, a notification will appear? Do you have the C# bridge installed? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now