[Tutorial] Team Cars and Team Players
#1

So like always, make sure you define the a_samp include file.

pawn Код:
#include <a_samp>
That just defines, that you are going to be scripting a San Andreas Multiplayer server. Next you will have to add the new files. We want to make Team Players, so put this under the #include, add this:

pawn Код:
new gTeam[MAX_PLAYERS];
That defines, that there are teams in you server, with a maximum of 250 players in your server(MAX_PLAYERS does not equal, infinity. In SA-MP it equals 250 players). Next we have define our teams. So above the new file, and below the include file, add this:

pawn Код:
#define GROVE_STREET 1
#define POLICE 2
This right here, defines that GROVE_STREET 1, and POLICE 2 will do something (in this case, they will be two separate teams). In order for your nametag to show up as the Team Color you are in, you must define these two, right underneath the #define POLICE 2:

pawn Код:
#define GROVE_STREET_COLOUR 0x00820FAA
#define POLICE_COLOUR 0x003DF5AA
This defines that GROVE_STREET_COLOUR is Green (0x00820FAA), and that POLICE_COLOUR is Blue (0x003DF5AA). So far our script should look like this:

pawn Код:
#include <a_samp>

#define GROVE_STREET 1
#define POLICE 2
#define GROVE_STREET_COLOUR 0x00820FAA
#define POLICE_COLOUR 0x003DF5AA

new gTeam[MAX_PLAYERS];
The Next thing you want to do is make sure that you have skins for you Team. So we are gonna add a Grove Street Gang member skin and a Police Officer skin under OnGameModeInit. So under the new file, add this:

pawn Код:
public OnGameModeInit()
{
    AddPlayerClass(105,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Grove Street Gang Member (0)
    AddPlayerClass(280,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Police Officer (1)
    return 1;
}
Next all we have to do is make sure the Class gets changed into a Team. So under OnPlayerRequestClass, add this:

pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}
What we did there was, when you get to request a skin, and you select it, it will set the team from the class you chose. Now we have to make sure that the class you chose, gives you the appropriate nametag color. So under OnPlayerSpawn, add this:

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColour(playerid);
    return 1;
}
This basically added a player who spawns, to the appropriate team Color. But nothing will work unless you have this next few lines scripted. To be able to determine whether you're a cop or a gang member, you must make sure you Set the Player Team from the Class. So underneath everything script this:

pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = GROVE_STREET;
    }
}
Next you will tell gTeam, that this is a Grove Street Gang Member, and his nametag should be green. So next add this under everything:

pawn Код:
SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == GROVE_STREET)
    {
        SetPlayerColor(playerid,GROVE_STREET_COLOUR); //Green
    }
}
This basically sets the Grove Street Gang Member to the Grove Street Color, we had defined earlier which was green, so, now this nametag is green. Now Lets add the Police the exact same way. It should look something like this:

pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = GROVE_STREET;
    }
    if(classid == 1)
    {
        gTeam[playerid] = POLICE;
    }
}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == GROVE_STREET)
    {
        SetPlayerColor(playerid,GROVE_STREET_COLOUR); //Green
    }
    if(gTeam[playerid] == POLICE)
    {
        SetPlayerColor(playerid,POLICE_COLOUR); // Blue
    }
}
REMEMBER: the skin id goes up by number as you go down the player class. (for example: if grove street gang member is 0, so will be the classid.

Next we must add Team Cars (If you are a Grove Street Gang Member, and you attempt to get into a Police Car, it will say, You do not have the keys to this car). So now add this in between, #define files and new files:

pawn Код:
enum TeamCars
{
GroveStreet,
Police
}
This made it where these two title ids, are TeamCars. So to make them TeamCars, make sure you define this, on top of the new file:

pawn Код:
new Cars[TeamCars];
This Defines Cars as [any team in here]. Next we create the vehicle. (you can either do AddStaticVehicle, or CreateVehicle, but make sure at the beggining, you put Cars[Team name here]). Now Add the Police Car, and the Greenwood into Los Santos, so it will look like this under OnGameModeInit:

pawn Код:
public OnGameModeInit()
{
    AddPlayerClass(105,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Grove Street Gang Member (0)
    AddPlayerClass(280,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Police Officer (1)
    Cars[GroveStreet] = CreateVehicle(492,2484.3054,-1655.0886,13.1036,90.8565,44,16,900); //Greenwood
    Cars[Police] = CreateVehicle(596,1536.0603,-1676.5302,13.1054,0.6847,-1,-1,900); //LSPD Cruiser
    return 1;
}
Next we make sure that the Script Gets the vehicle and know that you are not part of that team. Under everything add this:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[GroveStreet] )
        {
            if(gTeam[playerid] != 1)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
                return 1;
            }
        }
        if(CarCheck == Cars[Police] )
        {
            if(gTeam[playerid] != 2)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You Don't have the keys for this car!");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
This here makes sure that if you try to get into one of the cars, it will not let you. For example, if gTeam(playerid) is not equal to 1, then removeplayerfromvehicle and send him a message in red saying You Don't have the keys for this car! So now, lets define the Color Red. On top of the script under the last #define, add this:

pawn Код:
#define COLOR_RED 0xFF0000AA
That just defined the Color Red. So here we are! WE ARE DONE! You have made your own player teams, and car teams! Enjoy them, and practice making more, as more more make is more progress for you!
Reply
#2

This is for DM server?
or rp?
Reply
#3

Quote:
Originally Posted by Thebest96
Посмотреть сообщение
This is for DM server?
or rp?
TDM/CnR IMO.

Pretty basic tutorial,but still I always appreciate effort.
Good job.
Reply
#4

can you show me for RP?
Faction LSPD please?
Reply
#5

Quote:

C:\Users\Desertsoulz_2\Desktop\SA-MP\GTA San Andreas\SAMP\gamemodes\ADMINS.pwn(9) : error 001: expected token: "-identifier-", but found "-integer value-"
C:\Users\Desertsoulz_2\Desktop\SA-MP\GTA San Andreas\SAMP\gamemodes\ADMINS.pwn(20) : warning 213: tag mismatch
C:\Users\Desertsoulz_2\Desktop\SA-MP\GTA San Andreas\SAMP\gamemodes\ADMINS.pwn(20) : error 032: array index out of bounds (variable "Cars")
C:\Users\Desertsoulz_2\Desktop\SA-MP\GTA San Andreas\SAMP\gamemodes\ADMINS.pwn(21) : warning 213: tag mismatch
C:\Users\Desertsoulz_2\Desktop\SA-MP\GTA San Andreas\SAMP\gamemodes\ADMINS.pwn(21) : error 032: array index out of bounds (variable "Cars")
C:\Users\Desertsoulz_2\Desktop\SA-MP\GTA San Andreas\SAMP\gamemodes\ADMINS.pwn(22) : warning 213: tag mismatch
C:\Users\Desertsoulz_2\Desktop\SA-MP\GTA San Andreas\SAMP\gamemodes\ADMINS.pwn(22) : error 032: array index out of bounds (variable "Cars")
C:\Users\Desertsoulz_2\Desktop\SA-MP\GTA San Andreas\SAMP\gamemodes\ADMINS.pwn(23) : warning 213: tag mismatch
C:\Users\Desertsoulz_2\Desktop\SA-MP\GTA San Andreas\SAMP\gamemodes\ADMINS.pwn(23) : error 032: array index out of bounds (variable "Cars")
C:\Users\Desertsoulz_2\Desktop\SA-MP\GTA San Andreas\SAMP\gamemodes\ADMINS.pwn(60) : warning 213: tag mismatch
C:\Users\Desertsoulz_2\Desktop\SA-MP\GTA San Andreas\SAMP\gamemodes\ADMINS.pwn(60) : error 032: array index out of bounds (variable "Cars")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

Please respond, I tried to make an Admin team for CnR

Here's the script.


Код:
#include <a_samp>

#define ADMINS 99
#define ADMINS_COLOR 0xFF00FFAA //Purple
#define COLOR_RED 0xFF0000AA //RED

enum TeamCars
{
ADMINS
}

new gTeam[MAX_PLAYERS];
new Cars[TeamCars];

public OnGameModeInit()
{
    AddPlayerClass(163,2127.6602,2377.6648,10.8203,182.7401,0,0,0,0,0,0);
    AddPlayerClass(164,2127.6602,2377.6648,10.8203,182.7401,0,0,0,0,0,0);

	Cars[ADMINS] = CreateVehicle(522,2091.4963,2361.1116,10.8058,183.7787,85,0,1000); //
	Cars[ADMINS] = CreateVehicle(522,2093.6804,2360.7153,10.8131,180.7032,85,0,1000); //
	Cars[ADMINS] = CreateVehicle(522,2095.8301,2361.1843,10.8129,177.7382,85,0,1000); //
	Cars[ADMINS] = CreateVehicle(522,2098.3806,2361.2388,10.8129,177.9737,85,0,1000); //
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColour(playerid);
    return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 99)
    {
        gTeam[playerid] = ADMINS;
    }
}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == ADMINS)
    {
        SetPlayerColor(playerid,ADMINS_COLOR); //Purple
    }
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[ADMINS] )
        {
            if(gTeam[playerid] != 99)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You can't drive this car!");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
Reply
#6

Nevermind
Reply
#7

Quote:
Originally Posted by Desertsoulz
Посмотреть сообщение
Please respond, I tried to make an Admin team for CnR

Here's the script.


Код:
#include <a_samp>

#define ADMINS 99
#define ADMINS_COLOR 0xFF00FFAA //Purple
#define COLOR_RED 0xFF0000AA //RED

enum TeamCars
{
ADMINS
}

new gTeam[MAX_PLAYERS];
new Cars[TeamCars];

public OnGameModeInit()
{
    AddPlayerClass(163,2127.6602,2377.6648,10.8203,182.7401,0,0,0,0,0,0);
    AddPlayerClass(164,2127.6602,2377.6648,10.8203,182.7401,0,0,0,0,0,0);

	Cars[ADMINS] = CreateVehicle(522,2091.4963,2361.1116,10.8058,183.7787,85,0,1000); //
	Cars[ADMINS] = CreateVehicle(522,2093.6804,2360.7153,10.8131,180.7032,85,0,1000); //
	Cars[ADMINS] = CreateVehicle(522,2095.8301,2361.1843,10.8129,177.7382,85,0,1000); //
	Cars[ADMINS] = CreateVehicle(522,2098.3806,2361.2388,10.8129,177.9737,85,0,1000); //
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColour(playerid);
    return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 99)
    {
        gTeam[playerid] = ADMINS;
    }
}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == ADMINS)
    {
        SetPlayerColor(playerid,ADMINS_COLOR); //Purple
    }
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[ADMINS] )
        {
            if(gTeam[playerid] != 99)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You can't drive this car!");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
Try using

Код:
enum TeamCars
{
ADMIN
}
instead of ADMINS and change every Cars[ADMINS] to Cars[ADMIN]. But don't change any other ADMINS.

Here's the full code with those changed:
Код:
#include <a_samp>

#define ADMINS 99
#define ADMINS_COLOR 0xFF00FFAA //Purple
#define COLOR_RED 0xFF0000AA //RED

enum TeamCars
{
ADMIN
}

new gTeam[MAX_PLAYERS];
new Cars[TeamCars];

public OnGameModeInit()
{
    AddPlayerClass(163,2127.6602,2377.6648,10.8203,182.7401,0,0,0,0,0,0);
    AddPlayerClass(164,2127.6602,2377.6648,10.8203,182.7401,0,0,0,0,0,0);

	Cars[ADMIN] = CreateVehicle(522,2091.4963,2361.1116,10.8058,183.7787,85,0,1000); //
	Cars[ADMIN] = CreateVehicle(522,2093.6804,2360.7153,10.8131,180.7032,85,0,1000); //
	Cars[ADMIN] = CreateVehicle(522,2095.8301,2361.1843,10.8129,177.7382,85,0,1000); //
	Cars[ADMIN] = CreateVehicle(522,2098.3806,2361.2388,10.8129,177.9737,85,0,1000); //
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColour(playerid);
    return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 99)
    {
        gTeam[playerid] = ADMINS;
    }
}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == ADMINS)
    {
        SetPlayerColor(playerid,ADMINS_COLOR); //Purple
    }
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[ADMIN] )
        {
            if(gTeam[playerid] != 99)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You can't drive this car!");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
Reply
#8

nice emanuel +1
Reply
#9

Dude, are people seriously asking to show you how to make them like RP? He just did, you just got to edit some things up. And thats all.
Reply
#10

Quote:
Originally Posted by 3ventic
Посмотреть сообщение
Try using

Код:
enum TeamCars
{
ADMIN
}
instead of ADMINS and change every Cars[ADMINS] to Cars[ADMIN]. But don't change any other ADMINS.

Here's the full code with those changed:
Код:
#include <a_samp>

#define ADMINS 99
#define ADMINS_COLOR 0xFF00FFAA //Purple
#define COLOR_RED 0xFF0000AA //RED

enum TeamCars
{
ADMIN
}

new gTeam[MAX_PLAYERS];
new Cars[TeamCars];

public OnGameModeInit()
{
    AddPlayerClass(163,2127.6602,2377.6648,10.8203,182.7401,0,0,0,0,0,0);
    AddPlayerClass(164,2127.6602,2377.6648,10.8203,182.7401,0,0,0,0,0,0);

	Cars[ADMIN] = CreateVehicle(522,2091.4963,2361.1116,10.8058,183.7787,85,0,1000); //
	Cars[ADMIN] = CreateVehicle(522,2093.6804,2360.7153,10.8131,180.7032,85,0,1000); //
	Cars[ADMIN] = CreateVehicle(522,2095.8301,2361.1843,10.8129,177.7382,85,0,1000); //
	Cars[ADMIN] = CreateVehicle(522,2098.3806,2361.2388,10.8129,177.9737,85,0,1000); //
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColour(playerid);
    return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 99)
    {
        gTeam[playerid] = ADMINS;
    }
}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == ADMINS)
    {
        SetPlayerColor(playerid,ADMINS_COLOR); //Purple
    }
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[ADMIN] )
        {
            if(gTeam[playerid] != 99)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You can't drive this car!");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
Uh, what's your point? Do you think if you change one darn letter it will make it only for admins? Are you insane?
Reply
#11

Nice man thanks.
Reply
#12

How can I add more cars than just two?
Reply
#13

Great tutorial +1. But how can i make something like permissions? like you need permission to become grove or admin to be grove?
Reply
#14

I got the same errorS!! Please somebody can help me here? ='(

Code:
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(14) : error 001: expected token: "-identifier-", but found "-integer value-"
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(47) : warning 213: tag mismatch
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(47) : error 032: array index out of bounds (variable "Cars")
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(48) : warning 213: tag mismatch
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(48) : error 032: array index out of bounds (variable "Cars")
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(49) : warning 213: tag mismatch
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(49) : error 032: array index out of bounds (variable "Cars")
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(50) : warning 213: tag mismatch
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(50) : error 032: array index out of bounds (variable "Cars")
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(702) : warning 213: tag mismatch
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(702) : error 032: array index out of bounds (variable "Cars")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Here's the script:

Code:
#include <a_samp>
#include <core>

#define SPECIAL_ACTION_PISSING 68
#define MAX_INVALID_NOS_VEHICLES 29
#define DOD 1
#define DOD_COLOUR 0x00820FAA
#define COLOR_RED 0xFF0000AA



enum TeamCars
{
DOD
}

new Cars[TeamCars];
new gTeam[MAX_PLAYERS];
new ELEGY;
new ELEGY2;
new ELEGY3;
new JESTER;
new JESTER2;
new STRATUM;
new STRATUM2;
new STRATUM3;
new STRATUM4;
new TE1;

forward NitroReset();

main()
{
	print("\n __________________________________\n");
	print("\n|                      Drift                           |\n");
	print("\n|__________________________________|\n");
}

public OnGameModeInit()
{
	SetGameModeText("Drift");
	UsePlayerPedAnims();
	SetTimer("NitroReset", 1500, 1);
	//Funзхes para Spawn de Members - DOD
 	AddPlayerClass(299,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0);
    AddPlayerClass(104,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); 
    Cars[DOD] = CreateVehicle(562,-2506.870117, -635.783325, 134.652481, 359.465423, -1, -1, 10000);
    Cars[DOD] = CreateVehicle(429,-2494.236083, -633.563049, 134.012542, 359.016265, -1, -1, 10000);
    Cars[DOD] = CreateVehicle(507,-2530.7561,-618.6442,132.1928,269.1777,1,1);
    Cars[DOD] = CreateVehicle(436,-2529.5754,-606.6457,132.1944,270.8741,1,1);
    return 1;
}
public OnGameModeExit()
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
    SetPlayerScore(playerid, GetPlayerMoney(playerid));
    return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public NitroReset()
{
	for(new i = 0; i<MAX_PLAYERS; i++)
	{
	    if(!IsPlayerInInvalidNosVehicle(i,GetPlayerVehicleID(i)))
		{
    		    new vehicle = GetPlayerVehicleID(i);
                AddVehicleComponent(vehicle, 1010);
		}
	}
}

IsPlayerInInvalidNosVehicle(playerid,vehicleid)
{
   

    new InvalidNosVehicles[MAX_INVALID_NOS_VEHICLES] =
    {
	581,523,462,521,463,522,461,448,468,586,
	509,481,510,472,473,493,595,484,430,453,
	452,446,454,590,569,537,538,570,449
    };

    vehicleid = GetPlayerVehicleID(playerid);

    if(IsPlayerInVehicle(playerid,vehicleid))
    {
		for(new i = 0; i < MAX_INVALID_NOS_VEHICLES; i++)
		{
		    if(GetVehicleModel(vehicleid) == InvalidNosVehicles[i])
		    {
		        return true;
		    }
		}
    }
    return false;
}

public OnPlayerConnect(playerid)
{
    GivePlayerMoney(playerid, 0);
    new pName[30], string[128];
    GetPlayerName(playerid, pName, 30);
    format(string, 256, "%s entrou no server.", pName);
    SendClientMessageToAll(0x33AA33AA,string);
    SendClientMessage(playerid, 0x33CCFFAA, "Se bem Vindo ao Servidor de Drift Nacional!");
    SendClientMessage(playerid, 0x33CCFFAA, "[DOD] - Drift Or Die");
    SendClientMessage(playerid, 0x33CCFFAA, "Escreve /cmd para aprenderes alguns comandos!");
	return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    new pName[30], string[128];
    GetPlayerName(playerid, pName, 30);
    format(string, 256, "%s saiu do server.", pName);
    SendClientMessageToAll(0xA52A2AAA,string);
   	return 1;
}
public OnPlayerSpawn(playerid)
{
    SetPlayerHealth(playerid,9000.0);
	SetPlayerToTeamColour(playerid);
    return 1;
}
SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = DOD;
    }
}
SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == DOD)
    {
        SetPlayerColor(playerid,DOD_COLOUR); //Green
    }
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[DOD] )
        {
            if(gTeam[playerid] != 1)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You Don't Belong to DOD Crew!");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
Reply
#15

Quote:
Originally Posted by nexco
View Post
I got the same errorS!! Please somebody can help me here? ='(

Code:
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(14) : error 001: expected token: "-identifier-", but found "-integer value-"
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(47) : warning 213: tag mismatch
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(47) : error 032: array index out of bounds (variable "Cars")
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(48) : warning 213: tag mismatch
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(48) : error 032: array index out of bounds (variable "Cars")
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(49) : warning 213: tag mismatch
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(49) : error 032: array index out of bounds (variable "Cars")
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(50) : warning 213: tag mismatch
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(50) : error 032: array index out of bounds (variable "Cars")
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(702) : warning 213: tag mismatch
C:\Documents and Settings\Tiago Esteves\Ambiente de trabalho\Servidor - Teste\pawno\Driftv2.pwn(702) : error 032: array index out of bounds (variable "Cars")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Here's the script:

Code:
#include <a_samp>
#include <core>

#define SPECIAL_ACTION_PISSING 68
#define MAX_INVALID_NOS_VEHICLES 29
#define DOD 1
#define DOD_COLOUR 0x00820FAA
#define COLOR_RED 0xFF0000AA



enum TeamCars
{
DOD
}

new Cars[TeamCars];
new gTeam[MAX_PLAYERS];
new ELEGY;
new ELEGY2;
new ELEGY3;
new JESTER;
new JESTER2;
new STRATUM;
new STRATUM2;
new STRATUM3;
new STRATUM4;
new TE1;

forward NitroReset();

main()
{
	print("\n __________________________________\n");
	print("\n|                      Drift                           |\n");
	print("\n|__________________________________|\n");
}

public OnGameModeInit()
{
	SetGameModeText("Drift");
	UsePlayerPedAnims();
	SetTimer("NitroReset", 1500, 1);
	//Funзхes para Spawn de Members - DOD
 	AddPlayerClass(299,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0);
    AddPlayerClass(104,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); 
    Cars[DOD] = CreateVehicle(562,-2506.870117, -635.783325, 134.652481, 359.465423, -1, -1, 10000);
    Cars[DOD] = CreateVehicle(429,-2494.236083, -633.563049, 134.012542, 359.016265, -1, -1, 10000);
    Cars[DOD] = CreateVehicle(507,-2530.7561,-618.6442,132.1928,269.1777,1,1);
    Cars[DOD] = CreateVehicle(436,-2529.5754,-606.6457,132.1944,270.8741,1,1);
    return 1;
}
public OnGameModeExit()
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
    SetPlayerScore(playerid, GetPlayerMoney(playerid));
    return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public NitroReset()
{
	for(new i = 0; i<MAX_PLAYERS; i++)
	{
	    if(!IsPlayerInInvalidNosVehicle(i,GetPlayerVehicleID(i)))
		{
    		    new vehicle = GetPlayerVehicleID(i);
                AddVehicleComponent(vehicle, 1010);
		}
	}
}

IsPlayerInInvalidNosVehicle(playerid,vehicleid)
{
   

    new InvalidNosVehicles[MAX_INVALID_NOS_VEHICLES] =
    {
	581,523,462,521,463,522,461,448,468,586,
	509,481,510,472,473,493,595,484,430,453,
	452,446,454,590,569,537,538,570,449
    };

    vehicleid = GetPlayerVehicleID(playerid);

    if(IsPlayerInVehicle(playerid,vehicleid))
    {
		for(new i = 0; i < MAX_INVALID_NOS_VEHICLES; i++)
		{
		    if(GetVehicleModel(vehicleid) == InvalidNosVehicles[i])
		    {
		        return true;
		    }
		}
    }
    return false;
}

public OnPlayerConnect(playerid)
{
    GivePlayerMoney(playerid, 0);
    new pName[30], string[128];
    GetPlayerName(playerid, pName, 30);
    format(string, 256, "%s entrou no server.", pName);
    SendClientMessageToAll(0x33AA33AA,string);
    SendClientMessage(playerid, 0x33CCFFAA, "Se bem Vindo ao Servidor de Drift Nacional!");
    SendClientMessage(playerid, 0x33CCFFAA, "[DOD] - Drift Or Die");
    SendClientMessage(playerid, 0x33CCFFAA, "Escreve /cmd para aprenderes alguns comandos!");
	return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    new pName[30], string[128];
    GetPlayerName(playerid, pName, 30);
    format(string, 256, "%s saiu do server.", pName);
    SendClientMessageToAll(0xA52A2AAA,string);
   	return 1;
}
public OnPlayerSpawn(playerid)
{
    SetPlayerHealth(playerid,9000.0);
	SetPlayerToTeamColour(playerid);
    return 1;
}
SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = DOD;
    }
}
SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == DOD)
    {
        SetPlayerColor(playerid,DOD_COLOUR); //Green
    }
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[DOD] )
        {
            if(gTeam[playerid] != 1)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You Don't Belong to DOD Crew!");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
This should work:

pawn Code:
#include <a_samp>

#define SPECIAL_ACTION_PISSING 68
#define MAX_INVALID_NOS_VEHICLES 29
#define DOD 1
#define DOD_COLOUR 0x00820FAA
#define COLOR_RED 0xFF0000AA

new Car1,Car2,Car3,Car4;
new gTeam[MAX_PLAYERS];
//new ELEGY;
//new ELEGY2;
//new ELEGY3;
//new JESTER;
//new JESTER2;
//new STRATUM;
//new STRATUM2;
//new STRATUM3;
//new STRATUM4;
//new TE1;

forward NitroReset();

main()
{
    print("\n __________________________________\n");
    print("\n|                      Drift                           |\n");
    print("\n|__________________________________|\n");
}

public OnGameModeInit()
{
    SetGameModeText("Drift");
    UsePlayerPedAnims();
    SetTimer("NitroReset", 1500, 1);
    //Funзхes para Spawn de Members - DOD
    AddPlayerClass(299,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0);
    AddPlayerClass(104,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0);
    Car1 = AddStaticVehicleEx(562,-2506.870117, -635.783325, 134.652481, 359.465423, -1, -1, 10000);
    Car2 = AddStaticVehicleEx(429,-2494.236083, -633.563049, 134.012542, 359.016265, -1, -1, 10000);
    Car3 = AddStaticVehicle(507,-2530.7561,-618.6442,132.1928,269.1777,1,1);
    Car4 = AddStaticVehicle(436,-2529.5754,-606.6457,132.1944,270.8741,1,1);
    return 1;
}
public OnGameModeExit()
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    SetPlayerScore(playerid, GetPlayerMoney(playerid));
    return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public NitroReset()
{
    for(new i = 0; i<MAX_PLAYERS; i++)
    {
        if(!IsPlayerInInvalidNosVehicle(i,GetPlayerVehicleID(i)))
        {
                new vehicle = GetPlayerVehicleID(i);
                AddVehicleComponent(vehicle, 1010);
        }
    }
}

IsPlayerInInvalidNosVehicle(playerid,vehicleid)
{


    new InvalidNosVehicles[MAX_INVALID_NOS_VEHICLES] =
    {
    581,523,462,521,463,522,461,448,468,586,
    509,481,510,472,473,493,595,484,430,453,
    452,446,454,590,569,537,538,570,449
    };

    vehicleid = GetPlayerVehicleID(playerid);

    if(IsPlayerInVehicle(playerid,vehicleid))
    {
        for(new i = 0; i < MAX_INVALID_NOS_VEHICLES; i++)
        {
            if(GetVehicleModel(vehicleid) == InvalidNosVehicles[i])
            {
                return true;
            }
        }
    }
    return false;
}

public OnPlayerConnect(playerid)
{
    GivePlayerMoney(playerid, 0);
    new pName[30], string[128];
    GetPlayerName(playerid, pName, 30);
    format(string, 256, "%s entrou no server.", pName);
    SendClientMessageToAll(0x33AA33AA,string);
    SendClientMessage(playerid, 0x33CCFFAA, "Se bem Vindo ao Servidor de Drift Nacional!");
    SendClientMessage(playerid, 0x33CCFFAA, "[DOD] - Drift Or Die");
    SendClientMessage(playerid, 0x33CCFFAA, "Escreve /cmd para aprenderes alguns comandos!");
    return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    new pName[30], string[128];
    GetPlayerName(playerid, pName, 30);
    format(string, 256, "%s saiu do server.", pName);
    SendClientMessageToAll(0xA52A2AAA,string);
    return 1;
}
public OnPlayerSpawn(playerid)
{
    SetPlayerHealth(playerid,9000.0);
    SetPlayerToTeamColour(playerid);
    return 1;
}
SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = DOD;
    }
}
SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == DOD)
    {
        SetPlayerColor(playerid,DOD_COLOUR); //Green
    }
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Car1 || Car2 || Car3 || Car4 )
        {
            if(gTeam[playerid] != 1)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You Don't Belong to DOD Crew!");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
Reply
#16

Nice Tutorial Helped me a lot but why are you getting them to write long pice of code (boring one)
and not use switch
Quote:
Code:
SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = GROVE_STREET;
    }
    if(classid == 1)
    {
        gTeam[playerid] = POLICE;
    }
}
can be writen
Code:
SetPlayerTeamFromClass(playerid, classid)
{
     Switch(classid)
     {
     case 0 :gTeam[playerid] = GROVE_STREET;
     case 1 :gTeam[playerid] = POLICE;
     }   
}
and if you got more skins for each of them

Code:
SetPlayerTeamFromClass(playerid, classid)
{
     Switch(classid)
     {
     case 0,1,2:gTeam[playerid] = GROVE_STREET;
     case 3,4,5,6,7,8,9:gTeam[playerid] = POLICE;
     }   
}
or even shorter
Code:
SetPlayerTeamFromClass(playerid, classid)
{
     Switch(classid)
     {
     case 0..2:gTeam[playerid] = GROVE_STREET;
     case 3..9:gTeam[playerid] = POLICE;
     }   
}
it is useful when there is a lot of skins and more than 2 teams
Reply
#17

Code:
C:\Users\Machlik\Desktop\samp03bsvr_R2_win32\gamemodes\Untitled.pwn(23) : warning 217: loose indentation
C:\Users\Machlik\Desktop\samp03bsvr_R2_win32\gamemodes\Untitled.pwn(290) : error 017: undefined symbol "SetPlayerTeamFromClass"
C:\Users\Machlik\Desktop\samp03bsvr_R2_win32\gamemodes\Untitled.pwn(306) : error 017: undefined symbol "SetPlayerTeamFromClass"
C:\Users\Machlik\Desktop\samp03bsvr_R2_win32\gamemodes\Untitled.pwn(308) : error 017: undefined symbol "classid"
C:\Users\Machlik\Desktop\samp03bsvr_R2_win32\gamemodes\Untitled.pwn(312) : error 017: undefined symbol "classid"
C:\Users\Machlik\Desktop\samp03bsvr_R2_win32\gamemodes\Untitled.pwn(318) : error 017: undefined symbol "SetPlayerToTeamColour"
C:\Users\Machlik\Desktop\samp03bsvr_R2_win32\gamemodes\Untitled.pwn(322) : error 035: argument type mismatch (argument 2)
C:\Users\Machlik\Desktop\samp03bsvr_R2_win32\gamemodes\Untitled.pwn(326) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


7 Errors.
Uhhh, what's wrong?
Reply
#18

Nice tut pal.
Reply
#19

C:\Users\Antonio Carlos\Desktop\Nuno\gta sa\filterscripts\CNR.pwn(54) : error 017: undefined symbol "SetPlayerTeamFromClass"
C:\Users\Antonio Carlos\Desktop\Nuno\gta sa\filterscripts\CNR.pwn(264) : warning 217: loose indentation
C:\Users\Antonio Carlos\Desktop\Nuno\gta sa\filterscripts\CNR.pwn(264) : error 017: undefined symbol "SetPlayerTeamFromClass"
C:\Users\Antonio Carlos\Desktop\Nuno\gta sa\filterscripts\CNR.pwn(266) : error 017: undefined symbol "classid"
C:\Users\Antonio Carlos\Desktop\Nuno\gta sa\filterscripts\CNR.pwn(270) : error 017: undefined symbol "classid"
C:\Users\Antonio Carlos\Desktop\Nuno\gta sa\filterscripts\CNR.pwn(277) : error 001: expected token: ";", but found "{"
C:\Users\Antonio Carlos\Desktop\Nuno\gta sa\filterscripts\CNR.pwn(277) : warning 217: loose indentation
C:\Users\Antonio Carlos\Desktop\Nuno\gta sa\filterscripts\CNR.pwn(287) : error 030: compound statement not closed at the end of file (started at line 255)


Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#define GROVE_STREET 1
#define POLICE 2
#define GROVE_STREET_COLOUR 0x00820FAA
#define POLICE_COLOUR 0x003DF5AA

new gTeam[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("\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(105,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //Grove Street Gang Member (0)
    AddPlayerClass(280,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Police Officer (1)
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(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)
{
    SetPlayerToTeamColour(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;
}
etPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = GROVE_STREET;
    }
    if(classid == 1)
    {
        gTeam[playerid] = POLICE;
    }
}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == GROVE_STREET)
    {
        SetPlayerColor(playerid,GROVE_STREET_COLOUR); //Green
    }
    if(gTeam[playerid] == POLICE)
    {
        SetPlayerColor(playerid,POLICE_COLOUR); // Blue
    }
    
SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = GROVE_STREET;
    }
    if(classid == 1)
    {
        gTeam[playerid] = POLICE;
    }
}

SetPlayerToTeamColour(playerid)
	{
    if(gTeam[playerid] == GROVE_STREET)
    {
        SetPlayerColor(playerid,GROVE_STREET_COLOUR); //Green
    }
    if(gTeam[playerid] == POLICE)
    {
        SetPlayerColor(playerid,POLICE_COLOUR); // Blue
    }
}
Reply
#20

help pls
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)