if(CanEnterVehicle(playerid, vehicleid) == 0) // runs
{
SendClientMessage(playerid, -1, "0"); // runs
return 1; // runs
}
else
SendClientMessage(playerid, -1, "1"); // NEVER and nothing else below this
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(ispassenger == 0)
{
if(CanEnterVehicle(playerid, vehicleid) == 0)
{
SendClientMessage(playerid, -1, "0");
return 1;
}
else
SendClientMessage(playerid, -1, "1");
pDriver[playerid] = 1;
}
FuelTimer[playerid] = SetTimerEx("VehicleFuelUpdate", 15000, 1, "ii", playerid, vehicleid);
TextDrawSetOutline(tSpeed[playerid], 1);
TextDrawShowForPlayer(playerid, tSpeed[playerid]);
new str[32];
format(str, sizeof(str), "%d l", Fuel[vehicleid]);
TextDrawSetString(tFuel[playerid], str);
TextDrawSetOutline(tFuel[playerid], 1);
TextDrawShowForPlayer(playerid, tFuel[playerid]);
SpeedTimer[playerid] = SetTimerEx("VehicleUpdate", 400, 1, "ii", playerid, vehicleid);
return 1;
}
CanEnterVehicle(playerid, vehicleid)
{
if(LockedCar[vehicleid] == 1 && PlayerCar[playerid] == vehicleid) // "==" for testing purposes, ignore it, ty
{
TogglePlayerControllable(playerid, true);
CustomShowTextDraw(playerid, TextDrawCreate(10.0, 250.0, "This Vehicle is Locked!"), 125, 5, 1);
return 0;
}
for(new i = 0; i < strlen(AirVehicle); i++)
{
if(vehicleid == AirVehicle[i])
{
if(PilotLicence[playerid] == 0)
{
CustomShowTextDraw(playerid, TextDrawCreate(10.0, 250.0, "You can't pilot air vehicles without the Pilot Licence!"), 175, 5, 1);
TogglePlayerControllable(playerid, true);
return 0;
}
}
}
if(DriverLicence[playerid] == 0)
{
TogglePlayerControllable(playerid, true);
CustomShowTextDraw(playerid, TextDrawCreate(10.0, 250.0, "You can't drive vehicles without the Driver Licence!"), 175, 5, 1);
return 0;
}
return 1;
}
I still do recommend using OnPlayerStateChange, because a player can still abort the entering even after OnPlayerEnterVehicle is called. If this happens, you will end up with a bugged system.
|
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(ispassenger == 0)
{
if(CanEnterVehicle(playerid, vehicleid) == 1)
{
SendClientMessage(playerid, -1, "0");
//return 1;
}
else
SendClientMessage(playerid, -1, "1");
//pDriver[playerid] = 1;
}
/*FuelTimer[playerid] = SetTimerEx("VehicleFuelUpdate", 15000, 1, "ii", playerid, vehicleid);
TextDrawSetOutline(tSpeed[playerid], 1);
TextDrawShowForPlayer(playerid, tSpeed[playerid]);
new str[32];
format(str, sizeof(str), "%d l", Fuel[vehicleid]);
TextDrawSetString(tFuel[playerid], str);
TextDrawSetOutline(tFuel[playerid], 1);
TextDrawShowForPlayer(playerid, tFuel[playerid]);
SpeedTimer[playerid] = SetTimerEx("VehicleUpdate", 400, 1, "ii", playerid, vehicleid);*/
return 1;
}