Vehicle problems
#1

I have a government vehicles and everyone can enter them

Whats worng here?:

else if(IsGovVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 2)
{
new Floatos[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.");
}



// Government Vehicles
FacInfo[2][fCars][0] = CreateVehicle(507,1454.8049,-1749.6432,13.4354,359.8442,0,0,1800); // Gov 1
FacInfo[2][fCars][1] = CreateVehicle(507,1507.4797,-1749.7860,13.4354,359.8442,0,0,1800); // Gov 2
FacInfo[2][fCars][2] = CreateVehicle(579,1253.69995117,-2042.50000000,59.70000076,0.00000000,0,0,1800); //Huntley
FacInfo[2][fCars][3] = CreateVehicle(409,1248.59997559,-2034.19995117,59.59999847,0.00000000,0,0,1800); //Stretch
FacInfo[2][fCars][4] = CreateVehicle(579,1244.19995117,-2042.40002441,59.70000076,0.00000000,0,0,1800); //Huntley
FacInfo[2][fCars][5] = CreateVehicle(579,1253.69995117,-2026.09997559,59.70000076,0.00000000,0,0,1800); //Huntley
FacInfo[2][fCars][6] = CreateVehicle(579,1243.80004883,-2025.09997559,59.70000076,0.00000000,0,0,1800); //Huntley
FacInfo[2][fCars][7] = CreateVehicle(579,1248.50000000,-2022.30004883,59.70000076,0.00000000,0,0,1800); //Huntley
FacInfo[2][fCars][8] = CreateVehicle(426,1253.50000000,-2035.19995117,59.40000153,0.00000000,0,0,1800); //Premier
FacInfo[2][fCars][9] = CreateVehicle(426,1244.00000000,-2034.69995117,59.59999847,0.00000000,0,0,1800); //Premier
FacInfo[2][fCars][10] = CreateVehicle(487,1116.80004883,-2052.39990234,74.50000000,0.00000000,0,0,1800); //Maverick
FacInfo[2][fCars][11] = CreateVehicle(487,1116.50000000,-2021.00000000,74.50000000,181.75000000,0,0,1800); //Maverick
FacInfo[2][fCars][12] = CreateVehicle(461,1250.80004883,-2042.50000000,59.40000153,0.00000000,0,0,1800); //PCJ-600
FacInfo[2][fCars][13] = CreateVehicle(461,1246.80004883,-2042.09997559,59.40000153,0.00000000,0,0,1800); //PCJ-600*/

return 1;
Reply
#2

Check OnPlayerStateChange
Reply
#3

you have to give restrictions for the players
Reply
#4

Quote:
Originally Posted by DIRTYBYT3
Посмотреть сообщение
Check OnPlayerStateChange
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_PASSENGER)
{
SetPlayerArmedWeapon(playerid,0);
}
if(newstate == PLAYER_STATE_PASSENGER)
{
if(newstate == PLAYER_STATE_PASSENGER)
{
new gun,tmp;
GetPlayerWeaponData(playerid,4,gun,tmp);
#pragma unused tmp
if(gun)SetPlayerArmedWeapon(playerid,gun);
else SetPlayerArmedWeapon(playerid,0);
}
}
if(newstate == PLAYER_STATE_DRIVER && oldstate != PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
// if(!engine) SendClientMessage(playerid, COLOR_WHITE, "You can start or stop the vehicle's engine using {FF6347}/engine{FFFFFF}.");
if(!engine) GameTextForPlayer(playerid, "~w~/engine to turn on/off the vehicle engine.", 3500, 3);
//if(!PlayerInfo[playerid][pCarLic]) SendClientMessage(playerid, COLOR_LIGHTRED, " You don't have a drivers license, beware of cops.");
//if(IsATowTruck(vehicleid)) SendClientMessage(playerid, COLOR_WHITE, "You can tow a vehicle using {FF6347}/tow{FFFFFF}.");
}
return 1;
}
Reply
#5

else if(IsGovVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 2)
{
new Floatos[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.");
----------TRY THIS-------
RemovePlayerFromVehicle(playerid);
}
Reply
#6

Quote:
Originally Posted by DIRTYBYT3
Посмотреть сообщение
else if(IsGovVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 2)
{
new Floatos[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.");
----------TRY THIS-------
RemovePlayerFromVehicle(playerid);
}
Already tryed it isnt work
Reply
#7

So your problem is OnPlayerEnterVehicle... the restrictions would be there
Reply
#8

Quote:
Originally Posted by DIRTYBYT3
Посмотреть сообщение
So your problem is OnPlayerEnterVehicle... the restrictions would be there
The first thing i sended is OnPlayerEnterVehicle
Reply
#9

Show your OnPlayerEnterVehicle please i can't see the problem
Reply
#10

Quote:
Originally Posted by DIRTYBYT3
Посмотреть сообщение
Show your OnPlayerEnterVehicle please i can't see the problem
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(!ispassenger)
{
if(IsDMVCar(vehicleid))
{
if(!LicenseTest[playerid])
{
new Floatos[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,980.1932,-1407.9902,13.0956,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))
{
new Floatos[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 Floatos[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 Floatos[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 Floatos[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 Floatos[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 Floatos[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(IsTruckerVehicle(vehicleid) && PlayerInfo[playerid][pJob] != JOB_TRUCKER)
{
new Floatos[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 Floatos[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.");
}

}
return 1;
}
Reply
#11

Ok remove "new Floatos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
SetPlayerPos(playerid, pos[0], pos[1], pos[2]);"
Put only this:
if(IsGovVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 2)
{
SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the GOV.");
RemovePlayerFromVehicle(playerid);
}

}
return 1;
}
Reply
#12

Quote:
Originally Posted by DIRTYBYT3
Посмотреть сообщение
Ok remove "new Floatos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
SetPlayerPos(playerid, pos[0], pos[1], pos[2]);"
Put only this:
if(IsGovVehicle(vehicleid) && PlayerInfo[playerid][pFac] != 2)
{
SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the GOV.");
RemovePlayerFromVehicle(playerid);
}

}
return 1;
}
Aint working
Reply
#13

PHP код:
ClearAnimations(playerid); 
Have you try this one? put it in OnPlayerEnterVehicle It's worked fine for me
Should be like this:

PHP код:
if(!LicenseTest[playerid])
{
    
SendClientMessage(playeridCOLOR_ORANGE"You are not taking a drivers license test.");
    
ClearAnimations(playerid);

Reply
#14

Quote:
Originally Posted by Tenka
Посмотреть сообщение
PHP код:
ClearAnimations(playerid); 
Have you try this one? put it in OnPlayerEnterVehicle It's worked fine for me
Should be like this:

PHP код:
if(!LicenseTest[playerid])
{
    
SendClientMessage(playeridCOLOR_ORANGE"You are not taking a drivers license test.");
    
ClearAnimations(playerid);

aint work too
Reply
#15

All right. How do you define IsGovVehicle?
put before OnGameModeInit ()
IsGovVehicle (carid) {if ((carid> = 1) && (carid <= 5)) {return 1;} return 0;}
then check on public OnPlayerStateChange (playerid, newstate, oldstate)
public OnPlayerStateChange (playerid, newstate, oldstate)
{
if (IsPlayerNPC (playerid))
{
return 1;
}
if (newstate == PLAYER_STATE_DRIVER)
{
GetVehicleParamsEx (newcar, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx (newcar, engineOn [newcar], lights, alarm, doors, bonnet, boot, objective);
if (IsGovVehicle(newcar))
{
if (PlayerInfo[playerid][pFac] == 2) {return 1; }
else RemovePlayerFromVehicle (playerid); SendClientMessage(playerid, COLOR_ORANGE, " You can't start the engine as it belongs to the GOV.");
}
return 1;
}

that should work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)