Sign in to follow this  
Rozi

Issues with client-side scripting.

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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 by FailerZ

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 by FailerZ
  • Like 1

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
//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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 by FailerZ

Share this post


Link to post
Share on other sites
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?

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.