SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 10/08/2017, 06:33 PM   #1
XeonMaster
Big Clucker
 
XeonMaster's Avatar
 
Join Date: Jul 2017
Location: Earth
Posts: 186
Reputation: 13
Default SA:MP Developer Tutorial (Beginner's)

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 gamemode.
Pawno was created by spookie 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*wich allow you to connect into SA:MP Server that owned by strangers.
SA:MP Server is a Console Program that allow 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:

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 Lastest 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 demostration https://www.youtube.com/watch?v=n3UvWU-MAm0

After installing the client. you can play directly with joining an 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 extract 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 Adminstration password and hostname to your server name. and start server with excuting samp_server.exe!

Meaning of every word and setting? visit here: http://wiki.sa-mp.com/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 add a reference or functions to your scripts from another script in 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 it location to world that mean the script can include file from anywhere. (ex: "../gamemodes/file.inc")

10.2- #define

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

PHP Code:
#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 a limits for everythings in life. same thing here, also script has a 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 Code:
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 declare/create a diffrents type of variables. that can be an integer/float/string.
Note that assigned var to this variable can be changed anywhere in script. so be careful when you choose the right keyword.

ex:


PHP Code:
new myvar 1

10.5.3 - static

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

ex:


PHP Code:
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 Code:
new stock mystock 1;

stock myfunc()
{
 * print(
mystock);


10.5.5 - const

const is same as #define the only different bettwen 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 script or by a native.
Note! you must forward this function before using it or calling it!

ex:

PHP Code:
forward MyFunc();
public 
MyFunc()
{
 * print(
"yay!!");

10.7 - native

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

ex:*


PHP Code:
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 Code:
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 sytems 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 querys on tables (on a remote host)
SQL Lite - this saving system based on saving stats as querys on tables (on a local database .db)

Choose careful 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 explaint 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 knownable 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 to mapping, here is the most knownable

- 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

Last edited by XeonMaster; 10/08/2017 at 09:11 PM.
XeonMaster is offline   Reply With Quote
Old 11/08/2017, 08:55 AM   #2
XeonMaster
Big Clucker
 
XeonMaster's Avatar
 
Join Date: Jul 2017
Location: Earth
Posts: 186
Reputation: 13
Default Re: SA:MP Developer Tutorial (Beginner's)

70 View, No Comments?
XeonMaster is offline   Reply With Quote
Old 11/08/2017, 09:22 AM   #3
[Bios]Marcel
High-roller
 
[Bios]Marcel's Avatar
 
Join Date: Jul 2012
Location: Germany
Posts: 1,216
Reputation: 189
Default Re: SA:MP Developer Tutorial (Beginner's)

Here is a comment, don't make tutorals if you have no clue what you are actually talking about.
[Bios]Marcel is offline   Reply With Quote
Old 11/08/2017, 09:23 AM   #4
XeonMaster
Big Clucker
 
XeonMaster's Avatar
 
Join Date: Jul 2017
Location: Earth
Posts: 186
Reputation: 13
Default Re: SA:MP Developer Tutorial (Beginner's)

Quote:
Originally Posted by [Bios]Marcel View Post
Here is a comment, don't make tutorals if you have no clue what you are actually talking about.
ok, can you help me with giving me a clue?

thank you.
XeonMaster is offline   Reply With Quote
Old 11/08/2017, 09:27 AM   #5
[Bios]Marcel
High-roller
 
[Bios]Marcel's Avatar
 
Join Date: Jul 2012
Location: Germany
Posts: 1,216
Reputation: 189
Default Re: SA:MP Developer Tutorial (Beginner's)

There are some mistakes, don't feel like listing them now. Will do later, furthermore tomorrow, since i won't be home today.
[Bios]Marcel is offline   Reply With Quote
Old 11/08/2017, 09:35 AM   #6
Fratello
Big Clucker
 
Fratello's Avatar
 
Join Date: May 2016
Location: Serbia
Posts: 113
Reputation: 20
Default Re: SA:MP Developer Tutorial (Beginner's)

I like the work, keep it up!
__________________
Quote:
Originally Posted by Misiur View Post
Well, maybe simply you don't have any friends (in database)
Fratello is offline   Reply With Quote
Old 11/08/2017, 11:23 AM   #7
Hansrutger
Gangsta
 
Hansrutger's Avatar
 
Join Date: May 2011
Location: Sweden
Posts: 901
Reputation: 135
Default Re: SA:MP Developer Tutorial (Beginner's)

Quote:
Originally Posted by XeonMaster View Post
70 View, No Comments?
When the true intention is revealed. :3
__________________



Current progression on roleplay gamemode:
Week 1 ( 22/04-30/04 ): 10524 loc
...
Week 15 ( 30/07-06/08 ): 72535 loc
Hansrutger is offline   Reply With Quote
Old 11/08/2017, 11:27 AM   #8
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Ottawa, Canada
Posts: 1,605
Reputation: 613
Default Re: SA:MP Developer Tutorial (Beginner's)

0.1% of newbs to pawn read these beginner tutorials. And that makes sense too!
__________________

Stop contacting me for help! I ain't got time for yoir shit!


Gammix is online now   Reply With Quote
Old 11/08/2017, 03:12 PM   #9
XeonMaster
Big Clucker
 
XeonMaster's Avatar
 
Join Date: Jul 2017
Location: Earth
Posts: 186
Reputation: 13
Default Re: SA:MP Developer Tutorial (Beginner's)

Thanks everyone!

Quote:
Originally Posted by Gammix View Post
0.1% of newbs to pawn read these beginner tutorials. And that makes sense too!
hmm, didn't understand but ok!

@Marcel: can you specifie the mistakes, that i can fix it? thank you.
XeonMaster is offline   Reply With Quote
Old 12/08/2017, 10:12 PM   #10
Ramboi
Little Clucker
 
Join Date: Jul 2017
Location: Not on Earth ATM
Posts: 32
Reputation: 0
Default Re: SA:MP Developer Tutorial (Beginner's)

I can't understand if it's a SAMP tutorial or port forwarding tutorial or how to setup a SAMP server tutorial or plugins tutorial of some sort.

Like come on, I'm looking for a PAWNO tutorial nothing else.
Ramboi is online now   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
[Tutorial] [Beginner's Tutorial] Gamemode Changing System Champ Tutorials 9 29/06/2013 01:00 PM
Beginner tutorial setting up a server. eclipses Server Support 0 09/10/2012 09:40 AM
Seeking professional pawno developer and web-developer Kingunit Everything and Nothing 21 13/05/2012 05:02 PM


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


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