Grove Street

GTA SA IS LIFE


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 (or LAN) with up to 200 other people. You need the original Grand Theft Auto: San Andreas game to play San Andreas Multiplayer.

[edit] Features

In SA:MP you are able to do almost anything that you can do in single player GTA. SA:MP also features the ability to create your own scripted game mods

[edit] Gamemodes

For more detailed information, see Gamemodes

Gamemode Description
LVDM (aka Moneygrub) Win this gamemode by being the player with the most money, obtained in any way you see fit. A popular gamemode on many servers due to its lack of any 'real' objective, making it a freeroam mode
San Fierro TDM A Team Deathmatch based in San Fierro, where you must stick with your team to become the player with the highest score.
Rivershell A water-based CTF gamemode, where your team must win by capturing a slow moving boat from the opposing teams base before they capture your team's.
Local Yokel SE The same as Rivershell, but based on land using sports cars (the SE stands for sports edition)
Cops 'n' Gangs Another CTF gamemode, this time between the Los Santos Police and the Grove Street Families - the objective vehicle being a slow-moving van.
Area51 An Assault gamemode, where attackers must break into Area 51 by parachuting while the military and scientists defend.
Freighter A water-based Area 51, where Triads must break into a rival gang's (the Da Nang Boys') freight ship, using speedboats and helicopters.
Manhunt-LV One person is chosen to be the 'hunted' person, while everyone else must chase him down and kill him. The person who kills the 'hunted' becomes the hunted himself.
LS Parachute A fun gamemode with no objective other than to parachute off tall buildings - popular by people making gameplay videos
Minigun Madness Another fun mode, made to give people a break from the standard objective-based modes. All the players are locked in a small compound in a free-for-all with only miniguns to defend themselves.
Monster A freeroam mode where everyone spawns at the desert airstrip with only monster trucks for transport. Was popular during the private beta testing

[edit] System Requirements

SA:MP will run on any computer that will run San Andreas single player, but give better performance in most cases. However, if you are playing on larger servers, the game may run slower at times if you have a lower spec.

[edit] Requirements

[edit] Minimum

  • 1 GHz Processor
    • Pentium 3 / Athlon or equivalent
  • 256MB RAM
  • Win 98/Me/2000/Xp
  • 64MB Graphics Card (DirectX 9 compatible)
    • Radeon 8500 / GeForce 3 or equivalent
  • 8X DVD-ROM Drive
  • 3.6GB free HD space
  • DirectX 9 compatible soundcard

[edit] Recommended

    • Intel pentium 4 HT 2,8 Ghz Processor Intel pentium D 3.0 GHZ / AMD Athlon X2 3800+
    • 1GB RAM
  • Win 98/Me/2000/Xp
  • PCIe 256MB Graphics Card (DirectX 9c compatible)
    • Radeon X800 / GeForce 6,7 or equivalent
  • 16X DVD-ROM Drive
  • 5.0GB free HD space
  • DirectX 9 compatible soundcard

[edit] SA:MP specific

In addition to the standard Single Player requirements, SA:MP needs the following:

  • 4.7MB free Hard Drive space
  • An Internet Connection (512k+ Broadband is highly recommended for smooth online play)
  • A copy of GTA San Andreas for PC - V1.0 or V1.01 [NOT V2.0]

Getting Started

From SA-MP

Jump to: navigation, search

Contents

[hide]


[edit] Download

The first and easiest step is to download the SA:MP Client from the website. The download page can be found at http://www.sa-mp.com/download.php - It is necessary to regularly check this page, especially if you get "Incorrect Version" errors after a few weeks.

[edit] Install

Simply run the downloaded .exe file and install to your GTA San Andreas folder. The default directory is:

C:\Program Files\Rockstar Games\GTA San Andreas\

It is very important that SA:MP is installed in the same place as gta_sa.exe. This is important as SA:MP needs the core San Andreas files to run. You should see the following window with your San Andreas directory pre-selected. If it is slected, click install - if not, browse for the directory first.

Image:Client-install-window.jpg


This automatic installation process should place a shortcut named SAMP on your desktop - just open this file to choose a server.

Image:Sampicon.jpg

[edit] Find a Server

A screenshot showing the SA:MP browser, with littlewhitey's popular 100 player server selected
A screenshot showing the SA:MP browser, with littlewhitey's popular 100 player server selected

Finding a server is simple - run the newly created shortcut on your desktop (samp.exe), and the browser will pop up. Click on the "internet" tab at the bottom of the client to query the masterlist, and you will see what is shown on the image to the right.


The only neccessary user input to this page is to enter your name in the "name" field, to the top of the browser window. Then, simply choose a server you want, right-click on it, and press "Connect". If all goes well, this will load up San Andreas with the selected server, and you will be playing San Andreas with anywhere up to 200 other people!


If the online play doesn't start, see the list of common problems.

[edit] Your First View

A screenshot showing a typical class selection screen (From littlewhitey's server, running LVDM)
A screenshot showing a typical class selection screen (From littlewhitey's server, running LVDM)

The first you will see in San Andreas Multiplayer is class selection, where you choose the skin you wish to play as. In some gamemodes choosing a skin will choose what team you are in, or what role you will play in the game. Different skins may also have different weapons - it is all Gamemode-dependent. In the gamemode shown, LVDM, the skin does not have any special abilities, weapons or roles - it is simply cosmetic. To scroll through available skins press the left or right keys on your keyboard, and press your Shift key to spawn. If a skin is part of a certain team then scrolling through them will normally show which team you will be on if you where to choose said skin.

A number of other key elements of SA:MP can be seen in the screenshot, which I will now detail.







[edit] Chat Box

The chatbox can be found in the top-left corner of the screen, and provides a way for users to talk with each other. You can type messages by using the T, `, or F6 keys. You can toggle the chat window on and off using the F7 key.

[edit] Kill Info Window

The "kill info window" can be found in the middle of the right side of the screen. It shows who killed who and what the death weapon was, as well as showing suicides or generic deaths. It can be shown/hidden by pressing F9.

[edit] Class Info Box

The Class info window is a special one, as it only appears when you are at the Class Selection Screen. It gives details on the class you are viewing in the screen, such as what weapons it has and what its model number is. This window also gives info about what version of SA:MP you are playing - 0.2.0 in the screenshot.

[edit] Game Commands

As SA:MP is built on top of the San Andreas game, nearly all the commands are exactly the same as single player with the exception of a few SA:MP-specific commands :-

Key Description
F1 Displays the in-game help menu
T Allows you to chat & enter commands
Shift Selects a character while at the spawn screen
F4 Allows you to reselect a character (on death)
F5 Shows the network data (eg: bandwidth usage)
F6 An alternate of "T" (chat)
F7 Shows/hides the chat window
F8 Takes a screenshot
F9 Shows/hides the "death" window
G Allows you to enter a car as a passenger
H Allows you to shoot while passenger (with a SMG)
` (key under esc) Shows/hides your current typing
As for all other commands, they are exactly the same as single player. If you have never played San Andreas before it is highly recommended that you play through Single Player first - even if it is only the first few missions. A lot of playing SA:MP involves knowledge of single player itself, especially tasks such as driving around or looking for places to buy health/weapons.
 

Common Problems

From SA-MP

Jump to: navigation, search

Contents

[hide]

[edit] Client

[edit] I get the error "San Andreas cannot be found"

San Andreas Multi-player is not a stand-alone program! It adds multi-player functionality to San Andreas, and thus you need GTA San Andreas for the PC - it also needs to be UK/US v1, other versions will not work and are highly unlikely to be added in the future.

[edit] Loading SA:MP gives lots of errors (Access Violation)

To fix the error use Ctrl+alt+del to close SA:MP (if it is still open) and install the 0.1b browser patch, located here.

[edit] I can not see any servers in SA:MP

First off, ensure you are following the procedures set out in the Quick-start guide. If you have followed what it says, and still cannot see any servers, you must allow SA:MP access through your firewall. Unfortunately, due to the large amount of available firewall software, we can not offer further support on this - we suggest looking at the manufacturers website or trying a Google search.

[edit] Single Player Loads instead of SA:MP

YOU ARE NOT SUPPOSED TO SEE THE SINGLE PLAYER OPTIONS (NEW GAME, LOAD GAME, ETC) - SA:MP SHOULD LOAD BY ITSELF AND NOT PRESENT THESE OPTIONS. IF YOU SEE "NEW GAME" SINGLE PLAYER HAS LOADED, NOT SAN ANDREAS MULTIPLAYER.

Single Player can load for 2 reasons - you have installed SA:MP to the wrong folder, or you have the wrong version of San Andreas.

  • If you get the 1st screen, make sure that SA:MP was installed to your San Andreas folder (normally C:\Program Files\Rockstar Games\GTA San Andreas). It can also be caused by some firewalls not allowing SA:MP to load San Andreas - try disabling your firewall to see if it works.
  • If you get the second screen, you have the wrong version of San Andreas - you need UK/US v1.0 San Andreas in order to run SA:MP. If the screen says "1.01", simply reinstall from your DVD. If it says 2.0, this version was made unmodable by Rockstar. Please note that any German version will not work - v1.0 or otherwise.

[edit] I get "INVALID NICKNAME" when connecting to server

Ensure you are using no "Special" characters in your name (use 0-9, a-z, {},[],() only), and that your name is no longer than 16 characters long.

[edit] Screen sticks at "Connecting to xxx.xxx.xxx.xx:xxxx"

The server could be offline, or if you cant connect to any server, disable your firewall and see if it works. If it does you must set up your firewall properly - go to its website to find out how.

[edit] I have a modified GTA: San Andreas, and my SA:MP won't load

Mods are not supported within SA:MP. Any modifications you have made will crash your game. Reinstall San Andreas again. Also, ensure that your directory looks like this. Do not use mods with SA:MP it's a bannable offense.

[edit] Crash: When I try to tune my car, the game crashes

Possible Solutions:

1)

  • Go to your My Documents/GTA SA User Files Folder.
  • Delete the file named gta_sa.set. This file contains your game configurations, the game will recreate this file when you start it next time with the default config.
  • Start SA:MP, try to mod your car
  • If it works, try to change settings (changing resolution, Visual effects, AA, etc.)

2)

  • Go to start > run > dxdiag
  • Click on the "Sound" tab.
  • Under "DirectX Features", set the "Hardware Sound Acceleration Level" to "Basic Acceleration" (Should also work on Standard Acceleration)
  • Click on "Save all Information", and Exit.

3)

  • Update your drivers

[edit] I'm getting an Exception while the Game loads

If you're getting an Exception like this:

  • EDIT: Exception At Address: 0x004F02D3
  • Last SCM Opcode: 0x581
  • Registers:
  • EAX: 0x00000039 EBX: 0x00B60000 ECX: 0x00000000 EDX: 0x00000000
  • ESI: 0x00B62CB0 EDI: 0x00B65238 EBP: 0x00000000 ESP: 0x0023FD8C
  • EFLAGS: 0x00210213

then:

  • Go to your My Documents/GTA SA User Files Folder.
  • Delete the file named gta_sa.set. This file contains your game configurations, the game will recreate this file when you start it :* next time with the default config.
  • Start SA:MP
  • If it works, try to change settings (changing resolution, Visual effects, AA, etc.)

[edit] When launching GTA with SA:MP it wont start

Make sure you don't have any cheats/mods and remove d3d9.dll from your GTA San Andreas folder if you have it.

[edit] When SA:MP loads I get Error Report

What I got to do.

Start GTA SA normal, change your language to English and now you will not get an error - it worked for me.

[edit] Server

[edit] Error: "Segmentation fault"

This error could be caused by a number of things, but the most common is a badly-written server.cfg - ensure there are no blank lines in your server.cfg

[edit] Server instantly crashes when started

Most commonly its a error in your server.cfg file. Check the server_log.txt and the reason should be printed out or in the crashinfo.txt file.

Category:Server Documentation

From SA-MP

Jump to: navigation, search

Articles in category "Server Documentation"

There are 6 articles in this category.

C

L

S

W

Scripting Basics

From SA-MP

Jump to: navigation, search

Contents

[hide]

[edit] Variable types

Variables are places you can use to store data. In PAWN the variable names are case sensitive, so a variable named "lolhax" is not the same as "LOLHAX" or "lOLhAx" for that matter; variable names must also start with a letter of the alphabet (A-Z)

[edit] Integer

This is the default variable type, it is used for storing whole numbers. You must not use numbers with decimal points as they are not whole numbers even if the numbers after the decimal point are all "0" (eg. 5.00) it is still not technically a whole number.

[edit] Example

 

[edit] Possible Usage

 
 

[edit] Float

Float variables are used to hold decimal places. These are named "floating point" numbers. While declaring a new float variable, prefix the variable name with "Float:".

 

[edit] Example

 
 
 

[edit] Possible Usage

 
 
 

[edit] String

Strings are storage places for characters (letters and/or symbols). Strings must be placed into an array, this is so each cell can hold a letter - you must specify an extra cell for the string

 

identifier "0".

[edit] Examples

 
 
 

[edit] Usual Usage

 
 
 

[edit] Possible Usage

 
 
 

[edit] Boolean

Used for true or false results. True is equal to 1 and false is equal to 0. New

booleans default to false.

 

[edit] Examples

 
 
 

[edit] Possible Usage

 
 
 

[edit] Array

Arrays are large storage places for data to be stored - they are like virtua

l tables. An array can contain integer, float, or boolean data. When you access your array, you need to start at cell 0 (NOT cell 1), and count up

to one less than the array's size.

 

[edit] One-dimensional array

A one-dimensional array is a single row split into the specified amount of

 

 cells.

 
 
 

[edit] Example

 
 
 

[edit] Possible Use

 
 
 

[edit] Two-dimensional array

Two dimensional array allows you to have many columns and rows. When you assign them, you must fill in all rows and columns - you can't specify 5 rows in the brackets, and

 

 only assign 3 of them.

 
 
 

[edit] Example

 
 
 

[edit] Possible Usage

 

 
 
 

[edit] Three-dimensional array - Two-dimensional array string

 

 

 
 
 

[edit] Two-dimensional array string

 

 

 
 
 

[edit] Conditionals

 

Conditionals allow you to see if data

 meets conditions then execute code

depending on the result. The most common type of conditional would

be the if/else conditional, but their are also many others - case, for loop and while loop.

[edit] if

The most common conditional, the if

statement checks to see if a set of

data in parenthesis meets conditions

set by use of operators. If the condition is true, code in squiggly brackets below an if statement is executed.

[edit] Example

 

 

 
 
 


[edit] else

Else is used at the end of an if statement's squiggly brackets.

Code is executed in the else

statement if the if statement

does NOT meet its conditions.

[edit] Example

 

 

 
 
 

An if statement can also be attached to the end of an else statement. This is useful because if an if statement doesn't check

out, it will move to the ne

xt condition.

[edit] else if

 

 

 
 
 


[edit] while

A while loop will loop through code in

squiggly brackets as long as a condition is met each time. Frequently this condition is an integer

that must be less/greater than another integer. While loops are useful because you can use your incrementing

variable, in this case v, to make changes in bulk.

[edit] Example 1

 
 
 

This while loops increments

variable v until it's

 greater than 9.

Don't forget to increment your variable.

[edit] Example 2

 
 

This while loop looks through all players, and if the player is in a checkpoint, it changes an array's cell to 1. The array would have to be declared with a size of MAX_PLAYERS, which is a macro defined as 200. This sort of code is really helpful because you can set player properties easily and

efficiently. You can use incheckpoints in a conditional statement later on:

 
 

This

could be used in OnPlayerLeaveCheckpoint to change the variable to 0.

[edit] for

A for loop will do the same thing as a while loop, but it allows you to specify the variable you wish to change for each loop, the condition that has to be met each time, and

the action to take at the end of each loop.

[edit] Example

 
 

Notice that a for loop's three parameters are separated by a semicolon (;) not a comma (,). In the first parameter, a new variable "i" is declared. In this parameter you specify the variable you want to deal with, declare a new one. The second parameter is the condition, same as in the while loop. The third parameter is the

action taken at the end of the code.

[edit]

 Operators

Operators are commonly used in conditional statements; they check the relationship between two sets of data before

executing code.

Operator Meaning Usage
== Left is equal to Right if(Left == Right)
!= Left is not equal to Right if(Left != Right)
> Left is greater than Right if(Left > Right)
>= Left is greater than or equal to Right if(Left >= Right)
< Left is less than Right if(Left < Right)
<= Left is less than or equal to Right if(Left <= Right)
Operator Meaning Usage
&& and if(Left && Right)
|| or if(Left || Right)
 ! not if(!Variable)

 

 

nor if(!(Left || Right))
not and if(!(Left && Right))
exclusive or if((Left && !Right)||(!Left && Right))
not exclusive or if(!((Left && !Right)||(!Left && Right)))
Making a basic deathmatch

Making a basic deatchmatch in PAWN couldn't be simpler. Simply open up Pawno (see Scripting Editors) and click new. There you have it, your first script. To run it first save it (most people save it to "<San Andreas Install Directory>/samp/gamemodes/src/" but it is easier (for local testing) to save it to "<SA>/samp/gamemodes/"), then click the button on the toolbar to the immediate left of the blue arrow button. This will compile your .pwn file to a .amx in the same folder, however for the game to see it it needs to be in "<SA>/samp/gamemodes/" (see why saving there was easier, that makes it already there after compiling). Now to test your map you will need to set up a local server and change to your mode (type "changemode <your mode name>" in the server window).

If all that worked, when you connect to your server through the sa-mp client and the game starts you should appear outside a casino in Las Venturas. Unfortunately you won't be able to see the character you are selecting (there is currently only one) but we can easily change that later. It is also not a very interesting deathmatch as you only have fists to fight with and no opponents, but as this is a local server there is currently not a lot we can do about the second problem.

Now the first thing you are likely to want to add to your mode is weapons, these are controlled on a "per class" basis. Every player you have to select from at the start of a game (or later if you change) is called a player "class". They may all have the same weapons or all different, or a combination. You set each classes weapons separately, so to make them all have the same weapon you would simply copy the weapon data and add it to each class, this will guarantee a balanced match but is not too interesting, however it is up to you. In the editor search for this line:

AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);

This is a class definition, the parameters are as follows:

AddPlayerClass(Player model, X, Y, Z, A, Weapon 0, Ammo 0, Weapon 1, Ammo 1, Weapon 2, Ammo 2);

Player model can be got from "peds.ide", "X", "Y" and "Z" are the co-ordinates of where the player will spawn when selected and "A" is their facing angle, there is one spawn point per class, however this can be got around with coding which will be covered later. The weapon numbers can be found here and the ammo numbers are simply the amount of ammo you want to give the player per weapon (melee weapon ammo is always 0).

Now copy this line:

AddPlayerClass(102, 1958.3783, 1343.1572, 15.3746, 269.1425, 5, 0, 22, 100, 32, 50);

and place it under the line you found in your script. You will now have a choice ingame between CJ with nothing and a Balla with a baseball bat, pistol and Tec9, if you want to even this up try adding your own weapons to CJ or adding more player classes under these with other weapons.

Note: the weapons listed on the page linked to above which say "(crashes if you try to fire)" or "(Unusable)" do not work with SA-MP either, also grenades currently crash SA-MP, however this is being looked into so they may work by the time you read this.

[edit] Getting co-ordinates, angles and model ids

You will probably want to move some of your spawn points about so everyone doesn't spawn in the same place, which would make a rather boring deathmatch and camping amazingly easy. This is where the debug mode comes in. Run "samp_debug.exe" in your San Andreas root directory and whenever you want to save a co-ordinate type "/save" in the game (press "t" or the key under escape to bring up the text/chat prompt). This will save your current position, angle and playerid to a file called "savedpositions.txt" in your SA root directory. To change player while in debug mode press F11 and F12 to loop through all supported models.

[edit] Introduction to functions and callbacks

Before we can continue you will need to be introduced to callbacks. These are the chunks of code already in your gamemode that look something like this:

public OnPlayerDisconnect(playerid)
{
	printf("OnPlayerDisconnect(%d)", playerid);
	return 1;
}

This is the OnPlayerDisconnect callback, that means this section of code is run by the server whenever a player disconnects, so if you want to show a big message on the screen when a player leaves you would put the code for that here. All the callbacks the game uses (except 2, but they are used by filterscripts, not gamemodes and are not covered here) are in your file, you cannot make up your own. Most of them appear as the one above does, but some (i.e. "OnPlayerCommandText", "OnPlayerRequestClass", "OnGameModeInit" and "main" (which is not strictly a callback and never has more than your game title)) have other bits in already, either to make the game work or to show you what to do there. You may also use other, similar blocks (as we are about to) which look the same but are called functions, these have to be called by you yourself. Here is a function called "IMadeThis" (note the lack of spaces).

public IMadeThis()
{
	// This is a comment and is ignored by the game/compiler

	/* So 	
	is
	this */

	print("This will be printed to the server window");
	return 0;
}

You may have also noticed a very quick introduction to comments there, everything on a line after "//" will be ignored, as will anything anywhere between "/*" and "*/". As a function is not called by the game we need to call it ourselves from a callback, this is dead easy as most of the commands you use to code with are in fact premade functions (commands are in fact different), so if you placed:

IMadeThis();

in your OnPlayerDisconnect callback (it must be between the "{" and "}" and also before the "return 1;" it would run that function and print a message in the server window when you disconnected (remember the other things in there are ignored). We don't generally want to print things to the server window and all the "print" and "printf" functions already in the file are generally removed by the coder. Only things between the braces are in the function/callback (from now on function refers to callbacks as well as they are a special case of function), the line above is the name of the function. "public" means the function can be run by any other bit of code, this basically means your code can be run when you call it, we're not worried about private functions as they are not generally used in SA-MP (if at all). The brackets after the function name enclose the parameters list, we haven't covered these yet but you can see an example of their usage in some of the callbacks in your blank file, note that those parameters are automatically passed when the game calls the function, if we are using a custom functions (i.e. not a callback) and we want to use some parameters we will need to pass them ourselves. One tiny other thing which should be mentioned is that all lines apart from lines with braces on (and even them in certain circumstances, but these will be covered later) and lines directly before an open brace (braces may be on the end of that line or, as shown here, on a new line), end with a semicolon to denote the end of a process.

[edit] Making a team deathmatch

OK, now you know how to make classes and place them about we will show you how to set teams, this will be the first bit of real coding but is fairly easy. I will just be using the two classes described on this page so if you have more remove them for now or start a new mode and make sure only those two are in. Classes are numbered in order from 0, so the first class in your file is 0, the second is 1 and so on (computers and programs nearly always start from 0 in counting (you will find that your playerid in a test game is 0)). We want to set the team based on which class they choose (either Grove or Balla), you may look at the callbacks and think that this would go in the OnPlayerRequestClass function, and you would be correct. When the select their class you want to set the team based on that, we can't do it in the OnPlayerSpawn function as at that point we don't know the class they have selected (that is a parameter and only parameters we are passed or which are global in your script (we will cover this later) can be used in any function). First we need to define our teams, under the "#include" line(s) at the top of your file add these lines:

#define TEAM_GROVE 1
#define TEAM_BALLA 2
#define TEAM_GROVE_COLOR 0x00FF00AA // Bright Green (in RGBA format)
#define TEAM_BALLA_COLOR 0xFF00FFAA // Bright Purple

If you want to alter the colors, that's fine, just remember that the last two digits are the alpha and the lower that is the less you can see the color. Defines are purely replacements, now if you ever want to use the number 1 in your script you can use TEAM_GROVE instead, this is not a good idea for normal calculations as it makes them harder to read, but for using to denote teams, which are only denoted by a number, it makes it a lot clearer what's going on (and makes it very easy to change the teams around or modify later as you need only change the 1 in the define rather than all the instances of it throughout the code. When the code is compiled, all the "TEAM_GROVE"s will be replaced by 1, it is not like a variable, it is a constant, it doesn't change. Now under those lines add:

new gTeam[MAX_PLAYERS];

This is called a global array. An array is basically lots of variables (places you store data to read and write) clumped together to store lots of data at once. The "MAX_PLAYERS" is a pre-defined constant (done in exactly the same way as we did our defines. MAX_PLAYERS is actually set at 100, so this means that our array can store up to 100 pieces of data. The g on the name means global, but that doesn't make it global (it just makes it easier to tell what variables do what, defining it outside a function means it is global and can be used by all our functions. Any variable defined in a function is local to that function and it can't have the same name as another variable in the same function or a global variable (which is also why the g is useful), it can however have the same name as another variable in another function. All the "playerid" variables in your blank script are in fact all independent variables, each local to a different function, however they are all passed the same data, but just remember that any functions you make won't automatically have that data. Now we have that set up we can set the teams:

public SetPlayerTeamFromClass(playerid, classid)
{
	if (classid == 0)
	{
		gTeam[playerid] = TEAM_GROVE;
	}
	else
	{
		gTeam[playerid] = TEAM_BALLA;
	}
}

Place that code OUTSIDE a function in your code (as it is a new function) and put these lines as the first things after the open curly braces in your OnPlayerRequestClass callback (notice the way the variables are not global so we are having to pass them to out function too):

SetPlayerTeamFromClass(playerid, classid);

This will save the players team to an array through our new function. Data in an array is referenced by a number, so array[0] is the first item of data, array[1] is the second and so on, as we are using gTeam[playerid], depending on which playerid we are passed will define where in the array to store the data, so for player 5 their data will be stored at array position 5 (remember, this is the 6th piece of data). Now copy this function:

public SetPlayerToTeamColor(playerid)
{
	if (gTeam[playerid] == TEAM_GROVE)
	{
		SetPlayerColor(playerid, TEAM_GROVE_COLOR);
	}
	else if (gTeam[playerid] == TEAM_BALLA)
	{
		SetPlayerColor(playerid, TEAM_BALLA_COLOR);
	}
}

And add the following line to OnPlayerSpawn:

SetPlayerToTeamColor(playerid);

We now have our teams, but what have we actually done?

	if (classid == 0)
	{
		gTeam[playerid] = TEAM_GROVE;
	}

In our first function, we check which class they chose (remember we said that the first class defined in your file was class 0?) "==" means "is equal to", a single equals sign simply sets the variable to the number given (as seen on the next line but one). The curly braces separate the functions between them from the rest of the code, bits in there are only executed if the selected class is 0 (cj), if it isn't, the else command comes into play and executes instead (this executes whenever the "if" command is false (i.e. the class isn't 0)), since we only have two classes to choose from this must mean we're Balla:

	else
	{
		gTeam[playerid] = TEAM_BALLA;
	}

We don't need a return here as there is no data to return.

The second half set the players' color when they spawn, so you can tell who's on which team. As we saved their team to a global array, we can still access the data even though it is in a separate function.

	if (gTeam[playerid] == TEAM_GROVE)
	{
		SetPlayerColor(playerid, TEAM_GROVE_COLOR);
	}

Hopefully you can see what this is doing now, if the player who just spawned (as referenced by playerid) is in TEAM_GROVE, we set their color to TEAM_GROVEs color.

	else if (gTeam[playerid] == TEAM_BALLA)
	{
		SetPlayerColor(playerid, TEAM_BALLA_COLOR);
	}

This next section is a little different, it could easilly have been done like this:

	else
	{
		SetPlayerColor(playerid, TEAM_BALLA_COLOR);
	}

But the way it is done allows you to set their color to TEAM_BALLAs color only if the first part is false (as sorted by the ELSE) AND if they are in TEAM_BALLA, this allows you to add more options by adding more "else if ()" blocks to the end as one will only be executed if all the blocks before it weren't.

[edit] Vehicles

OK, if you have previous chapters you should have a very basic deathmatch or team-deathmatch with spawns placed wherever you want, so lets add some vehicles. Most of the commands in PAWN do pretty much exactly as they're named, we want to add a vehicle so lets look for vehicle commands:

CreateVehicle();

AddStaticVehicle();

If you click on either of these and look in the status bar (the bar at the bottom of the editor) you will see their syntax (what information/parameters you need to give them to work):

[a_samp.inc] native CreateVehicle(vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2);

[a_samp.inc] native AddStaticVehicle(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2);

Now they both look equally as good, but this is where prior knowledge comes in, CreateVehicle only places one car ingame, AddStaticVehicle creates a vehicle spawn, so when the car is destroyed or desynched it will reappear back where you placed the spawn. These need to be created at the start of the game so you would place this in your "OnGameModeInit()" callback.

List of available car colors
List of available car colors
The modelid/vehicletype numbers can be found in your vehicles.ide file, the Floats are just non whole numbers, basically co-ordinates and angles, and the color numbers can be found in your carcols.dat file, look for the reference number for the color you want, so "black" is "0", "taxi yellow" is "6", "currant blue poly" is "32" etc, "-1" means random (from that car's default colors, found lower in the carcols.dat file). If you want to get the position for a vehicle, go into debug mode, select your vehicle, get in and type "/save" then open up "savedpositions.txt" and copy the line. If you want to spawn a vehicle in debug mode, type "/v <vehicleid>" ingame and that vehicle will spawn (vehicleid is taken again from vehicles.ide), or type "/vsel" to bring up the vehicle command screen.

I got these co-ordinates:

2040.2279, 1344.4127, 11.0, 3.5436

Note: These are called floats, 11.0 is a float despite being whole, any whole number being used as a float must have a trailing ".0" to denote it as a float. These numbers are in the english format of using a decimal point ("."), commas are used to separate parameters. Also remember the 4th number is angle, so if we now add the following line to the game mode in OnGameModeInit, recompile and test, we will get a bright pink infernus outside the casino which is the default spawn position for CJ. Note: on a car which uses the secondary color (such as a cop car (id 596)) this would be a pink and blue car as that is the secondary color.

AddStaticVehicle(411, 2040.2279, 1344.4127, 10.6719, 3.5436, 126, 54);

Now you can easily go about saving positions and creating as many cars as you want (up to an engine defined limit of 254 individual cars, 50 different types of car). The spawns saved to the file will have "-1, -1" as the colors by default.

 

Create a free website at Webs.com