Jump to content

Help me


MaurO^

Recommended Posts

Hi, I'm new here, let's say I've learned a lot but what I still have trouble understanding is the deference between creating a client script or server, if I create a marker in client, only I will see it and the other players will not? creating a warp system and this bothers me a lot

Link to comment
  • Scripting Moderators

The difference between server and client scripts is obvious.

Server Scripts are loaded by MTA Server, it can affect all players.

Client Scripts are loaded by Player's MTASA application, it can only affect the play who load the script (except some functions that will sync data to server).

The best explanation is the sync system.

Server --Sync To--> Client

Client --Sync To--> Server

In this way, data can be exchanged from server to client or from client to server.

Whether you will see something have an effect on other players depends on whether the data is exchanged.

Link to comment

I'm not good at explaination. But, let's see..

If you make marker on client side, other player can't see your marker. But, they can see their own marker.

Example:

-- file name client.lua
-- client side code

createMarker( 0, 0, 0) -- this marker automatically created when client script started.
-- marker position is on the center of gta world

By doing that, you are the only one who can see that marker, other player can't see your marker, but they have their own marker. Your marker and other player's marker is a different element.

But if you make it on server side. You and other players are seeing the same marker, because element that created on server side will sync to all clients.

Let's make another example code using command

-- client side code

function giveMeMarker()
	local x, y, z = getElementPosition(localPlayer)
	createMarker(x, y, z)
end
addCommandHandler("givememarker", giveMeMarker)

If you type "givememarker", it will create marker on your position, other players can't see it, but if they type that command, they have marker on their position, you cant see their marker.

So, element created on server will sync to all players, but element created on client, it won't sync to other players.

 

Link to comment
1 hour ago, idarrr said:

No soy bueno en la explicación. Pero, veamos ...

Si marcas el marcador en el lado del cliente, el otro jugador no puede ver tu marcador. Pero, puede ver su propio marcador.

Ejemplo:





    

Al hacer eso, eres el único que puede ver ese marcador, el otro jugador no puede ver tu marcador, pero tienen su propio marcador. Tu marcador y el marcador de otro jugador es un elemento diferente.

Pero si lo haces en el servidor. Usted y otros jugadores están viendo el mismo marcador, porque el elemento que se creó en el servidor se sincroniza con todos los clientes.

Vamos a hacer otro código de ejemplo usando el comando





	 
	


Si escribe "givememarker", crea un marcador en tu posición, otros jugadores no podrán verlo, pero si teclean este comando, tienen un marcador en su posición, no puedes ver su marcador.

Por lo tanto, el elemento creado en el servidor se sincroniza con todos los jugadores, pero el elemento creado en el cliente no se sincroniza con otros jugadores.

 

 

- If I use setElementPosition on the client side when going to x zone, will the players see me when I go to x zone? or will I just see myself?

Edited by Xero~
Link to comment
57 minutes ago, IIYAMA said:

Todos (con un retraso), porque están transmitiendo su posición / rotación al servidor.

Te recomiendo que hagas eso en el servidor debido a la demora.

Si haces eso con un objeto, no se sincronizará.

 

 
 
 
 
 
7/5000
 
Thank you
 
 
 
 
Sugerir un cambio
 
 
 
 
57 minutes ago, IIYAMA said:

Everybody(with a delay), because you are streaming your position/rotation to the server.

I do recommend you to do that serverside because of the delay.

If you do that with an object, it will not be synced.

 

Thank you!

Link to comment

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.
×
×
  • Create New...