Team vehicles - What's wrong?
#1

I basically want the police team to be able to drive PD cars, the EMS to be able to drive ambulances, and if they try to enter the vehicle of another faction, they get ejected.
I haven't been able to find an error in my script, can anyone help me?
This is the script:

pawn Код:
#include <a_samp>

#define POLICE 1
#define EMS 2
#define POLICE_COLOR 0x1B4CE0AA
#define EMS_COLOR 0xFF8AF5AA
#define COLOR_RED 0xFF0000AA

enum TeamCars
{
Police,
Ems
}
new Cars[TeamCars];

new gTeam[MAX_PLAYERS];

public OnGameModeInit()
{
    AddPlayerClass(282,-212.8113,979.4888,19.3295,265.9427,0,0,0,0,0,0); //POLICE
    AddPlayerClass(275,-321.5634,1055.6372,19.7422,0.2632,0,0,0,0,0,0); //EMS
    Cars[Police] = AddStaticVehicle(598,-210.8453,999.8466,19.3565,88.9803,0,1); // FCpolice1
    Cars[Police] = AddStaticVehicle(598,-210.8381,995.6052,19.2733,88.3708,0,1); // FCpolice2
    Cars[Police] = AddStaticVehicle(598,-210.9035,990.9142,19.1776,87.8309,0,1); // FCpolice3
    Cars[Police] = AddStaticVehicle(598,-211.0338,986.5652,19.0902,88.7393,0,1); // FCpolice4
    Cars[Police] = AddStaticVehicle(599,-228.7683,984.3557,19.7830,359.9276,0,1); // FCpolice5
    Cars[Ems] = AddStaticVehicle(416,-330.7315,1063.7899,19.8899,270.1239,1,3); // FCems1
    Cars[Ems] = AddStaticVehicle(416,-335.0536,1056.3861,19.8883,89.4939,1,3); // FCems2
    Cars[Ems] = AddStaticVehicle(416,-304.0838,1036.2386,19.7430,269.8071,1,3); // FCems3
    Cars[Ems] = AddStaticVehicle(416,-303.8831,1032.0743,19.7432,269.9365,1,3); // FCems4
    Cars[Ems]= AddStaticVehicle(416,-304.0561,1028.1265,19.7430,270.0614,1,3); // FCems5
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    if(GetPlayerSkin(playerid) == 282) GameTextForPlayer(playerid,"~b~Police",7500,6);
    if(GetPlayerSkin(playerid) == 275) GameTextForPlayer(playerid,"~p~Emergency Services",7500,6);
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

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

SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = POLICE;
    }
{
    if(classid == 1)
        gTeam[playerid] = EMS;
    }
}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == POLICE)
    {
        SetPlayerColor(playerid,POLICE_COLOR); //BLUE
    }
{
    if(gTeam[playerid] == EMS)
        SetPlayerColor(playerid,EMS_COLOR); // PINK
    }
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[Police] )
        {
            if(gTeam[playerid] != 1)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You don't belong to the correct faction.");
                return 1;
            }
        }
        if(CarCheck == Cars[Ems] )
        {
            if(gTeam[playerid] != 0)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You don't belong to the correct faction.");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
OnPlayerStateChange is where the magic is supposed to happen..
Need help fast, can't continue :/
Reply


Messages In This Thread
Team vehicles - What's wrong? - by needhack - 23.02.2013, 17:19
Re: Team vehicles - What's wrong? - by Alternative112 - 23.02.2013, 17:44
AW: Re: Team vehicles - What's wrong? - by Nero_3D - 23.02.2013, 17:48
Re: Team vehicles - What's wrong? - by needhack - 23.02.2013, 17:55
AW: Team vehicles - What's wrong? - by Nero_3D - 23.02.2013, 18:05
Re: Team vehicles - What's wrong? - by needhack - 23.02.2013, 18:48

Forum Jump:


Users browsing this thread: 1 Guest(s)