nedaso

Server-side and client-side?

Recommended Posts

Hello.

Back in the day I used to script SA-MP servers which used PAWN language which was pretty basic, one file for the gamemode.

 

I recently came across ragemp and the possibilities seem endless. However, I'm confused by this different sides of scripting. I was looking at the wiki and, for example, server-side functions contained stuff with vehices and client-side functions contained even more stuff with vehicles. What is the difference between those? Does that mean that server-side is everything that is related to the server and client-side has to target every player? Like if I want to change the vehicle color, which function do I even use?

 

Thanks for all answers, I'm new to this so this will probably sound stupid.

Share this post


Link to post
Share on other sites

Hi,

 

The client side means the game of the player, and each player has the client side u created.

Then for example you can tell X player to do a action like can't do basic ATTACKS (punch/fist) 

mp.game.controls.disableControlAction

, and only this player will not be able to do that. The client side of other players is not influenced by this. 

 

To summary:

- Each player download the client side you created, but each client side is independant.

- The server side tell the client side of a player (or all if you want) to do action, to edit player, show CEF (Chromium Browser)...

- The client side edits the player's gameplay.

 

So no, client side doesn't target every player at once. It depends on your serverside, but yes server side is pretty all things that is about server.

PS: if you want to all the players to call a function in client side use this:

mp.players.forEach(player => {
	player.call("MY FUNCTION", [args1, args2]);
}

 

 

To answer the changing color of a vehicle, you have 2 solutions (Server side only):

- If it is by a command, you get the datas of the vehicle by doing 

data = player.vehicle

And then you edit the vehicle color by:

data.setColor(int color1, int color2); // first color1 is primary color, then the second is the secondary :)

And here is the code for vehicle colors:

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

- Or you have already the vehicle data in a variable, and you pretty just do the same with the variable's name

 

Also, refer to the wiki they indexed everything, starting by basic development:

https://wiki.rage.mp/index.php?title=Getting_Started_with_Development#Creating_your_first_resource

 

Hope it helped you.

Edited by Protocole

Share this post


Link to post
Share on other sites
1 hour ago, Protocole said:

Hi,

 

The client side means the game of the player, and each player has the client side u created.

Then for example you can tell X player to do a action like can't do basic ATTACKS (punch/fist) 

mp.game.controls.disableControlAction

, and only this player will not be able to do that. The client side of other players is not influenced by this. 

 

To summary:

- Each player download the client side you created, but each client side is independant.

- The server side tell the client side of a player (or all if you want) to do action, to edit player, show CEF (Chromium Browser)...

- The client side edits the player's gameplay.

 

So no, client side doesn't target every player at once. It depends on your serverside, but yes server side is pretty all things that is about server.

PS: if you want to all the players to call a function in client side use this:

mp.players.forEach(player => {
	player.call("MY FUNCTION", [args1, args2]);
}

 

 

To answer the changing color of a vehicle, you have 2 solutions (Server side only):

- If it is by a command, you get the datas of the vehicle by doing 

data = player.vehicle

And then you edit the vehicle color by:

data.setColor(int color1, int color2); // first color1 is primary color, then the second is the secondary :)

And here is the code for vehicle colors:

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

- Or you have already the vehicle data in a variable, and you pretty just do the same with the variable's name

 

Also, refer to the wiki they indexed everything, starting by basic development:

https://wiki.rage.mp/index.php?title=Getting_Started_with_Development#Creating_your_first_resource

 

Hope it helped you.

Thank you, it helped a lot!

 

However I'm still confused about the two functions to change the vehicle color.

If vehicle.setColor is a server-side function, why is there a vehicle.setColours function and what does it do? Does it change the vehicle color for one player only?

 

Share this post


Link to post
Share on other sites
1 hour ago, nedaso said:

Thank you, it helped a lot!

 

However I'm still confused about the two functions to change the vehicle color.

If vehicle.setColor is a server-side function, why is there a vehicle.setColours function and what does it do? Does it change the vehicle color for one player only?


 

If you use that, then only that player will see the color change, unless you then send that data to the server and set it for everyone else.

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

  • Recently Browsing   0 members

    No registered users viewing this page.