SA-MP Forums

Go Back   SA-MP Forums > SA-MP > General

Reply
 
Thread Tools Display Modes
Old 22/10/2019, 04:59 PM   #1
keytruth
Little Clucker
 
Join Date: May 2019
Posts: 22
Reputation: 2
Question How does SA-MP work?

Hello everyone, I was wondering how SA-MP works? Please tell us how SA-MP, RakNet (Packages, etc.), client-server, etc. work.
What method does something change in the game? (SCM, Memory Addresses)

(It is advisable to give an answer in expanded form)
__________________
#saveDL

My creations:

keytruth is offline   Reply With Quote
Old 24/10/2019, 01:10 AM   #2
IllidanS4
Big Clucker
 
IllidanS4's Avatar
 
Join Date: Feb 2013
Posts: 197
Reputation: 275
Default Re: How does SA-MP work?

Well there's a lot of it, much more than a single forum post could provide. For detailed overview of the network protocol, you can look up the RakNet specification, and for the listing of RPCs and packet IDs, there are some in the source code of YSF.

The basic working of the networking model is simple. Each tick, the server reads all packets coming from the clients (a packet here is a whole single message) and processes them based on their ID. The ID can identify a player sync, vehicle sync, camera sync and others, and there is also a special type of packet called RPC.

The sync packets contain information like position, rotation, health etc. When they are received, the relevant fields are copied to the player structures in the server for later access via scripts. The whole sync packet is copied to another location in the player's data, and OnPlayerUpdate is called to determine whether the packet shall be re-sent to other players (in range). The true is returned there, the player is marked as "updated", telling the server to send this packet to other players.

RPCs (remote procedure calls) form a large set of packet "sub-IDs". They represent actions performed by the server that should be streamed to the players (or vice-versa). Some are broadcasted to all players, some are sent only to a single one. For example, the RPC caused by CreateObject is broadcasted to all people (informing them of a new object), while SetPlayerPos sends the RPC only to the targeted player (and when they are teleported, they send a sync packet with their new position).

The client works pretty much the same in this regard; it sends and receives packets which manipulate the game's entities in different ways. Some things are performed by manipulating memory, some by calling functions provided by the game, but I think all of them require understanding of memory addresses used by the game.

This is all I can provide now. It's from memory, so sorry for any mistakes.
__________________
You have stolen my dreams and my childhood, and you have stolen my sleep hours.
IllidanS4 is offline   Reply With Quote
Old 24/10/2019, 02:52 PM   #3
keytruth
Little Clucker
 
Join Date: May 2019
Posts: 22
Reputation: 2
Default Re: How does SA-MP work?

Quote:
Originally Posted by IllidanS4 View Post
Well there's a lot of it, much more than a single forum post could provide. For detailed overview of the network protocol, you can look up the RakNet specification, and for the listing of RPCs and packet IDs, there are some in the source code of YSF.

The basic working of the networking model is simple. Each tick, the server reads all packets coming from the clients (a packet here is a whole single message) and processes them based on their ID. The ID can identify a player sync, vehicle sync, camera sync and others, and there is also a special type of packet called RPC.

The sync packets contain information like position, rotation, health etc. When they are received, the relevant fields are copied to the player structures in the server for later access via scripts. The whole sync packet is copied to another location in the player's data, and OnPlayerUpdate is called to determine whether the packet shall be re-sent to other players (in range). The true is returned there, the player is marked as "updated", telling the server to send this packet to other players.

RPCs (remote procedure calls) form a large set of packet "sub-IDs". They represent actions performed by the server that should be streamed to the players (or vice-versa). Some are broadcasted to all players, some are sent only to a single one. For example, the RPC caused by CreateObject is broadcasted to all people (informing them of a new object), while SetPlayerPos sends the RPC only to the targeted player (and when they are teleported, they send a sync packet with their new position).

The client works pretty much the same in this regard; it sends and receives packets which manipulate the game's entities in different ways. Some things are performed by manipulating memory, some by calling functions provided by the game, but I think all of them require understanding of memory addresses used by the game.

This is all I can provide now. It's from memory, so sorry for any mistakes.
Thank you
__________________
#saveDL

My creations:

keytruth is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Host Linux not work // In local work ! Belengher Scripting Help 6 25/09/2017 12:22 PM
mysql login work, register work SAVE NOT WORK HELP ilepopivanov Scripting Help 10 12/04/2015 12:11 AM
Ticket key work And PayTicket key dont work. Admigo Scripting Help 1 26/03/2012 08:14 PM
My Server work on Windows and dont work on linux Justinlol Help Archive 10 14/08/2011 02:43 PM
should FS/GM that work with windows work on linux iggy1 Help Archive 4 01/06/2010 10:53 AM


All times are GMT. The time now is 03:06 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.