Any player can drive any vehicle
#1

Here's the code, but for some strange reason, any player can enter any car and drive?

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    SendClientMessage(playerid, COLOR_WHITE, "Remember to wear your seatbelt so you don't get fined!(/belt).");
    if(PlayerInfo[playerid][pCarLic] == 0) return SendClientMessage(playerid, COLOR_GREY, "You are driving without a license!");
	if(!ispassenger)
	{
       if (g_bIsRobbiz[playerid])
       {
           DestroyObject(g_robbizBag[playerid]);
       }
       if(IsDMVCar(vehicleid))
		{
		    if(!LicenseTest[playerid])
		    {
			    new Float:pos[3];
			    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
			    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		        SendClientMessage(playerid, COLOR_ORANGE, "You are not taking a drivers license test.");
		    }
		    else
		    {
		        SendClientMessage(playerid, COLOR_LIGHTBLUE, "* GPS: Finish the test by driving through all of the checkpoints on your GPS.");
		        SetPlayerCheckpoint(playerid,959.7175,-1403.0309,13.1974,5);
		        SendClientMessage(playerid, COLOR_RED, "If you exit the car your test will be failed and it will have to be re-done.");
		    }
		}
	    else if(IsFamVehicle(vehicleid) && Fam[vehicleid] != PlayerInfo[playerid][pFam] && !IsACop(playerid) && !IsADOC(playerid) && !IsASAAF(playerid) && !IsSASD(playerid))
		{
		    new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to a family.");
		}
	    else if(IsLeoVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 1)
	    {
		    new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the LSPD.");
	    }
	    else if(IsLSFMDVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 5)
	    {
		    new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the LSFMD.");
	    }
	    else if(IsNewsVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 4)
	    {
		    new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the News Agency.");
	    }
	    else if(IsFBIVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 6)
	    {
		    new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the FBI.");
	    }
	    else if(IsNGVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 7)
	    {
		    new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the NG.");
	    }
     	else if(IsRETOVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 9)
	    {
		    new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to Rebel's Towing");
	    }
	    else if(IsTaxiVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 10)
	    {
		    new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to LS Taxi Co");
	    }
	    else if(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pJob] != JOB_TRUCKER)
	    {
	    	new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the Truckers.");
	    }
	    else if(IsGovVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 2)
	    {
		    new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the GOV.");
	    }
	    else if(IsSAAFVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 11)
	    {
		    new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the SA Air Force.");
	    }
	    else if(IsDOCVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 13)
	    {
		    new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the Department Of Correct.");
	    }
	    else if(IsSASDVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 8)
	    {
		    new Float:pos[3];
		    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
		    SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the San Andreas Sherrif Department.");
	    }

	}
	return 1;
}
Reply
#2

You didn't use
RemovePlayerFromVehicle(playerid);
After sending the client message.
Reply
#3

Quote:
Originally Posted by DavidBilla
Посмотреть сообщение
You didn't use
RemovePlayerFromVehicle(playerid);
After sending the client message.
Tried it..didn't work. :/ Even the client messages don't come up.
Reply
#4

If I remember correctly, you need to get the player's faction info before the function actually begins GetPlayerInfo(playerid, ..........)
Reply
#5

Quote:
Originally Posted by Blade_Cervetti
Посмотреть сообщение
If I remember correctly, you need to get the player's faction info before the function actually begins GetPlayerInfo(playerid, ..........)
I'm sure the function '
Код:
else if(IsLeoVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 1)
already does that
Reply
#6

Give this a shot:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    SendClientMessage(playerid, COLOR_WHITE, "Remember to wear your seatbelt so you don't get fined!(/belt).");
    if(!PlayerInfo[playerid][pCarLic]) SendClientMessage(playerid, COLOR_GREY, "You are driving without a license!");
    if(!ispassenger)
    {
       if(g_bIsRobbiz[playerid]) DestroyObject(g_robbizBag[playerid]);
       if(IsDMVCar(vehicleid))
        {
            if(!LicenseTest[playerid]) SendClientMessage(playerid, COLOR_ORANGE, "You are not taking a drivers license test.");
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "* GPS: Finish the test by driving through all of the checkpoints on your GPS.");
                SetPlayerCheckpoint(playerid, 959.7175, -1403.0309, 13.1974, 5);
                SendClientMessage(playerid, COLOR_RED, "If you exit the car your test will be failed and it will have to be re-done.");
                return 1;
            }
        }
        else if(IsFamVehicle(vehicleid) && Fam[vehicleid] != PlayerInfo[playerid][pFam] && !IsACop(playerid) && !IsADOC(playerid) && !IsASAAF(playerid) && !IsSASD(playerid))
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to a family.");
        else if(IsLeoVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 1)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the LSPD.");
        else if(IsLSFMDVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 5)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the LSFMD.");
        else if(IsNewsVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 4)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the News Agency.");
        else if(IsFBIVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 6)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the FBI.");
        else if(IsNGVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 7)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the NG.");
        else if(IsRETOVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 9)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to Rebel's Towing");
        else if(IsTaxiVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 10)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to LS Taxi Co");
        else if(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pJob] != JOB_TRUCKER)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the Truckers.");
        else if(IsGovVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 2)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the GOV.");
        else if(IsSAAFVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 11)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the SA Air Force.");
        else if(IsDOCVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 13)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the Department Of Correct.");
        else if(IsSASDVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 8)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the San Andreas Sherrif Department.");
        else return 1;
        new Float:pos[3];
        GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
        SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    }
    return 1;
}
Just rearranging the if and else if statements, and removing some unnecessary 'returns'.
Reply
#7

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Give this a shot:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    SendClientMessage(playerid, COLOR_WHITE, "Remember to wear your seatbelt so you don't get fined!(/belt).");
    if(!PlayerInfo[playerid][pCarLic]) SendClientMessage(playerid, COLOR_GREY, "You are driving without a license!");
    if(!ispassenger)
    {
       if(g_bIsRobbiz[playerid]) DestroyObject(g_robbizBag[playerid]);
       if(IsDMVCar(vehicleid))
        {
            if(!LicenseTest[playerid]) SendClientMessage(playerid, COLOR_ORANGE, "You are not taking a drivers license test.");
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "* GPS: Finish the test by driving through all of the checkpoints on your GPS.");
                SetPlayerCheckpoint(playerid, 959.7175, -1403.0309, 13.1974, 5);
                SendClientMessage(playerid, COLOR_RED, "If you exit the car your test will be failed and it will have to be re-done.");
                return 1;
            }
        }
        else if(IsFamVehicle(vehicleid) && Fam[vehicleid] != PlayerInfo[playerid][pFam] && !IsACop(playerid) && !IsADOC(playerid) && !IsASAAF(playerid) && !IsSASD(playerid))
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to a family.");
        else if(IsLeoVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 1)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the LSPD.");
        else if(IsLSFMDVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 5)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the LSFMD.");
        else if(IsNewsVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 4)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the News Agency.");
        else if(IsFBIVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 6)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the FBI.");
        else if(IsNGVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 7)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the NG.");
        else if(IsRETOVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 9)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to Rebel's Towing");
        else if(IsTaxiVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 10)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to LS Taxi Co");
        else if(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pJob] != JOB_TRUCKER)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the Truckers.");
        else if(IsGovVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 2)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the GOV.");
        else if(IsSAAFVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 11)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the SA Air Force.");
        else if(IsDOCVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 13)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the Department Of Correct.");
        else if(IsSASDVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 8)
            SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the San Andreas Sherrif Department.");
        else return 1;
        new Float:pos[3];
        GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
        SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    }
    return 1;
}
Just rearranging the if and else if statements, and removing some unnecessary 'returns'.
THANK YOU! +Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)