[Tutorial] Getting started for beginners.
#1

Introduction :
Hello everyone, after I got my old account hacked and I still don't know how it could be since my password was very secure I decided to make this new account, anyways I'm going to make a useful tutorial for newbies, however it won't be a scripting thread but it will be a thread where a newbie can get started from.

Some useful informations :
- What is SA:MP ?
San Andreas Multiplayer (abbreviated to SA:MP) is a third party multiplayer modification for the Grand Theft Auto: San Andreas PC game. San Andreas Multiplayer is developed by a dedicated team who work on their own spare time developing SA:MP.
SA:MP was created by kyeman and spookie in 2005, these were also the people who had created VC:MP ( Vice City MultiPlayer ), though SA:MP was considered superior by both the community and the developers due to the high amount of creativity and expansion that could be done in San Andreas rather than Vice City, for example ability to swim in water and a lot of interiors/objects/skins/vehicles.
- What is PAWN ?
PAWN is the official language for scripting SA:MP servers, and is used by thousands of people to create their own server. The most commonly used program to script and compile PAWN is called pawno which we use.
PAWN isn't used only by SA:MP but by many other games as well.


How can I run a server ?
1 - Requirements :
Fully working GTA San Andreas Game
SA:MP 0.3z
SA:MP 0.3z Windows Server

2 - Installation of SA:MP 0.3z :
Once you clicked the link given above you can download the program to install SA:MP 0.3z on your computer.




3 - Installation of your Windows Server Files :
Once you clicked the link given above you can download your Windows Server files on your computer, just like any other ZIP file you have the unzip it in your desktop.

4 - Exploration over your Windows Server Files :
After unzipping the folder you downloaded, enter it, when you are done, you will find many folder and files on it, I will explain to you.
- Filterscripts : (abbreviated to FS) is a pawno file which contains a particular script, FSs are used to have a specific let's say for example House system, maybe vehicles system and it can be many other things.
The SA:MP forum members post daily FSs, you can check and download some of them here.
- gamemodes : (abbreviated to GM) is a pawno file contains coding, the game is considered as your server engine since it usally contains most big parts of your server in, and it is something that your server needs to start.
You can find some GMs posted by the SA:MP forum members here.
- pawno : it's the folder which you can find in the program to code your server, pawno.exe is used each time you want to see/edit your script.
- pawno/include : this folder contains all of your includes, open your gamemode and check in the top you will find #include a_samp which means a_samp.inc must be placed in pawno/include otherwise a reading error will appear.
Includes are .inc file which contains functions, if you add includes to your gamemode it means an extra acces to functions and it depends on the include you installed, each one has its own functions.
You can download includes from here.
- plugins : some includes does require plugins, so you must place your downloaded plugins in here
You can download plugins from here.
Note : It depends on your OS, if you are under windows use plugin.dll and if in Lunix use .so

4 - 2 : Server.cfg
server.cfg is a server configuration file which allows you to change settings of your sa-mp server.
This file is necessary for every server and has to be located in the server directory next to the server application.
Код:
echo Executing Server Config...
lanmode 0
rcon_password changeme
maxplayers 50
port 7777
hostname SA-MP 0.3 Server
gamemode0 grandlarc 1
filterscripts gl_actions gl_realtime gl_property gl_mapicon ls_mall ls_elevator attachments skinchanger vspawner
announce 0
query 1
chatlogging 0
weburl www.sa-mp.com
onfoot_rate 40
incar_rate 40
weapon_rate 40
stream_distance 300.0
stream_rate 1000
maxnpc 0
logtimeformat [%H:%M:%S]
Код:
  1. lanmode 0 ( Turning lanmode on means the server will more accurate, you can turn lanmode on by changing the value to 1 and you can turn it off by changing the value to 0. default this is set to 0 )
  2. rcon_password changeme ( The RCON password means password of your server since the RCON gives a full control over the server, you must choose a very secure RCON password and none must know about )
  3. maxplayers 50 ( The maximum amount of the players which can join your server before it gets full )
  4. port 7777 ( The port depends on your portforward/host, by default it is set to 7777 )
  5. hostname SA-MP 0.3 Server ( Your server name )
  6. gamemode0 grandlarc 1 ( The gamemode which will be loaded from gamemodes folder )
  7. filterscripts gl_actions gl_realtime gl_property gl_mapicon ls_mall ls_elevator attachments skinchanger vspawner ( The FS which will be loaded from the filterscripts folder )
  8. announce 0 ( Toggle server to be announced to SA-MP masterlist, enable it 1 and disble 0 )
  9. query 1 ( Toggle querying of server. If this is disabled, the server information will not be displayed in the server browser. Set to 1 to enable querying or 0 to disable )
  10. chatlogging 0 ( It will log the chats, I suggest you to let it disabled since it will gets your log spammed )
  11. weburl www.sa-mp.com ( The website of your Server )
  12. onfoot_rate 40 ( The minimum time in milliseconds a client updates the server with new data while running/walking )
  13. incar_rate 40 ( The minimum time in milliseconds a client updates the server with new data while in car )
  14. weapon_rate 40 ( The minimum time in milliseconds a client updates the server with new data while on foot )
  15. maxnpc 0 ( The amout of NPC ( Bots ) which can spawn in your server )
  16. logtimeformat [%H:%M:%S] ( Allows you to configure the timestamp format, Suggest you to let it by default )
Note : The server needs the .amx file only to run, the .pwn file is used only to edit the code and the .amx is the translated code into server language, so it can be understable and runnable by the machine.

4 - 3 : Getting your server On :
Head to your Windows Server file.
You can see samp-server.exe, double click on it, Did you got a black screen of cmd and closed immediately ? It means you didn't change your RCON Password.
Go to your server.cfg, change the RCON passwod from changeme to your password and save it.
Now double click on samp-server.exe, You can join the server via the IP : 127.0.0.1
Your server is online only for you, None can join it.

4 - 3 - B: Getting your server Online
Methods used in TP-LINK router, I can show you how to do it in any router so don't hesitate asking me.
  1. Open your cmd and type in ipconfig, Copy your adress IP and default gateway
  2. Head to your internet browser and in url paste the default gateway
  3. To login type in username and password either admin or user
  4. Press on Advanced Setup >> Click the Virtual Server link near the center of the page
  5. Set the start and end Port to " 7777 " || Protocol " ALL " || Local IP " The IPv4 which you did copy from cmd
  6. Go to www.whatsmyip.org and copy your Adress IP, Send it to your freind and he can come online
Your server will basically be very simple and without many features, You can start learning to code and you can also download GameModes from this Forums.

Differences :
Difference between FS and Include :
An include is a file with code which can be included in any script at compiling and they don't have anything to do with variables.
A filterscript is a compiled script which uses includes to be compiled just like the gamemode, and they use their own area to store date "scriptfiles" while include doesn't.
Wigs of Filterscripts may get you a server but wigs of includes doesn't.
Includes are very necessary to run your server while FS aren't and they add much settings and functions and inc is used to save space in scripts.
Difference between FS and GameMode :
Gamemode and FS shouldn't be mixed in one server because they may cause a hell of bugs ( You just have to do it right ).
basically FS and GM both of them is almost the same, the way they get written by the server and how they collect their data, just that you must not randomly mix them.
Difference between .pwn and .amx :
.pwn files is programmed for humans because it's easy to understand and edit it.
.amx files are used by the cpu, binary file that you can't understand and you can't edit.


Pawn Scripting
I think you know how to configure and run your server, I think it's time for something new.
We are going to have some fun by editing a gamemode.
After doing this open the pawno folder inside your server and open the file "pawno.exe".
Press "File/Open" (CTRL + o) and open any gamemode inside the gamemodes folder.
When you open it first thing you will see is this.
pawn Код:
#include <a_samp>
This is the basic SA-MP include, it must be included in every SA-MP script.
Publics :
Publics are basic functions called while your server is running and in all gamemodes you can find publics gets called and some other gets called in very particular moments just like this :
pawn Код:
public OnPlayerConnect(playerid)
{      
SendClientMessage(playerid, -1, "Hi!")
;return 1;
}
The player will get this message each time he connects to the server.
Please note that you can't put in your gamemode more than one public, if you want another function then you use the same public.
pawn Код:
public OnPlayerConnect(playerid)
{      
SendClientMessage(playerid, -1, "Hi!"); // He gets the message
SetPlayerHealth(playerid, 100); // and at the same time, he gets his hp set to 100
;return 1;
}
Most famous and used publics :
public OnGameModeInit() Called when your mode starts; it is necessary in all scripts.
public OnGameModeExit() Called when your mode ends; it is not necessary in all scripts.
public OnPlayerConnect(playerid) Called when you connect.
public OnPlayerRequestClass(playerid, classid) Called when you choose your skin.
public OnPlayerSpawn(playerid) Called when you Spawn.
public OnPlayerDeath(playerid) Called when you die.

public OnGameModeInit()
Example Usage:
pawn Код:
public OnGameModeInit()
{
    print("Gamemode started!"); // Print in your console
    UsePlayerPedAnims(); // Run style to CJ's
    return 1;
}
So players in your server will always run like Mr.CJ

You can spawn vehicles.
pawn Код:
AddStaticVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1);
And the code will be
pawn Код:
public OnGameModeInit()
{
    print("Gamemode started!"); // Print in your console
    UsePlayerPedAnims(); // Run style to CJ's
    AddStaticVehicle(411, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1); // Spawn Infernus vehicle
    //(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2)
    return 1;
}
public OnGameModeExit()
Example Usage:
pawn Код:
public OnGameModeExit()
{
    print("Gamemode ended."); // Print in your console
    return 1;
}
public OnPlayerConnect()
Example Usage:
pawn Код:
public OnPlayerConnect(playerid)
{      
SendClientMessage(playerid, -1, "Hi!");
SetPlayerHealth(playerid, 100); // hp set to 100
return 1;
}
public OnPlayerRequestClass()
Example Usage:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{  
SetPlayerPos(playerid, 2294.2810, 558.2053, 7.7813); // Skin position
SetPlayerCameraPos(playerid, 2294.3071, 560.6948, 8.7324); // Position of the camera    
SetPlayerCameraLookAt(playerid, 2294.2810, 558.2053, 7.7813); // Position where the camera is looking at    SetPlayerFacingAngle(playerid, 0);  
return 1;
}
SetPlayerFacingAngle sets the angle where the player is looking; it's structure is:
playerid = ID of the player
0 = angle (in this case north).

Код:
   north (0)
               |
(90) west-   -east (270)
               |
        south (180)
public OnPlayerSpawn()
Example Usage:
pawn Код:
public OnPlayerSpawn(playerid)
{  
SendClientMessage(playerid, -1, "Spawned.");  
return 1;
}
public OnPlayerDeath()
Example Usage:
pawn Код:
public OnPlayerDeath(playerid)
{  
GameTextForPlayer(playerid, "Killed.", 5000, 2);
return 1;
}
SendClientMessage is a function that sends a message to the player; its structure is:
Код:
(playerid, color, const message[])
playerid : The ID of the player to display the message to
color : The color of the message
const message[] : The text that will be displayed (max 144 characters).
GameTextForPlayer is a function that sends a screen message to the player; its structure is:
Код:
(playerid, const string[], time, style)
playerid : The ID of the player to show the gametext for.
const string[] : The text to be displayed.
time : The duration of the text being shown in milliseconds.
style : The style of text to be displayed.
I guess this is it, I would really appreciate if you give me feedback.

Thanks for reading,
SV.
Reply
#2

Very useful for newbies.
Reply
#3

Would be nice if you'd explain
1. Game basics.
2. Modes and explanation of each mode
3. How to home host. (with portforward and so on...)
4. What is "compile"
5. Difference between includes, filterscripts and gamemodes
6. Getting familiar with the server files
7.
Quote:

Note : The GM/FS needs the .amx file to be loaded, .pwn doesn't fit with the server, it's only used by the scripter so he can have an idea about what he is writing.

I would rather describe it as
Quote:

The server needs the .amx file only to run, the .pwn file is used only to edit the code and the .amx is the translated code into server language, so it can be understable and runnable by the machine.

Or at least something like that
Reply
#4

Very nice man well explained.
Reply
#5

Nice
Reply
#6

Nice additions.
Reply
#7

I suggest to add some other functions and how to use them.
Reply
#8

Quote:

lanmode 0 ( Turning lanmode on means the server will more accurate, you can turn lanmode on by changing the value to 1 and you can turn it off by changing the value to 0. default this is set to 0 )

You forgot to mention that this will use more bandwidth when enabled.
Reply
#9

Don't take me wrong, but people or newbies can find the same thing on wiki or other forum posts.... you should explain more function and gamemod basics, thanks.
Reply
#10

nice
Reply
#11

Really good for newbies REP+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)