SA-MP Forums Archive
Police and SRT Car problems - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Police and SRT Car problems (/showthread.php?tid=308862)



Police and SRT Car problems - SomebodyAndMe - 05.01.2012

As title said, it doesn't let police people in the police cars.

pawn Код:
// Check if the player is not a cop
            if (APlayerData[playerid][PlayerClass] != ClassPolice)
            {
                // First check if the vehicle is a static vehicle (player can still use a bought cop-car that he bought in his house,
                // as a bought vehicle isn't static)
                if (AVehicleData[vid][StaticVehicle] == true)
                {
                    // Check if the entered vehicle is a cop vehicle
                    switch (GetVehicleModel(vid))
                    {
                        case VehiclePoliceLSPD, VehiclePoliceSFPD, VehiclePoliceLVPD, VehicleHPV1000, VehiclePoliceRanger:
                        {
                            // Force the player out of the vehicle
                            RemovePlayerFromVehicle(playerid);
                            // Turn off the lights and engine
                            GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
                            SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
                            // Let the player know he cannot use a cop car
                            SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use a police vehicle");
                        }
                    }
                }
            }
            // Check if the player is not a cop
            if (APlayerData[playerid][PlayerClass] != ClassSRT)
            {
                // First check if the vehicle is a static vehicle (player can still use a bought cop-car that he bought in his house,
                // as a bought vehicle isn't static)
                if (AVehicleData[vid][StaticVehicle] == true)
                {
                    // Check if the entered vehicle is a cop vehicle
                    switch (GetVehicleModel(vid))
                    {
                        case VehiclePoliceLSPD, VehiclePoliceSFPD, VehiclePoliceLVPD, VehicleHPV1000, VehiclePoliceRanger:
                        {
                            // Force the player out of the vehicle
                            RemovePlayerFromVehicle(playerid);
                            // Turn off the lights and engine
                            GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
                            SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
                            // Let the player know he cannot use a cop car
                            SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use a police vehicle");
                        }
                    }
                }
            }
REP+ if you helped me


Thanks


Re: Police and SRT Car problems - SomebodyAndMe - 07.01.2012

Bump


Re: Police and SRT Car problems - SomebodyAndMe - 15.01.2012




Re: Police and SRT Car problems - JamesC - 15.01.2012

Where does the variable vid come from?


Re: Police and SRT Car problems - SomebodyAndMe - 15.01.2012

pawn Код:
// Get the ID of the player's vehicle
            vid = GetPlayerVehicleID(playerid);



Re: Police and SRT Car problems - mineralo - 15.01.2012

use this is more easy, you just change the condition when check if it's cop or not
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(ispassenger == 0)
    {
    if(GetVehicleModel(vehicleid) == 523 || GetVehicleModel(vehicleid) == 596 || GetVehicleModel(vehicleid) == 497 || GetVehicleModel(vehicleid) == 427 || GetVehicleModel(vehicleid) == 601)
    {
    if(GetPlayerJobID(playerid)==2)
        {
        return 1;
        }
    else
        {
        SendClientMessage(playerid, c_r, "( ! ) This vehicle is for Police Officers only !");
        GetPlayerPos(playerid,Float:LocX,Float:LocY,Float:LocZ);
        SetPlayerPos(playerid,Float:LocX,Float:LocY,Float:LocZ);
        return 1;
        }
    }
}}
return 1;
}



Re: Police and SRT Car problems - SomebodyAndMe - 15.01.2012

Well this is current script now:
pawn Код:
// Check if the player is not a cop
            if (APlayerData[playerid][PlayerClass] != ClassPolice)
            {
                // First check if the vehicle is a static vehicle (player can still use a bought cop-car that he bought in his house,
                // as a bought vehicle isn't static)
                if (AVehicleData[vid][StaticVehicle] == true)
                {
                    // Check if the entered vehicle is a cop vehicle
                    switch (GetVehicleModel(vid))
                    {
                        case VehiclePoliceLSPD, VehiclePoliceSFPD, VehiclePoliceLVPD, VehicleHPV1000, VehiclePoliceRanger:
                        {
                            // Force the player out of the vehicle
                            RemovePlayerFromVehicle(playerid);
                            // Turn off the lights and engine
                            GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
                            SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
                            // Let the player know he cannot use a cop car
                            SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use a police vehicle");
                        }
                    }
                }
            }
When I change it to this:
pawn Код:
// Check if the player is not a cop
            if (APlayerData[playerid][PlayerClass] != ClassPolice || APlayerData[playerid[PlayerClass] != ClassSRT) // right here!!!
            {
                // First check if the vehicle is a static vehicle (player can still use a bought cop-car that he bought in his house,
                // as a bought vehicle isn't static)
                if (AVehicleData[vid][StaticVehicle] == true)
                {
                    // Check if the entered vehicle is a cop vehicle
                    switch (GetVehicleModel(vid))
                    {
                        case VehiclePoliceLSPD, VehiclePoliceSFPD, VehiclePoliceLVPD, VehicleHPV1000, VehiclePoliceRanger:
                        {
                            // Force the player out of the vehicle
                            RemovePlayerFromVehicle(playerid);
                            // Turn off the lights and engine
                            GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
                            SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
                            // Let the player know he cannot use a cop car
                            SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use a police vehicle");
                        }
                    }
                }
            }
It won't work for either Cops or SRT, so they both cannot enter it.


Re: Police and SRT Car problems - mineralo - 15.01.2012

TRY THIS
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(ispassenger == 0)
    {
    if(GetVehicleModel(vehicleid) == 523 || GetVehicleModel(vehicleid) == 596 || GetVehicleModel(vehicleid) == 497 || GetVehicleModel(vehicleid) == 427 || GetVehicleModel(vehicleid) == 601)
    {
    if(APlayerData[playerid][PlayerClass] == ClassPolice || APlayerData[playerid[PlayerClass] == ClassSRT)
        {
        return 1;
        }
    else
        {
        SendClientMessage(playerid, c_r, "( ! ) This vehicle is for Police Officers only !");
        GetPlayerPos(playerid,Float:LocX,Float:LocY,Float:LocZ);
        SetPlayerPos(playerid,Float:LocX,Float:LocY,Float:LocZ);
        return 1;
        }
    }
}}
return 1;
}
IT SHOULD WORK AT 100%


Re: Police and SRT Car problems - Mean - 15.01.2012

Quote:
Originally Posted by mineralo
Посмотреть сообщение
TRY THIS
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(ispassenger == 0)
    {
    if(GetVehicleModel(vehicleid) == 523 || GetVehicleModel(vehicleid) == 596 || GetVehicleModel(vehicleid) == 497 || GetVehicleModel(vehicleid) == 427 || GetVehicleModel(vehicleid) == 601)
    {
    if(APlayerData[playerid][PlayerClass] == ClassPolice || APlayerData[playerid[PlayerClass] == ClassSRT)
        {
        return 1;
        }
    else
        {
        SendClientMessage(playerid, c_r, "( ! ) This vehicle is for Police Officers only !");
        GetPlayerPos(playerid,Float:LocX,Float:LocY,Float:LocZ);
        SetPlayerPos(playerid,Float:LocX,Float:LocY,Float:LocZ);
        return 1;
        }
    }
}}
return 1;
}
IT SHOULD WORK AT 100%
That can't work...

Mind if I see how you set all those variables, such as static vehicle and player team?


Re: Police and SRT Car problems - HB - 15.01.2012

Quote:
Originally Posted by SomebodyAndMe
Посмотреть сообщение
Well this is current script now:
pawn Код:
// Check if the player is not a cop
            if (APlayerData[playerid][PlayerClass] != ClassPolice)
            {
                // First check if the vehicle is a static vehicle (player can still use a bought cop-car that he bought in his house,
                // as a bought vehicle isn't static)
                if (AVehicleData[vid][StaticVehicle] == true)
                {
                    // Check if the entered vehicle is a cop vehicle
                    switch (GetVehicleModel(vid))
                    {
                        case VehiclePoliceLSPD, VehiclePoliceSFPD, VehiclePoliceLVPD, VehicleHPV1000, VehiclePoliceRanger:
                        {
                            // Force the player out of the vehicle
                            RemovePlayerFromVehicle(playerid);
                            // Turn off the lights and engine
                            GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
                            SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
                            // Let the player know he cannot use a cop car
                            SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use a police vehicle");
                        }
                    }
                }
            }
When I change it to this:
pawn Код:
// Check if the player is not a cop
            if (APlayerData[playerid][PlayerClass] != ClassPolice || APlayerData[playerid[PlayerClass] != ClassSRT) // right here!!!
            {
                // First check if the vehicle is a static vehicle (player can still use a bought cop-car that he bought in his house,
                // as a bought vehicle isn't static)
                if (AVehicleData[vid][StaticVehicle] == true)
                {
                    // Check if the entered vehicle is a cop vehicle
                    switch (GetVehicleModel(vid))
                    {
                        case VehiclePoliceLSPD, VehiclePoliceSFPD, VehiclePoliceLVPD, VehicleHPV1000, VehiclePoliceRanger:
                        {
                            // Force the player out of the vehicle
                            RemovePlayerFromVehicle(playerid);
                            // Turn off the lights and engine
                            GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
                            SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
                            // Let the player know he cannot use a cop car
                            SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use a police vehicle");
                        }
                    }
                }
            }
It won't work for either Cops or SRT, so they both cannot enter it.
Err...
pawn Код:
// Check if the player is not a cop
if (APlayerData[playerid][PlayerClass] != ClassPolice || APlayerData[playerid[PlayerClass] != ClassSRT) // right here!!!
{
You're telling the script to continue if the player is not the police or SRT class.... It should be the other way around. Only continue when the player is ClassPolice or ClassSRT. So != has to be replaced with ==, and then it will work.