14.08.2012, 11:47
EDIT: DON'T post alternatives such as OnPlayerStateUpdate, I'm not asking for that, if I wanted to do it with OPSU I would do it
so I'm trying to "update" my OnPlayerEnterVehicle with my "Speedometer" and Fuel, however I'm encountering REALLY strange problem
from this we can all clearly see that my code stops after this control statement "if" and even ELSE don't runs
so I'm trying to "update" my OnPlayerEnterVehicle with my "Speedometer" and Fuel, however I'm encountering REALLY strange problem
- Entering Vehicle as a Driver
- What Should Happen:
- Check if I can enter vehicle
- if no: Stop Function, SendClientMessage "0"
- else: Set pDriver to 1, Display Textdraws, Enters Vehicle, SendClientMessage "1"
- What Happens:
- Check if I can enter vehicle
- if no: Stop Function, SendClientMessage "0"
- else: Enters Vehicle
- What Should Happen:
- Entering Vehicle as a Passenger
- What Should Happen
- Display Textdraws
- What Happens
- Display Textdraws
- What Should Happen
from this we can all clearly see that my code stops after this control statement "if" and even ELSE don't runs
pawn Код:
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
pawn Код:
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;
}