Team Cars problem.
#1

Hello!

Today i have problem with team cars.

This https://sampforum.blast.hk/showthread.php?tid=160810 - this https://sampforum.blast.hk/showthread.php?tid=419713 and this https://sampforum.blast.hk/showthread.php?tid=300316 dosen't help me!!

My problem is that, when im civilian and i enter to police car i can drive it but i don't want that...

So here is my script: (in estonian)
pawn Код:
// First the teams!
new gTeam[MAX_PLAYERS];

#define TSIVIIL 0
#define BALLAD 1
#define GROVE 2
#define VAGOS 3
#define RUSSIAN 4
#define AZTECAS 5
#define POLITSEI 6
#define MAFIA 7
#define CHERIFF 8
#define SWAT 9
#define SOJAVAGI 10
#define CIA 11

// Then cars
enum TeamCars
{
LSPD,
Mafia
}
new Cars[TeamCars];

public OnGameModeInit()
{  
    Cars[LSPD] = CreateVehicle(401,2251.7415,2476.0071,10.5993,1.2631,52,52,900); // LSPD 1
    Cars[LSPD] = CreateVehicle(401,2255.8970,2476.3103,10.5995,0.5224,52,52,900); // LSPD 2
    Cars[LSPD] = CreateVehicle(401,2260.5508,2475.9434,10.5994,0.9976,52,52,900); // LSPD 3
    Cars[LSPD] = CreateVehicle(401,2260.5461,2460.9810,10.5996,358.9507,52,52,900); // LSPD 4
    Cars[LSPD] = CreateVehicle(401,2255.9341,2459.5439,10.5996,359.6339,52,52,900); // LSPD 5
    Cars[LSPD] = CreateVehicle(401,2251.6504,2458.6802,10.5993,359.5941,52,52,900); // LSPD 6
    Cars[LSPD] = CreateVehicle(401,2251.5488,2444.1545,10.5999,359.5937,52,52,900); // LSPD 7
    Cars[LSPD] = CreateVehicle(401,2255.6819,2443.7505,10.5997,357.4008,52,52,900); // LSPD 8
    Cars[LSPD] = CreateVehicle(401,2260.6716,2444.4990,10.5998,2.3976,52,52,900); // LSPD 9
    return 1;
}

// Then that
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[LSPD] )
        {
            if(gTeam[playerid] != POLITSEI)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "[LSPD] - Sa ei ole politseinik!");
                return 1;
            }
            else
            {
                return 1;
            }
        }
        VehicleModel[playerid] = GetVehicleModel(GetPlayerVehicleID(playerid));
        ShowGameTextForPlayer(playerid);
        SendClientMessage(playerid,COLOR_GREEN,"Sa sisenesid autosse! Vajuta number 2 , et masinat parandada & flippida!");
        return 1;
    }
    if(newstate != PLAYER_STATE_DRIVER && (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)) KillTimer(CFCTimer);
    return 1;
}
umm... no errors! Just dosen't work. yep...
Reply
#2

if(gTeam[playerid] != POLITSEI) i don't get it
Reply
#3

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
if(gTeam[playerid] != POLITSEI) i don't get it
If a player not police!

#define POLITSEI 6
Reply
#4

PHP код:
new lspdcar[9];
lspdcar[0] = createvehicel.....
lspdcar[1] = ......
for(new 
i=0i<sizeof(lspdcar); i++)
    {
        if(
GetPlayerVehicleID(playerid)==lspdcar[i])
        {
            if(
gTeam[playerid] != POLITSEI)
            {
            ....
            }
        }

Reply
#5

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
PHP код:
new lspdcar[9];
lspdcar[0] = createvehicel.....
lspdcar[1] = ......
for(new 
i=0i<sizeof(lspdcar); i++)
    {
        if(
GetPlayerVehicleID(playerid)==lspdcar[i])
        {
            if(
gTeam[playerid] != POLITSEI)
            {
            ....
            }
        }

Yep! It works, thanks!
Reply
#6

Umm i want add swat cars and so... And i do like this:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        for(new i=0; i<sizeof(lspdcar); i++)
        {
            if(GetPlayerVehicleID(playerid)==lspdcar[i])
            {
                if(gTeam[playerid] != POLITSEI || gTeam[playerid] != SWAT || gTeam[playerid] != CHERIFF || gTeam[playerid] != SOJAVAGI || gTeam[playerid] != CIA)
                {
                    RemovePlayerFromVehicle(playerid);
                    SendClientMessage(playerid,COLOR_RED,"[LSPD] - Sa ei ole politseinik!");
                }
            }
        }
        for(new i=0; i<sizeof(swatcar); i++)
        {
            if(GetPlayerVehicleID(playerid)==swatcar[i])
            {
                if(gTeam[playerid] != POLITSEI || gTeam[playerid] != SWAT || gTeam[playerid] != CHERIFF || gTeam[playerid] != SOJAVAGI || gTeam[playerid] != CIA)
                {
                    RemovePlayerFromVehicle(playerid);
                    SendClientMessage(playerid,COLOR_RED,"[LSPD] - Sa ei ole politseinik!");
                }
            }
        }
        for(new i=0; i<sizeof(ciacar); i++)
        {
            if(GetPlayerVehicleID(playerid)==ciacar[i])
            {
                if(gTeam[playerid] != SOJAVAGI || gTeam[playerid] != CIA)
                {
                    RemovePlayerFromVehicle(playerid);
                    SendClientMessage(playerid,COLOR_RED,"[LSPD] - Sa ei ole CIA!");
                }
            }
        }
        for(new i=0; i<sizeof(soda); i++)
        {
            if(GetPlayerVehicleID(playerid)==soda[i])
            {
                if(gTeam[playerid] != SOJAVAGI)
                {
                    RemovePlayerFromVehicle(playerid);
                    SendClientMessage(playerid,COLOR_RED,"[LSPD] - Sa ei ole sхjavдelnane!");
                }
            }
        }
        VehicleModel[playerid] = GetVehicleModel(GetPlayerVehicleID(playerid));
        ShowGameTextForPlayer(playerid);
        SendClientMessage(playerid,COLOR_GREEN,"Sa sisenesid autosse! Vajuta number 2 , et masinat parandada & flippida!");
        return 1;
    }
But now, if im police, then i can't enter police car... Help please?

cars here:
pawn Код:
lspdcar[0] = CreateVehicle(596,2251.7415,2476.0071,10.5993,1.2631,1,0,900); // LSPD 1
    lspdcar[1] = CreateVehicle(596,2255.8970,2476.3103,10.5995,0.5224,1,0,900); // LSPD 2
    lspdcar[2] = CreateVehicle(596,2260.5508,2475.9434,10.5994,0.9976,1,0,900); // LSPD 3
    lspdcar[3] = CreateVehicle(599,2260.5461,2460.9810,10.5996,358.9507,1,0,900); // LSPD 4
    lspdcar[4] = CreateVehicle(599,2255.9341,2459.5439,10.5996,359.6339,1,0,900); // LSPD 5
    lspdcar[5] = CreateVehicle(599,2251.6504,2458.6802,10.5993,359.5941,1,0,900); // LSPD 6
    lspdcar[6] = CreateVehicle(599,2251.5488,2444.1545,10.5999,359.5937,1,0,900); // LSPD 7
    lspdcar[7] = CreateVehicle(596,2255.6819,2443.7505,10.5997,357.4008,1,0,900); // LSPD 8
    lspdcar[8] = CreateVehicle(596,2260.6716,2444.4990,10.5998,2.3976,1,0,900); // LSPD 9
    swatcar[0] = CreateVehicle(427,2269.6206,2443.8635,10.5999,359.7554,1,0,900); // SWAT 1
    swatcar[1] = CreateVehicle(427,2273.2949,2443.3438,10.5999,358.6206,1,0,900); // SWAT 2
    swatcar[2] = CreateVehicle(427,2277.9805,2443.3772,10.5998,356.7937,1,0,900); // SWAT 3
    swatcar[3] = CreateVehicle(427,2282.2412,2445.2388,10.6002,358.6171,1,0,900); // SWAT 4
    swatcar[4] = CreateVehicle(601,2241.2480,2436.8567,10.6001,359.5331,1,0,900);
    ciacar[0] = CreateVehicle(411,2290.8494,2443.5261,10.5999,359.5887,1,0,900); // CIA
    ciacar[1] = CreateVehicle(411,2295.2502,2443.6106,10.5998,2.2856,1,0,900); // CIA 2
    soda[0] = CreateVehicle(401,2292.7109,2476.9768,10.5997,129.0995,1,0,900);
Reply
#7

do like this --
pawn Код:
// First the teams!
new gTeam[MAX_PLAYERS];

#define MAX_TEAM_CARS 50 //edit it according to ur needs

#define TSIVIIL 0
#define BALLAD 1
#define GROVE 2
#define VAGOS 3
#define RUSSIAN 4
#define AZTECAS 5
#define POLITSEI 6
#define MAFIA 7
#define CHERIFF 8
#define SWAT 9
#define SOJAVAGI 10
#define CIA 11

// Then cars
enum TeamCars
{
LSPD,
Mafia
}
new Cars[TeamCars][MAX_TEAM_CARS];

public OnGameModeInit()
{  
    Cars[LSPD][0] = CreateVehicle(401,2251.7415,2476.0071,10.5993,1.2631,52,52,900); // LSPD 1
    Cars[LSPD][1] = CreateVehicle(401,2255.8970,2476.3103,10.5995,0.5224,52,52,900); // LSPD 2
    Cars[LSPD][2] = CreateVehicle(401,2260.5508,2475.9434,10.5994,0.9976,52,52,900); // LSPD 3
    Cars[LSPD][3] = CreateVehicle(401,2260.5461,2460.9810,10.5996,358.9507,52,52,900); // LSPD 4
    Cars[LSPD][4] = CreateVehicle(401,2255.9341,2459.5439,10.5996,359.6339,52,52,900); // LSPD 5
    Cars[LSPD][5] = CreateVehicle(401,2251.6504,2458.6802,10.5993,359.5941,52,52,900); // LSPD 6
    Cars[LSPD][6] = CreateVehicle(401,2251.5488,2444.1545,10.5999,359.5937,52,52,900); // LSPD 7
    Cars[LSPD][7] = CreateVehicle(401,2255.6819,2443.7505,10.5997,357.4008,52,52,900); // LSPD 8
    Cars[LSPD][8] = CreateVehicle(401,2260.6716,2444.4990,10.5998,2.3976,52,52,900); // LSPD 9
    return 1;
}

// Then that
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        for(new i=0;i<=8;i++)if(CarCheck==Cars[LSPD][i])
        {
            if(gTeam[playerid] != POLITSEI)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "[LSPD] - Sa ei ole politseinik!");
                return 1;
            }
            else
            {
                return 1;
            }
        }
        VehicleModel[playerid] = GetVehicleModel(GetPlayerVehicleID(playerid));
        ShowGameTextForPlayer(playerid);
        SendClientMessage(playerid,COLOR_GREEN,"Sa sisenesid autosse! Vajuta number 2 , et masinat parandada & flippida!");
        return 1;
    }
    if(newstate != PLAYER_STATE_DRIVER && (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)) KillTimer(CFCTimer);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)