[Tutorial] Scripter's Guide [NEW]
#1

Definitions

In Scripting there are alot of definitions that you may need to know.
This are the definitions for this First Tutorial:

Filterscript (Script): A filterscript is a script that is attached to the Gamemode to work with the gamemode but not as the gamemode.
They are like add-ons.

Gamemode (Script): A gamemode is the main script running on a server.

Includes (Script): A include is a script that helps to script in someway. Examples are dini, zcmd, dudb. etc.

Chapter I - SA-MP & PAWNO

San Andreas Multiplayer is a modification of the Game "Grand Thef Auto San Andreas".
It was released in the year 2004 and people still play it.
If we make a analisis of all the Modifications of GTA:SA the most important Of all times are
MTA and SAMP, MTA is really customizable to be honest, you can even add images but...

What about SAMP?

San Andreas Multiplayer right now has 20,000 Players, sa-mp has more Roleplay Servers plus
better scripts. MTA uses lua and SA-MP uses pawn.

But well, let's leave this topic and start to script...

Chapter II - Downloading SA-MP & Downloading the Server Pack + Pawno

Pawno is the main Pawn editor, and Pawn is the programming language used in sa-mp.
In order to play SA-MP you need to download SA-Mp from this page, the client, and aswell the server pack. It will include many folders (the server pack), I suggest you to put them in a easy to open place, for example, your desktop.
I will explain each of the folders there:

Filterscripts (Folder): All filterscripts (See Definitions) go here.
Gamemodes (Folder): All Gamemodes (See Definitions) come here.
Includes (Folder): All Includes (See Definitions) come here.
Pawno (Folder): Pawno is here.
Plugins (Folder): This is a folder that does not come with installation, all plugins go here.
NOTE: You need to create this folder.
Scriptfiles (Folder): All the files of the script (NOT THE LISTED ABOVE) come here, for example, all user information, Server info. etc. ALL is managed by the scripts but not by sa-mp itself.

Chapter III - Setting up your server

Now what we are going to do is to see if our server is working. by default you have grandlarency (or something like that).
I suggest you download Notepad++ for opening all the files we are going to open (but .pwn or .inc)
After downloading Notepad++ open server.cfg (In Notepad++ right click > Edit in Notepad ++)
You will see this:

Код:
echo Executing Server Config...
lanmode 0
rcon_password rconpass (or sth like this)
maxplayers 50
port 7777
hostname SA-MP 0.3 Server
gamemode0 grandlarc (or sth like this)
filterscripts (sth here)
announce 1
query 1
weburl www.sa-mp.com
maxnpc 0
onfoot_rate 40
incar_rate 40
weapon_rate 40
stream_distance 300.0
stream_rate 1000
on rcon_pass, change rconpass to a password you want for the Rcon, Rcon is the default admin system on all pawno script it can't be deleted but only blocked with scripts (we will learn that later).
now delete gamemode0 content and filterscripts too.
should end like...

Код:
echo Executing Server Config...
lanmode 0
rcon_password yourpass
maxplayers 50
port 7777
hostname SA-MP 0.3 Server
gamemode0
filterscripts
announce 1
query 1
weburl www.sa-mp.com
maxnpc 0
onfoot_rate 40
incar_rate 40
weapon_rate 40
stream_distance 300.0
stream_rate 1000
Save the file with the name "tutfile" and open pawno (Server File > pawno > pawno.exe)
You will see a blank "file".
Create a new file and you will see some text appeared, that's the default "start script" with all callbacks and funcs (we are going to learn this later). Now only save it on gamemodes and Press F5, a compiler will pop up and say if it has errors warning or if compilation is clean.
If it's clean then just go to the Server Folder and open again server.cfg.
Now change gamemode to this:
Код:
gamemode0 tutscript
Save it and now run (On Server Folders) samp-server.exe
should appear a black window and that means your server is running.
Now open sa-mp and add this server to favorites:
127.0.0.1:7777 (this is the port)
This is only FOR YOU. others will need YOUR ip.
Now, go on, join it, you may see that the cam is in LV and that you spawn at LV that's how to set a basic server with a blank script.

__________________________________________________ ___________________________________________

Information

This is the second tutorial of my tutorial series, if you haven't read my First tutorial click here.
This tutorial will explain the basics of pawn.

What is pawn?

Wikipedia defines pawn as:
Quote:
Originally Posted by Wikipedia
Pawn, formerly known as Small, is an open source programming language primarily intended as an embeddable scripting language. It is maintained by a Dutch company named CompuPhase, which released the first version in 1998.
for us pawn is our programming language that is specially for sa-mp scripting, but sa-mp is not all colorful and learning it without knowing any other programming language may be quite hard, this tutorial is intended to teach you the basics of pawno.

Credits & Script Information Making

What I do in all the scripts i make is to set information and credits.
As we said we have this:

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Let's delete first lines (1, 2, 3) that contain:

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
They are not very useful.
as you already read on that 3 lines // is a comment aswell as /**/,
we will learn about comments:

NOTE: Don't add this.

pawn Код:
//<----- 1-Lined Comment
As you see, // is a 1 lined comment, so if we type...

pawn Код:
//<----- 1-Lined Comment
But this is not
will give you this error:

Код:
 error 010: invalid function or declaration
Why? cause it's not in a comment, with // only the text NEAR // will be comment.

So i can't make multi-lined comments?

Of course you can, /* and */ are used for multi-lined comments.
For example:
(Again, don't add this)

pawn Код:
/* This is a comment */
That is a multi-lined comment, but now let's go to the official script you are making.
We want to have the credits of the script, we want it, that's true. so we gotta
set some credits as Comment, some credits on main() function and some information
thing when a player connects, that will be the first thing we have to do, atleast i do.

So on the first lines put your "Copyright" and information, and credits. etc.
I will put this:

pawn Код:
/***********************************
*        TUTORIAL SCRIPT           *
*  CREATED BY: CHRISTIAN *
*  MODIFIED BY: MATTHEW STRIKER *
************************************/


/*
Deskoft Studios Tutorial Script

Developer: Christian
This script is created to teach users
the programming language used in
sa-mp, "pawn". This script can be
copied, used, modified or whatever
they want, i don't care. i only want
you to leave the credits as they are.

CREDITS:
 Christian (Teaching & Developing the Script)
 Matthew Striker (Continuing the tutorial)
*/
That, i will compile now and...
I have this:

Quote:

Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

That means it's a clean compilation and there was no errors or warnings.

So we have just learned comments and we have our Mini-Credits developed
Now what?

let's check the function "main()"

pawn Код:
main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}
What the **** is that?
Simple, that's called a function. has { and }, inside that { and } all the Function is made
inside ( and ) there are parameters.
now, print is used to print some text in the console (a.k.a black box where you run your script).
let's delete the pritns in main() and make OUR own print.
But first just delete them and go to the first lines.
We are going to learn something really useful:
#define.
Now the word "define" by wordnetweb.princeton.edu is:

Quote:
Originally Posted by wordnetweb.princeton.edu
give a definition for the meaning of a word
So we basically set a type of Meaning for something.

let's make some basic defines...
I will put this:
(NOTE: I suggest putting it AFTER #include <samp>)

pawn Код:
#define DEVELOPER "Christian"
#define VERSION "v.0.0.1a"
Now we are putting new stuff in our brain.
why the fuck is it in " and "?
all text inside " and " is called a string.
A string contains text, but we will learn how to put variables (We will learn the definition later)
later.
let's imagine strings are letters, we are setting the title of the letter to DEVELOPER and the content to v.0.0.1a
and VERSION as title and v.0.0.1a as content.
Now we will learn another useful function called printf, sends a formatted string to the console.
I know you are saying... What the ****?
but i will explain this.
it's pretty much the same as print but now you can use variables or defines or anything else.
this is a example: (DONT ADD)
pawn Код:
printf("Version: %s", VERSION);
remember the #define VERSION "v.0.0.1a" thing? it will output this:
Код:
Version: v.0.0.1a
on Console.
Now, what is %s? it's a string.
this are all the things that can be used:

%b Inserts a number at this position
%d Inserts an integer (whole) number
%f Inserts a floating point number.
%i Inserts an integer.
%s Inserts a string.
%x Inserts a number in hexadecimal notation.
%% Inserts the literal '%'
We will learn them later.
but now only strings.
if we use:
printf("%s %s", VERSION, DEVELOPER);
it will output:

Код:
v.0.0.1a Christian
so it prints them in order.
Now let's start working...
on the function main() let's put your info:

pawn Код:
print("Tutorial Script");
    printf("Version: %s", VERSION);
    printf("Developer: %s", DEVELOPER);
that will output:

Код:
Tutorial Script
Version: 0.0.1a
Developer: Christian
__________________________________________________ _________________________________________

Information

This is the second part of my tutorial series.
If you haven't checked part 2 click here.

What is a variable?

Wikipedia defines variable as
Quote:
Originally Posted by Wikipedia
a variable is a facility for storing data
So yeah, stores data, but what is the difference with #define?
#define can't be changed after compilation but a variable can.
Let's see... (DONT ADD THIS):

pawn Код:
new number=1;
new number2=1;
new result;
result=number+number2;
That's basically 1+1 = 2.
let's imagine a variable is like your brain.
You find Anne in the street and tell her:

Quote:

You: Hello Anne
Anne: Hi there
You: I have just learned math
Anne: Cool!
You: Do you know what 1+1 is?

Now Anne starts thinking, but that "thinking" lasts only some few seconds as it's a simple operation, in programming that operation may take less than a second (Depeding on lag, and the script way of programming).
so after... 1 second she may answer:

Quote:

Anne: 2 ofcourse!
You: Nice Job!

Now, we will start learning variables...

Integrer:

A integrer contains numbers, what we learned there was a integrer.
a example would be...
pawn Код:
new integrer;
instead of integrer you can put any name, you can put new mynumb; or whatever.
That stores ONLY a number.

Variables for Strings:

A Variable for Strings is:
pawn Код:
new myname[128];
What is [128]? the max lenght of the string inside the variable.
There are many other types of variables or systems of storing things but we will learn them later aswell.

We will now learn a new method called arrays or global variables.
Let's see...
pawn Код:
new Score[MAX_PLAYERS];
I putted that near the defines.
Now, what is MAX_PLAYERS? Guess...
That's a define, but...
Where was it defined?
you remember server.cfg and the func max_players? there.
Can you modify it? yes, ovbiously, and we will do it via script.
I prefer doing it via script.
Add this near your defines:

pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 50
The #undef basically undefines a define.
and there you go.
We have this at the moment:

pawn Код:
Deskoft Studios Tutorial Script

Developer: Christian
This script is created to teach users
the programming language used in
sa-mp, "pawn". This script can be
copied, used, modified or whatever
they want, i don't care. i only want
you to leave the credits as they are.
*/

#include <a_samp>
#define DEVELOPER "Christian"
#define VERSION "v.0.0.1a"
#undef MAX_PLAYERS
#define MAX_PLAYERS 50
new Score[MAX_PLAYERS];

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("Tutorial Script");
    printf("Version: %s", VERSION);
    printf("Developer: %s", DEVELOPER);
}

#endif

public OnGameModeInit()
{
    // Don'
t use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
In the next tutorial we will learn how to modify the scores and how to use Timers...

__________________________________________________ ___________________________

Now we will learn how to use timers and modify the score...
Wikipedia defines timers as...

Quote:
Originally Posted by Wikipedia
A timer is a specialized type of clock. A timer can be used to control the sequence of an event or process. Whereas a stopwatch counts upwards from zero for measuring elapsed time, a timer counts down from a specified time interval, like an hourglass
So yeah, a timer calls a function after x amount of milliseconds.

SetTimer(FuncName[], Milliseconds, Repeat)

That's the command to create a Timer...
Let's see, we want to create a timer that every second checks the money of the player
and sets the Score to that.
So we first create the function...

Public Functions

Ok i created this next to main():

pawn Код:
public SetScore()
{
    return 1;
}
basically a public function is a function that will be called by a timer or by the script at start.
NOTHING ELSE, a normal functions is like this:

pawn Код:
myfunc()
{
    return 1;
}
Now, basically in this public function we will use our first for();...

For()

When you use for, you will repeat something while something is true.
Let's see...

pawn Код:
for(new i=0;i<5;i++)
{

}
That will create first the variable (Int) i that starts in 0, then check if i is Less than 5 and then add +1 to i.
when i arrives to 4 it will just stop the for.
Let's use this.

On your SetScore public func type this:

pawn Код:
for(new i=0;i<MAX_PLAYERS;i++)
    {
        Score[i]=GetPlayerMoney(i);
        SetPlayerScore(i, Score[i]);
    }
What is that doing?
it will start the i variable in 0, and the max players is 500, so the loop will get the money of all the players, and set it as it's score!

SetPlayerScore(playerid, Score)

That basically sets the score of a player, you can...
pawn Код:
SetPlayerScore(playerid, 5);
And will set the score to 5.

GetPlayerMoney(playerid)
returns the amount of money a player has, it can be used like this...
pawn Код:
new playermoney;
playermoney=GetPlayerMoney(playerid);
Now... Compile your script.


Код:
public function lacks forward declaration (symbol "SetScore")
That right?
Yes, public functions need to be forwarded like this:
(On the start of the code, near #defines)

pawn Код:
forward SetScore();
You basically put the header.
Well that's all for now, later we will learn more things.

_________________________________

Now we will learn how to make a simple login system, but first you will need dini.inc
You can download it from: here

Now we have this code:

pawn Код:
Developer: Christian
This script is created to teach users
the programming language used in
sa-mp, "pawn". This script can be
copied, used, modified or whatever
they want, i don't care. i only want
you to leave the credits as they are.
*/

#include <a_samp>
#define DEVELOPER "Christian"
#define VERSION "v.0.0.1a"
#undef MAX_PLAYERS
#define MAX_PLAYERS 50
new Score[MAX_PLAYERS];
forward SetScore();

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("Tutorial Script");
    printf("Version: %s", VERSION);
    printf("Developer: %s", DEVELOPER);
}

#endif

public SetScore()
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        Score[i]=GetPlayerMoney(i);
        SetPlayerScore(i, Score[i]);
    }
    return 1;
}

public OnGameModeInit()
{
    // Don'
t use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Now as we have downloaded dini.inc (and placed it on include and pawno>include folder)
we can add this near #include <a_samp>:

pawn Код:
#include <dini>
What that do? that includes dini, that is for saving files.
Okay, we start by creating a folder in our scriptfiles folder. Call it "Users" (Capitalized).
Now to the script...

pawn Код:
public OnPlayerConnect(playerid)
{
    new pname[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    return 1;
}
that will get the name of the player.
we create a string... pname and we Get the PlayerName
sizeof(pname) basically returns 128, why? cause [128] is the size of the string.
Okay now we will start to use dini.
First let's check if the user file exists.
we will use format(.
Format is like printf()
%s, %d, %i. etc.

now... we will put this near GetPlayerName
pawn Код:
format(file, sizeof(file), "Users/%s.ini", pname);
Notice a difference?
sizeof(file) right?
well this is how to use format:
format(output, sizeofoutput, formattedtext, ....);
so we now have the FILE of the user that has just connected.
Now let's check if the file exists.
Now, on the top of the file put this:
pawn Код:
#define COLOR_GREY        0xAFAFAFAA
Why? that's a Hexadecimal color for the COLOR Grey.
Now we will introduce a new function called
SendClientMessage(playerid, COLOR, string);
that sends a message in the game to the player.
so let's add this next to format();
pawn Код:
if(dini_Exists(file))
    {
    }else{
    }
we have this at the moment on OnPlayerConnect:
pawn Код:
public OnPlayerConnect(playerid)
{
    new pname[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    new file[128];
    format(file, sizeof(file), "Users/%s.ini", pname);
    if(dini_Exists(file))
    {
    }else{
    }
    return 1;
}
that last code checks if the file exists.
Now, basically, let's learn the new functions...
dini_Exists: basically checks if a file exists, it will return 1 if the file exists!
so yes, let's continue...
inside that, let's add...
pawn Код:
public OnPlayerConnect(playerid)
{
    new pname[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    new file[128];
    format(file, sizeof(file), "Users/%s.ini", pname);
    if(dini_Exists(file))
    {
        // means the file exists!
    }else{
        dini_Create(file);
    }
    return 1;
}
so that will basically, create the file, that dini_Create is used to create files, it can be .ini, .txt!
now, we have a player file created!

Register System!

Now we will work on a register system, which is something slightly more complex for begginers.
At the moment, our code is:
pawn Код:
/*
Developer: Christian
This script is created to teach users
the programming language used in
sa-mp, "pawn". This script can be
copied, used, modified or whatever
they want, i don't care. i only want
you to leave the credits as they are.
*/


#include <a_samp>
#include <dini>

#define DEVELOPER "Christian"
#define VERSION "v.0.0.1a"
#undef MAX_PLAYERS
#define MAX_PLAYERS 50
new Score[MAX_PLAYERS];
forward SetScore();

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("Tutorial Script");
    printf("Version: %s", VERSION);
    printf("Developer: %s", DEVELOPER);
}

#endif

public SetScore()
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        Score[i]=GetPlayerMoney(i);
        SetPlayerScore(i, Score[i]);
    }
    return 1;
}

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new pname[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    new file[128];
    format(file, sizeof(file), "Users/%s.ini", pname);
    if(dini_Exists(file))
    {
        // means the file exists!
    }else{
        dini_Create(file);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
So, now, let's create a public function, again, public functions are only used when we use timers, so that's what we are going to use.
pawn Код:
forward OnPlayerRegister(playerid, step);
public OnPlayerRegister(playerid, step)
{
    return 1;
}
Oh no! Look! a forward! Why god? I'll have to explain them what a forward is!
Well, instead of raging and quitting sa-mp, let's say every single public (that is not pre-defined, as the ones you can see, as they are already forwarded in a_samp) must be forwarded, otherwise you recieve warnings...
Wasn't that hard huh?

But every single public function need to be called! so yeah, let's call it!

[PAWN]
public OnPlayerConnect(playerid)
{
new pname[128];
GetPlayerName(playerid, pname, sizeof(pname));
new file[128];
format(file, sizeof(file), "Users/%s.ini", pname);
if(dini_Exists(file))
{
// means the file exists!
}else{
dini_Create(file);
OnPlayerRegister(playerid, 1);
}
return 1;
}
[PAWN]
so yeah, I added it OnPlayerConnect, but wait a second, what if they /quit while the tutorial is on?
let's add something else to the OnPlayerConnect...
change...
pawn Код:
if(dini_Exists(file))
to...
pawn Код:
if(!dini_Exists(file))
Oh God! a "!", so complex!, basically, if ... "if(dini_Exists)" returned 1, now the "1" will check if it returns 0.
So now...
pawn Код:
public OnPlayerConnect(playerid)
{
    new pname[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    new file[128];
    format(file, sizeof(file), "Users/%s.ini", pname);
    if(!dini_Exists(file))
    {
        dini_Create(file);
        OnPlayerRegister(playerid, 1);
    }
    return 1;
}
That will mean, if the file DOESN'T Exist, the file will get created, but still we have the same problem, if they quit while the tutorial is on, they will be considered as registered.
pawn Код:
public OnPlayerConnect(playerid)
{
    new pname[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    new file[128];
    format(file, sizeof(file), "Users/%s.ini", pname);
    if(!dini_Exists(file))
    {
        dini_Create(file);
        OnPlayerRegister(playerid, 1);
    }
    if(dini_Int(pfile, "Registered") == 0)
    {
        OnPlayerRegister(playerid, 1);
    }
    return 1;
}
Before you shot yourself after reading that, let me explain it on a simple way.
I did explain what a integrer is right? Well here, my friend, you will read a field.
a INI file is a file that is used to save stats, it's like...
"Registered=1", which means he is registered.
Now it will check if he was registered!

My first tutorial
oh my good! My first tutorial! I'm so excited, i'll be able to impress my girlfriend saying I'm a professional scripter! Well, yeah my friend, today is the day you were waiting for, today your dreams become true, you will make your first tutorial.

So we had this sexy public function:
pawn Код:
forward OnPlayerRegister(playerid, step);
public OnPlayerRegister(playerid, step)
{
    return 1;
}
It's so complex, it has a return 1, it's simply sexy.
but what about we make it more sexy?
You notice the "step", that's the step of our tutorial, ever noticed how in a server the text started to pass and it looked so complex? Well yeah, you, my friend, are going to do that.

Let's start by such a simple thing, as adding the step number 1.

pawn Код:
forward OnPlayerRegister(playerid, step);
public OnPlayerRegister(playerid, step)
{
    if(step == 1)
    {
   
    }
    return 1;
}
Was that hard?
Anyways, so yes, currently if the user presses SHIFT or presses the SPAWN button, he can spawn, don't worry, we will delete that soon.
But, for a tutorial to be considered a tutorial, you need cameras!

Time for some In Game action my friend, don't rage now, partner, medics are incoming!
It's time... to... Press F5!



Oh! Oh oh my god! how could I forgot about pfile!
We got our first error, how exciting.
Sometimes pressing F5 can be as exciting as buying Modern Warfare 2 and not being able to run it.

pawn Код:
public OnPlayerConnect(playerid)
{
    new pname[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    new file[128];
    format(file, sizeof(file), "Users/%s.ini", pname);
    if(!dini_Exists(file))
    {
        dini_Create(file);
        OnPlayerRegister(playerid, 1);
    }
    if(dini_Int(pfile, "Registered") == 0)
    {
        OnPlayerRegister(playerid, 1);
    }
    return 1;
}
So yes, try to find the error, we had a "file" function, but we have a "pfile", which means, we need to use "file" instead of "pfile".
pawn Код:
public OnPlayerConnect(playerid)
{
    new pname[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    new file[128];
    format(file, sizeof(file), "Users/%s.ini", pname);
    if(!dini_Exists(file))
    {
        dini_Create(file);
        OnPlayerRegister(playerid, 1);
    }
    if(dini_Int(file, "Registered") == 0)
    {
        OnPlayerRegister(playerid, 1);
    }
    return 1;
}
Good Job! You are learning to fix errors!
Now Press F5, only a stupid warning about strtok, which doesn't matter for now.
Now open your console, which is samp-server.exe.



Wow, a black console! That's so sexy!
That's called our console, and everything is working correctly up to now!
But we need to take camera coords (to make the camera change of position and that stuff you see in a tutorial), so, i'm scared my friend, it's time for...

THE /V COMMAND!!!
OH GOD! OH NO! THE /V COMMAND!
NOW WE MUST USE 2 MORE INCLUDES!
Well yeah, for this part we will use zcmd and sscanf, which are easier to use.
You already installed dini, so what about we install zcmd, which is almost the same, a include.
Our friend ZeeX made it, so that you guys don't shoot your PC with a M4A1.
Here, click this.
Now, time to download, SSCANF2.

here, click this
our friend ****** (very good scripter and software engineer, to be honest), created this include so that we can make params as fast as saying "hi".
but, this is a bit complex to install,
first of all, add the .inc to your pawno>includes folder, then, on the main server folder, create a folder called "plugins", and now, inside place the .dll / .so, now open server.cfg, and add a new line, plugins.
like this:
Код:
echo Executing Server Config...
lanmode 0
rcon_password idontknowhowtoscriptpleasehelpme
maxplayers 500
port 7777
hostname [0.3] My Test Server
gamemode0 tutscript
filterscripts 
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
plugins sscanf
Was that hard? if you are in linux....

Код:
echo Executing Server Config...
lanmode 0
rcon_password idontknowhowtoscriptpleasehelpme
maxplayers 500
port 7777
hostname [0.3] My Test Server
gamemode0 tutscript
filterscripts 
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
plugins sscanf.so
Now, inside your script...
pawn Код:
#include <a_samp>
#include <dini>
#include <zcmd>
#include <sscanf2>
Yep! Yep!, We are done with those bastard includes, we neutralized our problem! Target neutralized.
Now... we have this...
pawn Код:
/*
Developer: Christian
This script is created to teach users
the programming language used in
sa-mp, "pawn". This script can be
copied, used, modified or whatever
they want, i don't care. i only want
you to leave the credits as they are.
*/


#include <a_samp>
#include <dini>
#include <zcmd>
#include <sscanf2>

#define DEVELOPER "Christian"
#define VERSION "v.0.0.1a"
#undef MAX_PLAYERS
#define MAX_PLAYERS 50
new Score[MAX_PLAYERS];
forward SetScore();

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("Tutorial Script");
    printf("Version: %s", VERSION);
    printf("Developer: %s", DEVELOPER);
}

#endif

public SetScore()
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        Score[i]=GetPlayerMoney(i);
        SetPlayerScore(i, Score[i]);
    }
    return 1;
}

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

forward OnPlayerRegister(playerid, step);
public OnPlayerRegister(playerid, step)
{
    if(step == 1)
    {
   
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    new pname[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    new file[128];
    format(file, sizeof(file), "Users/%s.ini", pname);
    if(!dini_Exists(file))
    {
        dini_Create(file);
        OnPlayerRegister(playerid, 1);
    }
    if(dini_Int(file, "Registered") == 0)
    {
        OnPlayerRegister(playerid, 1);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Wohoo our first 300 lines! Now instead of opening your wine bottles and getting grounded by your mom, press the F5 button in your keyboard.
woho, 1 warning (the strtok, which we will fix soon)!
now that we have that, let's work on the actual /v CMD.
with ZCMD, your commands are made like this:
pawn Код:
CMD:somethinghere(playerid, params[])
{
}
Basically, CMD makes it a public function, it's a macro.
let's work on our actual command.

pawn Код:
COMMAND:v(playerid, params[])
{
    // my first command, i'm so horny!
    return 1;
}
I added this on the bottom of my script, for order purposes.
that won't do nothing at the moment, what about we add the params.
pawn Код:
new vehicleid, color1, color2;
    if(!sscanf(params, "iii", vehicleid, color1, color2))
    {
    }
We add that to our command, what will that do?
We created 3 variables, to store our vehicleid and desired colors.
the if(!sscanf) will detect the parameters, and save them on the variables.

so yes...
pawn Код:
COMMAND:v(playerid, params[])
{
    // my first command, i'm so horny!
    new vehicleid, color1, color2;
    if(!sscanf(params, "iii", vehicleid, color1, color2))
    {
    }else{
    }
    return 1;
}
We have that.

on the else, it will be called, if for example, you do /v only, without params...
for you to understand it, let's add this:
pawn Код:
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_NAVY 0x000080AA
#define COLOR_AQUA 0xF0F8FFAA
#define COLOR_CRIMSON 0xDC143CAA
#define COLOR_FLBLUE 0x6495EDAA
#define COLOR_BISQUE 0xFFE4C4AA
#define COLOR_BLACK 0x000000AA
#define COLOR_CHARTREUSE 0x7FFF00AA
#define COLOR_BROWN 0XA52A2AAA
#define COLOR_CORAL 0xFF7F50AA
#define COLOR_GOLD 0xB8860BAA
#define COLOR_GREENYELLOW 0xADFF2FAA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_IVORY 0xFFFF82AA
#define COLOR_LAWNGREEN 0x7CFC00AA
#define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
#define COLOR_MIDNIGHTBLUE 0X191970AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OLIVE 0x808000AA
#define COLOR_ORANGERED 0xFF4500AA
#define COLOR_PINK 0xFFC0CBAA // - Light light pink
#define COLOR_SEAGREEN 0x2E8B57AA
#define COLOR_SPRINGGREEN 0x00FF7FAA
#define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
#define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
#define COLOR_MEDIUMAQUA 0x83BFBFAA
#define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^

#define COLOR_GREY        0xAFAFAFAA
#define COLOR_GREEN       0x33AA33AA
#define COLOR_BRIGHTRED   0xFF0000AA
#define COLOR_DARKRED     0xC60000FF
#define COLOR_YELLOW      0xFFFF00AA
#define COLOR_TAN         0xBDB76BAA
#define COLOR_PURPLE      0x800080AA
#define COLOR_WHITE       0xFFFFFFAA
#define COLOR_LIGHTBLUE   0x33CCFFAA
#define COLOR_ORANGE      0xFF9900AA
#define COLOR_INDIGO      0x4B00B0AA
#define COLOR_SYSTEM      0xa9c4e4
#define COLOR_SANTORANGE  0xFF6C3BAA
#define COLOR_INVIS       0xAFAFAF00
#define COLOR_CRIMBLUE    0x3A47DEFF
#define COLOR_WANTED      0xCC0066AA
#define COLOR_GROVE       0x378729FF
#define COLOR_BALLAS      0xA31D88FF
#define COLOR_DARKGREY    0x696969FF
#define COLOR_ERPSS       0x549852FF
#define COLOR_L1A         0x50A2ABFF
#define COLOR_FADE1       0xE6E6E6E6
#define COLOR_FADE2       0xC8C8C8C8
#define COLOR_FADE3       0xAAAAAAAA
#define COLOR_FADE4       0x8C8C8C8C
#define COLOR_FADE5       0x6E6E6E6E
#define BLACK             0x000000FF
On top of the script, this are colors, for the messages we will send to the players, just add it near the #includes.
We have this:
pawn Код:
/*
Developer: Christian
This script is created to teach users
the programming language used in
sa-mp, "pawn". This script can be
copied, used, modified or whatever
they want, i don't care. i only want
you to leave the credits as they are.
*/


#include <a_samp>
#include <dini>
#include <zcmd>
#include <sscanf2>

#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_NAVY 0x000080AA
#define COLOR_AQUA 0xF0F8FFAA
#define COLOR_CRIMSON 0xDC143CAA
#define COLOR_FLBLUE 0x6495EDAA
#define COLOR_BISQUE 0xFFE4C4AA
#define COLOR_BLACK 0x000000AA
#define COLOR_CHARTREUSE 0x7FFF00AA
#define COLOR_BROWN 0XA52A2AAA
#define COLOR_CORAL 0xFF7F50AA
#define COLOR_GOLD 0xB8860BAA
#define COLOR_GREENYELLOW 0xADFF2FAA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_IVORY 0xFFFF82AA
#define COLOR_LAWNGREEN 0x7CFC00AA
#define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
#define COLOR_MIDNIGHTBLUE 0X191970AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OLIVE 0x808000AA
#define COLOR_ORANGERED 0xFF4500AA
#define COLOR_PINK 0xFFC0CBAA // - Light light pink
#define COLOR_SEAGREEN 0x2E8B57AA
#define COLOR_SPRINGGREEN 0x00FF7FAA
#define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
#define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
#define COLOR_MEDIUMAQUA 0x83BFBFAA
#define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^

#define COLOR_GREY        0xAFAFAFAA
#define COLOR_GREEN       0x33AA33AA
#define COLOR_BRIGHTRED   0xFF0000AA
#define COLOR_DARKRED     0xC60000FF
#define COLOR_YELLOW      0xFFFF00AA
#define COLOR_TAN         0xBDB76BAA
#define COLOR_PURPLE      0x800080AA
#define COLOR_WHITE       0xFFFFFFAA
#define COLOR_LIGHTBLUE   0x33CCFFAA
#define COLOR_ORANGE      0xFF9900AA
#define COLOR_INDIGO      0x4B00B0AA
#define COLOR_SYSTEM      0xa9c4e4
#define COLOR_SANTORANGE  0xFF6C3BAA
#define COLOR_INVIS       0xAFAFAF00
#define COLOR_CRIMBLUE    0x3A47DEFF
#define COLOR_WANTED      0xCC0066AA
#define COLOR_GROVE       0x378729FF
#define COLOR_BALLAS      0xA31D88FF
#define COLOR_DARKGREY    0x696969FF
#define COLOR_ERPSS       0x549852FF
#define COLOR_L1A         0x50A2ABFF
#define COLOR_FADE1       0xE6E6E6E6
#define COLOR_FADE2       0xC8C8C8C8
#define COLOR_FADE3       0xAAAAAAAA
#define COLOR_FADE4       0x8C8C8C8C
#define COLOR_FADE5       0x6E6E6E6E
#define BLACK             0x000000FF

#define DEVELOPER "Christian"
#define VERSION "v.0.0.1a"
#undef MAX_PLAYERS
#define MAX_PLAYERS 50
new Score[MAX_PLAYERS];
forward SetScore();

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("Tutorial Script");
    printf("Version: %s", VERSION);
    printf("Developer: %s", DEVELOPER);
}

#endif

public SetScore()
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        Score[i]=GetPlayerMoney(i);
        SetPlayerScore(i, Score[i]);
    }
    return 1;
}

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

forward OnPlayerRegister(playerid, step);
public OnPlayerRegister(playerid, step)
{
    if(step == 1)
    {
   
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    new pname[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    new file[128];
    format(file, sizeof(file), "Users/%s.ini", pname);
    if(!dini_Exists(file))
    {
        dini_Create(file);
        OnPlayerRegister(playerid, 1);
    }
    if(dini_Int(file, "Registered") == 0)
    {
        OnPlayerRegister(playerid, 1);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}

COMMAND:v(playerid, params[])
{
    // my first command, i'm so horny!
    new vehicleid, color1, color2;
    if(!sscanf(params, "iii", vehicleid, color1, color2))
    {
    }else{
    }
    return 1;
}
Now, let's work on SendClientMessage! Woho! We will send our first message!

pawn Код:
COMMAND:v(playerid, params[])
{
    // my first command, i'm so horny!
    new vehicleid, color1, color2;
    if(!sscanf(params, "iii", vehicleid, color1, color2))
    {
    }else{
        SendClientMessage(playerid, COLOR_GREY, "ERROR: This command requires: /v [vehicleid][color1][color2]");
    }
    return 1;
}
That will send a message to "playerid", in "Color Grey", saying "ERROR:" bla bla bla.
Yes, very simple? Well, now time to work on the other side of the table...
pawn Код:
if(!sscanf(params, "iii", vehicleid, color1, color2))
    {
        new vin;
Every vehicle has a vin, like your class number, 1, 2, 3, 4, 5.
We need this vin to edit the vehicle.
And we also want the vehicle to appear in the position of the player right?
pawn Код:
new Float:x, Float:y, Float:z;
this will store the coords of the player...
So we have this...
pawn Код:
COMMAND:v(playerid, params[])
{
    // my first command, i'm so horny!
    new vehicleid, color1, color2;
    if(!sscanf(params, "iii", vehicleid, color1, color2))
    {
        new vin;
        new Float:x, Float:y, Float:z;
    }else{
        SendClientMessage(playerid, COLOR_GREY, "ERROR: This command requires: /v [vehicleid][color1][color2]");
    }
    return 1;
}
now, a float is a complex number, which can be 1.90990990, or 25.0.
so yes, let's work on getting the coords...
pawn Код:
COMMAND:v(playerid, params[])
{
    // my first command, i'm so horny!
    new vehicleid, color1, color2;
    if(!sscanf(params, "iii", vehicleid, color1, color2))
    {
        new vin;
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
    }else{
        SendClientMessage(playerid, COLOR_GREY, "ERROR: This command requires: /v [vehicleid][color1][color2]");
    }
    return 1;
}
that will store on x, y, z the POSITION / COORDS of the player.

pawn Код:
COMMAND:v(playerid, params[])
{
    // my first command, i'm so horny!
    new vehicleid, color1, color2;
    if(!sscanf(params, "iii", vehicleid, color1, color2))
    {
        new vin;
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        CreateVehicle(vehicleid, x, y, z, 0.0, color1, color2, -1);
    }else{
        SendClientMessage(playerid, COLOR_GREY, "ERROR: This command requires: /v [vehicleid][color1][color2]");
    }
    return 1;
}
SO that creates the vehicle itself, the vehicletype, x, y, z, rotation to 0.0, and the colors required.
THAT -1 is so that the vehicle won't respawn!
But, let's put the player inside the vehicle!
add:
pawn Код:
vin=CreateVehicle(vehicleid, x, y, z, 0.0, color1, color2, -1);
Why? as I already explained, we need to store the vin so we can edit the vehicle!
and now...
pawn Код:
PutPlayerInVehicle(playerid, vin, 0);
That basically puts the player in the "vin" (vehicle), in seat 0 (driver).
We have this:
pawn Код:
/*
Developer:  Christian
This script is created to teach users
the programming language used in
sa-mp, "pawn". This script can be
copied, used, modified or whatever
they want, i don't care. i only want
you to leave the credits as they are.
*/


#include <a_samp>
#include <dini>
#include <zcmd>
#include <sscanf2>

#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIME 0x10F441AA
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_NAVY 0x000080AA
#define COLOR_AQUA 0xF0F8FFAA
#define COLOR_CRIMSON 0xDC143CAA
#define COLOR_FLBLUE 0x6495EDAA
#define COLOR_BISQUE 0xFFE4C4AA
#define COLOR_BLACK 0x000000AA
#define COLOR_CHARTREUSE 0x7FFF00AA
#define COLOR_BROWN 0XA52A2AAA
#define COLOR_CORAL 0xFF7F50AA
#define COLOR_GOLD 0xB8860BAA
#define COLOR_GREENYELLOW 0xADFF2FAA
#define COLOR_INDIGO 0x4B00B0AA
#define COLOR_IVORY 0xFFFF82AA
#define COLOR_LAWNGREEN 0x7CFC00AA
#define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
#define COLOR_MIDNIGHTBLUE 0X191970AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OLIVE 0x808000AA
#define COLOR_ORANGERED 0xFF4500AA
#define COLOR_PINK 0xFFC0CBAA // - Light light pink
#define COLOR_SEAGREEN 0x2E8B57AA
#define COLOR_SPRINGGREEN 0x00FF7FAA
#define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
#define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
#define COLOR_MEDIUMAQUA 0x83BFBFAA
#define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^

#define COLOR_GREY        0xAFAFAFAA
#define COLOR_GREEN       0x33AA33AA
#define COLOR_BRIGHTRED   0xFF0000AA
#define COLOR_DARKRED     0xC60000FF
#define COLOR_YELLOW      0xFFFF00AA
#define COLOR_TAN         0xBDB76BAA
#define COLOR_PURPLE      0x800080AA
#define COLOR_WHITE       0xFFFFFFAA
#define COLOR_LIGHTBLUE   0x33CCFFAA
#define COLOR_ORANGE      0xFF9900AA
#define COLOR_INDIGO      0x4B00B0AA
#define COLOR_SYSTEM      0xa9c4e4
#define COLOR_SANTORANGE  0xFF6C3BAA
#define COLOR_INVIS       0xAFAFAF00
#define COLOR_CRIMBLUE    0x3A47DEFF
#define COLOR_WANTED      0xCC0066AA
#define COLOR_GROVE       0x378729FF
#define COLOR_BALLAS      0xA31D88FF
#define COLOR_DARKGREY    0x696969FF
#define COLOR_ERPSS       0x549852FF
#define COLOR_L1A         0x50A2ABFF
#define COLOR_FADE1       0xE6E6E6E6
#define COLOR_FADE2       0xC8C8C8C8
#define COLOR_FADE3       0xAAAAAAAA
#define COLOR_FADE4       0x8C8C8C8C
#define COLOR_FADE5       0x6E6E6E6E
#define BLACK             0x000000FF

#define DEVELOPER "Christian"
#define VERSION "v.0.0.1a"
#undef MAX_PLAYERS
#define MAX_PLAYERS 50
new Score[MAX_PLAYERS];
forward SetScore();

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("Tutorial Script");
    printf("Version: %s", VERSION);
    printf("Developer: %s", DEVELOPER);
}

#endif

public SetScore()
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        Score[i]=GetPlayerMoney(i);
        SetPlayerScore(i, Score[i]);
    }
    return 1;
}

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

forward OnPlayerRegister(playerid, step);
public OnPlayerRegister(playerid, step)
{
    if(step == 1)
    {
   
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    new pname[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    new file[128];
    format(file, sizeof(file), "Users/%s.ini", pname);
    if(!dini_Exists(file))
    {
        dini_Create(file);
        OnPlayerRegister(playerid, 1);
    }
    if(dini_Int(file, "Registered") == 0)
    {
        OnPlayerRegister(playerid, 1);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}

COMMAND:v(playerid, params[])
{
    // my first command, i'm so horny!
    new vehicleid, color1, color2;
    if(!sscanf(params, "iii", vehicleid, color1, color2))
    {
        new vin;
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        vin=CreateVehicle(vehicleid, x, y, z, 0.0, color1, color2, -1);
        PutPlayerInVehicle(playerid, vin, 0);
    }else{
        SendClientMessage(playerid, COLOR_GREY, "ERROR: This command requires: /v [vehicleid][color1][color2]");
    }
    return 1;
}
With the fully working /v command! What about we start working on the actual tutorial?!?
Let's press the Sexy F5 button, and open our sexy black console, and get inside our sexy server, on your sa-mp, add this server: 127.0.0.1:7777, and get in game!

When we get inside, let's spawn a chopper (/v 487 0 0 with the command we have), and fly to our desired location, here we have my screenshots:

First, we decided a place to hide the player, if you don't set the player pos, the camera will look crappy as the player will be in coords 0.0, 0.0, 0.0. So yes, hide the player in a intelligent position.

and type /save (Description), now, let's pick a camera initial position, this is the position where the camera will be at.


Excellent, now we save where the camera will look at, in which direction...


If you didn't understand a line of what I just said, don't be afraid to ask a question iin this topic.
So let's go to "My Documents > GTA San Andreas User File > SAMP > savedpositions.txt", in my case, I have this:
Код:
AddStaticVehicle(487,1758.8578,-1871.2877,30.0641,95.6751,0,0); // Here we will put the player
AddStaticVehicle(487,1781.1493,-1833.0995,33.3569,11.3549,0,0); // camera
AddPlayerClass(0,1781.0450,-1808.2030,13.5312,11.4841,0,0,0,0,0,0); // look at
So, let's analize it...
Quote:

AddStaticVehicle(487,1758.8578,-1871.2877,30.0641,95.6751,0,0); // Here we will put the player
AddStaticVehicle(487,1781.1493,-1833.0995,33.3569,11.3549,0,0); // camera
AddPlayerClass(0,1781.0450,-1808.2030,13.5312,11.4841,0,0,0,0,0,0); // look at

so yes, it's basically "x, y, z", after the "skin id" or "vehicle id", that's our coords, let's go to our code...

pawn Код:
forward OnPlayerRegister(playerid, step);
public OnPlayerRegister(playerid, step)
{
    if(step == 1)
    {
        SetPlayerPos(playerid, 1758.8578,-1871.2877,30.0641); // Hidden Player
        SetPlayerCameraPos(playerid, 1781.1493,-1833.0995,33.3569); // Camera Pos
        SetPlayerCameraLookAt(playerid, 1781.0450,-1808.2030,13.5312); // Camera Look At
    }
    return 1;
}
So we have 3 new concepts...
SetPlayerPos(playerid, Float:x, Float:y, Float:z); - Sets the player pos.
SetPlayerCameraPos(playerid, Float:x, Float:y, Float:z); - Sets the camera pos.
SetPlayerCameraLookAt(playerid, Float:x, Float:y, Float:z); - Sets the camera direction.
We have our basic camera system, let's add text...

pawn Код:
forward OnPlayerRegister(playerid, step);
public OnPlayerRegister(playerid, step)
{
    if(step == 1)
    {
        SetPlayerPos(playerid, 1758.8578,-1871.2877,30.0641); // Hidden Player
        SetPlayerCameraPos(playerid, 1781.1493,-1833.0995,33.3569); // Camera Pos
        SetPlayerCameraLookAt(playerid, 1781.0450,-1808.2030,13.5312); // Camera Look At
        SendClientMessage(playerid, COLOR_WHITE, "==============================================================================");
        SendClientMessage(playerid, COLOR_WHITE, "Deskoft's Freeroam/Roleplay Script");
        SendClientMessage(playerid, COLOR_GREY, "Welcome to Deskoft's Freeroam/Roleplay Script! We are proud to have you here.");
        SendClientMessage(playerid, COLOR_GREY, "This is the tutorial, in which you will create your account.");
        SendClientMessage(playerid, COLOR_GREY, "Please wait while we load and save the required files.");
        SendClientMessage(playerid, COLOR_WHITE, "==============================================================================");
    }
    return 1;
}

This tutorial is an introduction to our Pawn Classroom! Be sure to check it out if you are trying to learn PAWN!
Reply
#2

FAQ
1. Why did you create a new topic, with a new account?
Mainly, because the old user wanted me to continue the tutorial, plus, he is retired from gaming.

2. Everything's on the wiki!
Yeah, I agree, some people want it all together on a same tutorial, though.

3. Why all the errors?
His english was horrible, he told me just to publish it, and I had to ask him if I was able to edit it, I have made some modifications, aswell as some requests from Christian. My english is not that good either. It's a SUPER long tutorial, I find my time very limited, therefore, it's almost impossible for me to actually correct all the errors, sorry!

4. Who made this tutorial?
Christian, he is my friend. He had some private matters to attend, with her sister Jennifer, both of them were into gaming, both of them worked with me at Lawedan, and both of them created this tutorial.

5. Why are you posting it then?
As stated in number 1, he asked me to continue this tutorial, as I was in that time, when they resigned, the only user with advanced programming knowledge.

6. Where did he learn to script / Sources ?
I never asked him, therefore, I can't answer that question.

7. Where did YOU learn to script?
I am currently studying Software Engineering.

8. This tutorial is not well explained!
I don't think that's true, as of now, I seldom receive inquiries about stuff explained on this tutorial, the original guide required some explanation, and yes, I've done that.

9. Are you continuing this tutorial?
Yes, I am.

I AM NOT THE ONLY ONE WORKING ON THIS GUIDE, ALL THE SCRIPTERS IN LAWEDAN COMPUTERS, INC HAVE CONTRIBUTED, OUR WIKI AND BLOG EDITORS HAVE CONTRIBUTED WITH SCREENSHOTS!
Reply
#3

Good work. Thanks for the tutorial.
Reply
#4

What a long tutorial!

You've must took some time to type it!

And, this is a very nice tutorial for me.
Reply
#5

Im sure you had to drink a lot of water while making this tutorial.

Great job man.
Reply
#6

I saw the same tutorial somewhere else or atleast similar. It was made by Christian_Larrabure..

Edit: Christian_Larrabure is Deskoft

Nice tutorial!
Reply
#7

Thanks, i'm trying to help the members.
Reply
#8

Sorry for double post! Updated the tutorial.
Reply
#9

Great tutorial. One of the best beginner scripts ever. Thanks a lot
Reply
#10

Updated! - Added the first part of the tutorial.
Reply
#11

This helped me ALOT.
Reply
#12

looooooooool i need to make tyrent and nemsis and stars and uc and uss on my zombie server
the name is resident evill opertion raccon city but it is offlind
can u help me and tanx
Reply
#13

goooooooood wooooork
Reply
#14

good job man this helped me
Reply
#15

Great Job, will help a few out there
Reply
#16

Woah, huge tutorial, well explained. You covered pretty much everything a beginner should know. Congratz and thanks for it.
Reply
#17

I'm working on a new version, with a friendly design, and more advanced, too.
Reply
#18

The best tutorial i've been ever seen... Thanks !

P.S. - Rep+
Reply
#19

WOW, thanks a lot man I appreciate this sooooooooooooo muchhhhhhhh helped me get on with my own GM
Reply
#20

WOOOW! I found it, this is the tutorial where i got pawn's knowledge from! Finally i found it. This is a AMAZING, tutorial!
Awesomejob christian!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)