[Tutorial] How to launch the SA:MP client
#1

Launching the SA-MP client

This is a tutorial dedicating to "remotely" launching the SA:MP client. Basically, this isn't for any dedicated languages but rather a generalization for various languages such as C# and VB; general coding languages.

Launching the game using parameters in samp.exe

Before we go any further, it's important to know that the players name is depedent on whats stored in their registry key. So, it may be a good idea to check if it's set. This is generally done by checking if a value exists / the registry key exists:

HKEY_CURRENT_USER/Software/SAMP - "PlayerName"

The same goes for the gta_sa executable. How-ever, this is stored as gta_sa_exe. Note; that it is not the samp.exe exe that is stored but the gta_sa.exe. You should how-ever be able to replace the end "gta_sa.exe" part with SAMP to get the general path of where a SA:MP installation is.

So samp.exe has some very basic params:

ServerIP:
Port:

AFAIK, the port param is not required. It will default to 7777 although I could be wrong on this. So, for example:

Let's launch our localhost:
samp.exe 127.0.0.1 7777

This will open the SA:MP client, and connect us to 127.0.0.1:7777 as we have given such params. Remember; the player name is dependent on what is in the registry key; so if your making a custom client make sure the player's name is set properly before launching. This is just like launching it from the client; so the same restrictions, etc, will of-course apply.

Update: samp.exe is very smart, and can actually connect to servers using three different formats. The first as shown above is simply IP space Port. The other methods are as follows,


IP:PORT


And then simply just: IP(which ends up defaulting to 7777 - the default port).

Directly injecting samp.dll into gta_sa.exe

There is also another method which I personally haven't tested but it claims to work for people so I will leave it here. Basically you can directly launch gta_sa.exe with some parameters along with injecting the samp.dll library file.

Parameters to use when injecting samp.dll into gta_sa.exe:
Quote:

-c - Normal mode.
-d - Launch in debug mode.
-n - Name.
-h - Host / IP
-p - Port to connect on - OPTIONAL
-z - The server password - OPTIONAL

So if we want to launch the game and connect to our localhost using the name "pizzaboy" we can do:
Code:
gta_sa.exe -c -n pizzaboy -h 127.0.0.1 -p 7777
If we have our localhost server passworded we can add an additional z parameter like this:
Code:
gta_sa.exe -c -n pizzaboy -h 127.0.0.1 -p 7777 -z applebee
The password being "applebee". Then you simply inject samp.dll into the gta_sa process. You can inject it using various methods through various scripting languages, though I won't go in depth into doing that, the option is there.
Cheers!
Reply
#2

This thread has been updated with some additional useful information.
Reply
#3

you don't need to invoke samp.exe, you can invoke gta_sa.exe directly and then inject samp.dll.

Starting gta sa with this command line:
Quote:

"C:\Program Files\Rockstar Games\GTA San Andreas\gta_sa.exe" -c -h 127.0.0.1 -p 7777 -n Whitetiger

and then injecting samp.dll via CreateRemoteThread avoids silly bugs with samp.exe like if it's already running you'd get "samp.exe is already running" when you tried to execute it your way.

(this way also lets you change player name)

EDIT: Thanks for posting this though, you've reminded me to finally open source the custom launcher that I wrote months ago! shameless plug
Reply
#4

Quote:
Originally Posted by Whitetiger
View Post
you don't need to invoke samp.exe, you can invoke gta_sa.exe directly and then inject samp.dll.

Starting gta sa with this command line:


and then injecting samp.dll via CreateRemoteThread avoids silly bugs with samp.exe like if it's already running you'd get "samp.exe is already running" when you tried to execute it your way.

(this way also lets you change player name)

EDIT: Thanks for posting this though, you've reminded me to finally open source the custom launcher that I wrote months ago! shameless plug
Awesome, how did you find out about this though? Is there a documentation for it somewhere?
Reply
#5

I don't think it's documented anywhere on like, samp wiki or something. I don't remember how I found out about it either, but probably the first person who figured it out found out from the leaked samp source.
Reply
#6

http://forum.sa-mp.com/showpost.php?...63&postcount=6
Reply
#7

Updated & cleaned a bit.
Reply
#8

Saw the thread title and thought it was going to be one of those tutorials that tells you to click the connect button.

Nice tutorial, nevertheless
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)