[Tutorial] SA:MP Developer Tutorial (Beginner's)
#1

SA:MP Developer Tutorial (Beginner's)

0 - Tutorial Map:

**0 *- Tutorial Map.
**1 *- Introduction.
**2 *- What is SA:MP?
**3 *- What is Pawn?
**4 *- What is Pawno?
**5 *- What is Pawn Complier?
**6 *- What is SA:MP Server & Client?
**7 *- Setup the server and the client.
**8 *- Port Forwarding.
**9 *- Pawn Script.
**10 - Pawn Scripting using SA:MP Developement Kit.
**11 - Saving System.
**12 - Plugins.
**13 - Plugins using SA:MP Developement Kit.
**14 - Virtual Mapping.
**15 - Virtual Mapping for SA:MP Server.
**16 - Going Advanced?
* **

1 - Introduction:

Hello.
This is a basic/simple tutorial created/made for newbies,
for helping them to understand basic's meaning of every word and symbole in pawno,
this isn't the first tutorial there many others around samp forum,
if you find this useless/incorrect please feel free to reply what's wrrong/why.
ok, here we go.


2 - What is SA:MP:

San Andreas Multiplayer (SA:MP) is a modification for Grand Theft Auto: San Andreas which turns it into a multiplayer game.
You can play over the internet with other people.
You need the original Grand Theft Auto: San Andreas PC game to play San Andreas Multiplayer.
Version 1.0 of it.

3 - What is Pawn:

Pawn (not pawno) is a simple, typeless, 32-bit extension language with a C-like syntax.
A pawn "source" program is compiled to a binary file for optimal execution speed.
The pawn compiler outputs P-code (or bytecode) that subsequently runs on an abstract machine.
Execution speed, stability, simplicity and a small footprint were essential design criteria for both the language and the abstract machine.


4 - What is Pawno:

Pawno is probably the most common editor around. It's a very basic editor, which offers exactly what most people need.
Features like syntax highlighting, basic run-options and a functions bar which shows the included functions make pawno the perfect editor for people that create small gamemodes or filterscripts,
and people that just want to edit some little things in an existing game mode.
Pawno was created by spooky specifically for SA-MP.


5 - What is Pawn Complier:

Pawn Complier is a tool to make your script complicated or to convert it to abstract machine language (aka AMX),
This tool based on a Command Line Program (Console), that detect errors and warn you about mistakes in your script,
With writing it on a console or printing it on a file.


6 - What is SA:MP Server & Client:

SA:MP Client is a modification for Grand theft auto: San Andreas*which allow you to connect into SA:MP Server that owned by strangers.
SA:MP Server is a Console Program that allows you to create a playground for others players around samp world.
The server allow you to create your own Administration team and your own modification on San Andreas map and also features as your imagination wants.


7 - Setup the server and the client:

The first thing you need to do is installing Grand theft auto: San Andreas and install it on your own PC.
Then after this you should download Latest Version of SA:MP Client Package from here: http://sa-mp.com/download
If you don't know how to install samp client here is a little demonstration https://www.youtube.com/watch?v=n3UvWU-MAm0

After installing the client. you can play directly with joining a server from Internet/Hosting tab, but if you want to create your own server then stay with me,
You should Download SA:MP Server package too from http://sa-mp.com/download for your platform (Linux/Windows)

when download finish extracts it to a folder anywhere you want and open Config.cfg using any text editor.
you will see something like that


Quote:

echo Executing Server Config...
lanmode 0
rcon_password changeme
maxplayers 32
port 7777
hostname SA-MP 0.3 Server
gamemode0 grandlarc 1
filterscripts baseaf gl_actions gl_property gl_realtime gl_mapicon ls_elevator
announce 0
query 1
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]
You should change rcon_password to your Administration password and hostname to your server name. and start the server with executing samp_server.exe!

Meaning of every word and setting? visit here: https://sampwiki.blast.hk/wiki/Server.cfg

add on your samp client localhost(or your ip):7777 and Join here you go! you have a roleplay server your first server!
you don't know how to add a server? check out this*
Want to make it public server? stay with me!


8 - Port Forwarding:

Port forwarding is (opening port/adding exception on firewall) for samp server to accept coming connections from outside Local internet.
this is need another thread to explaint it. here is a tutorial by Leopard


9 - Pawn Script:

Script is a program or sequence of instructions that is interpreted or carried out by another program rather than by the computer processor (as a compiled program is).
Pawn Script is a type of script that i did talked about it before ^


10 - Pawn Scripting using SA:MP Developement Kit:

For scripting a gamemode/filterscript/include you should know the following things.

10.1- #include

include is a keyword that adds a reference or functions to your scripts from another script in the same server.

10.1.1 - #include <>

including a file using <> is locking it location to include folder at your pawncc.exe location. (ex: <a_samp>)

10.1.2 - #include ""

including a file using "" is opening its location to the world that means the script can include a file from anywhere. (ex: "../gamemodes/file.inc")

10.2- #define

this keyword containing 2 params, first is the variable and second it's their definition.
variable created by this keyword can be a string, integer or a fake-function
ex:

PHP код:
#define aa 23
print(aa);
Output
23 
10.3 - Script Map

To script a pawn script correctly you must organize your code correctly, most likely based on the following map.

#1 Comments
#2 Includes
#3 Defines
#4 Enum's
#5 Variables
#6 Static's
#7 Public Callbacks
#8 Commands
#9 Functions Static's/Stock
#10 Function Non-Static

10.4 - Limitation

There limits for everything in life. same thing here, also script has limits
Some of them (Most important):

Max players = 1000 (This limit is mostly used to create a variable for every player in server (ex: Admin[MAX_PLAYERS]))
Player Variables = 800 *(Max of variables that server/script can handle for a single player)
Max Name len * * = 24 * (Max len of a player name that player can use it) (ex: Name[MAX_PLAYER_NAME])
Max string len * = 1024 (Max string len that can be used anywhere in script)
colors code = 255 *(Using so much colors codes in one gamemodetext can crash player (who see it) client) (ex: ~r~~g~~b~....etc)

10.5 - enum, new, static, stock, const

10.5.1 - enum

Enumerations are a very useful system for representing large groups of data and modifying constants quickly.*
There are a few main uses - replacing large sets of define statements,*
symbolically representing array slots (these are actually the same thing but they look different) and creating new tags.

ex:

PHP код:
enum My_Enum

 * 
Id,
 * 
Admin
};
new 
player[MAX_PLAYERS][My_Enum];
player[MAX_PLAYERS][Admin] = 0
10.5.2 - new

new is a keyword that declares/create a different type of variables. that can be an integer/float/string.
Note that assigning var to this variable can be changed anywhere in the script. so be careful when you choose the right keyword.

ex:


PHP код:
new myvar 1
10.5.3 - static

static is a keyword that declares/create a different type of variables that you can't access it out the level/file that you created it on
unlike "new" keyword
Note that assigning var to this variable can be changed anywhere in the local script. so be careful when you choose the right keyword.

ex:


PHP код:
static myvar 1
10.5.4 - stock

stock is used to declare variables and functions which may not be used but which you don't want to generate unused warnings for.*
With variables, stock is like const in that it is a modifier, not a full declaration
its most commonly used for custom libraries (aka Custom Functions)

ex:*

PHP код:
new stock mystock 1;
stock myfunc()
{
 * print(
mystock);

10.5.5 - const

const is same as #define the only different between them is that const supports tags and enum just like 'new' or 'static' but*
variable assigned to it cannot be edited.

10.6 - public, forward

public is used to declare functions that can be called out a script or by a native.
Note! you must forward this function before using it or calling it!

ex:

PHP код:
forward MyFunc();
public 
MyFunc()
{
 * print(
"yay!!");

10.7 - native

native keyword is mostly used to define a function that exists on the *server side by SA-MP Server or a plugin (not exists in the script)
defining an invalid native might prevent your game mode from starting and can be the result of it crashing server sometimes!

ex:*


PHP код:
native*print(const string[]);
static 
stock MyFunc(str[])
{
 * print(
"Hallo!");
 * print(
str);


10.8 - Non-keyword function

Non-Keyword functions is same as others functions, but it can't be called out script and if it not used,
it will send some warnings in pawn console.

ex:*

PHP код:
Function1()
{
* * * *print(
"NK function");

10.9 - Meaning of symboles on natives/functions

[] - this mean the variable is a string (ex: func(string[]))
& * - this mean the variable can be edited when used. (ex: GetPlayerHealth(playerid, &Float:health))
Tag: - this mean only type of this var can work on that params of native (ex: SetPlayerArmour(playerid, Float:armour)) Float = 1.000 numbers decimal*


12 - Saving Systems:

There many saving systems around samp world. here some of them and their features:

Ini file * **- this saving system based on saving stats as texts on a .ini file.
MySQL **- this saving system based on saving stats as queries on tables (on a remote host)
SQL Lite - this saving system based on saving stats as queries on tables (on a local database .db)

Choose carefully the saving system that your server and you can handle it.


13 - Plugins:

Plugins (aka Add-ons) is a software component that adds a specific feature to an existing computer program.*
When a program supports plug-ins, it enables customization. The common examples are the plug-ins used in web browsers to add new features such as search-engines,*
virus scanners, or the ability to use a new file type such as a new video format.


14 - Plugins using SA:MP Developement Kit:

Plugins in samp are coded on C++ using any version of Visual Studio (2008+).
There two types of samp plugins.

1- Memory Hacking plugins (at your own risk!)
2- Normal Plugins

I can't explain this here, so I will give you a little reference here.

Want to join Plugin Developement World? Check out this tutorial.


15 - Virtual Mapping:

Virtual Mapping is the creation of maps, a graphic symbolic representation of the significant features of a part of the surface of the Earth.
Mostly knowable as Texture Mapping (aka Computing Mapping)

Texture Mapping is Texture mapping is a method for defining high-frequency detail, surface texture, or color information on a computer-generated graphic or 3D model.


16 - Virtual Mapping for SA:MP Server:

Virtual Mapping for samp is creating/organizing some objects, imported from DFF's files on Grand theft auto: San Andreas.
Organizing those objects is mostly used by Stunt servers. for creating an awesome Maps for fun!

There many tools for mapping here is the most knowable

- SA:MP Map editor by JernejL
- Map Editor by Kurence
- Map Editor by Matthais


17 - Going Advanced:
  1. AMX assembly
  2. Modular gamemode
18 - Sources:
  1. SA:MP Wiki
  2. Wikipedia
  3. SA:MP Forum
  4. My Brain

Thank you for reading!

XeonMaster
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)