Hello there,
There was a place where I explained how ClientSide and ServerSide can be optimized before.
but I thought my explanation was insufficient and I opened this issue.
What is the Event of the Optimization We Will Do?: We will use the code or code blocks for optimization of triggers such as distance / action / event that we set. In short, we will activate the code due to the event.
How is it done? ;
In the example you will see, I will use the optimization on the "DrawMarker" Nativesi.
DrawMarker natives heavily influences remon values
I will implement my method using distance. If the client (client) is at a certain distance from the location of the Marker, I will delete the Marker.
First, I will use the local operator to help me write my codes. PlayerPedId() or GetPlayerPed(-1) represents the player
but the texts are too long and it bothers me. I opened the Client Script (file) that I will optimize and clicked on the top line.
I'm posting your code...
Important : PlayerPedId() updates itself as the player enters, but GetPlayerPed(-1) means like no limit player, so definitely use PlayerPedId() (not much difference)
As I said, we were going to optimize DrawMarker (creating markers).
**DrawMarker is a native used in loop, otherwise it won't work**
Inside the loop where DrawMarker is located
I'm posting your code. It takes the coordinates of the players on the server.
!! And I am writing a code above the line where DrawMarker is located.
(( after playerLoc.<data> ".", we reach the data we want to receive in playerLoc, the "20" at the end represents the distance in meters))
and we add "end" under DrawMarker.
You can review the parameters of GetDistanceBetweenCoords Natives
Other Examples:
Let's use something other than "distance" this time...
For example, if the player presses the "X" Key, the Marker will be created. We will use the IsControlPressed Native for this
First of all, we need to reach the INDEX,
Thinking that you understand the logic of doing it fast, I will give an example directly.
Now the Marker is created when the "X" key is used.
There are too many examples that could be given. I think what I have given will make you understand the logic of Optimization.
If you have anything on your mind, feel free to share it in the comments.
Good Day Good Forums...
There was a place where I explained how ClientSide and ServerSide can be optimized before.
but I thought my explanation was insufficient and I opened this issue.
What is the Event of the Optimization We Will Do?: We will use the code or code blocks for optimization of triggers such as distance / action / event that we set. In short, we will activate the code due to the event.
How is it done? ;
In the example you will see, I will use the optimization on the "DrawMarker" Nativesi.
DrawMarker natives heavily influences remon values
I will implement my method using distance. If the client (client) is at a certain distance from the location of the Marker, I will delete the Marker.
First, I will use the local operator to help me write my codes. PlayerPedId() or GetPlayerPed(-1) represents the player
but the texts are too long and it bothers me. I opened the Client Script (file) that I will optimize and clicked on the top line.
Code:
local player = PlayerPedId()
I'm posting your code...
Important : PlayerPedId() updates itself as the player enters, but GetPlayerPed(-1) means like no limit player, so definitely use PlayerPedId() (not much difference)
As I said, we were going to optimize DrawMarker (creating markers).
**DrawMarker is a native used in loop, otherwise it won't work**
Inside the loop where DrawMarker is located
Code:
local playerLoc = GetEntityCoords(player)
I'm posting your code. It takes the coordinates of the players on the server.
!! And I am writing a code above the line where DrawMarker is located.
C++:
if GetDistanceBetweenCoords(playerLoc.x, playerLoc.y, playerLoc.z, 1011.34, -692.64, 56.97, true) < 20 then
(( after playerLoc.<data> ".", we reach the data we want to receive in playerLoc, the "20" at the end represents the distance in meters))
and we add "end" under DrawMarker.
You can review the parameters of GetDistanceBetweenCoords Natives
Hidden link for visitors, to see
Log in or register now.
Other Examples:
Let's use something other than "distance" this time...
For example, if the player presses the "X" Key, the Marker will be created. We will use the IsControlPressed Native for this
First of all, we need to reach the INDEX,
Hidden link for visitors, to see
Log in or register now.
that is, the Button code of the "X" Key.
Hidden link for visitors, to see
Log in or register now.
to browse native in parametersThinking that you understand the logic of doing it fast, I will give an example directly.
Now the Marker is created when the "X" key is used.
There are too many examples that could be given. I think what I have given will make you understand the logic of Optimization.
If you have anything on your mind, feel free to share it in the comments.
Good Day Good Forums...