12.12.2011, 08:31
Hello, I'm trying to make other planes, doing flights to, but the problem is: Compiles with no errors, but when entering the plane ingame and doing /work it don't let me do the job what returns the error message: You have not the correct piloting vehicle to start a job.
Code:
And:
Code:
pawn Код:
Pilot_StartRandomJob(playerid)
{
// Setup local variables
new PilotJobSet;
// Check the vehicle-model of the player to decide which job the player can get
switch (GetVehicleModel(GetPlayerVehicleID(playerid)))
{
case VehicleShamal, VehicleNevada, VehicleDodo: // Select a random job for planes
PilotJobSet = Pilot_Plane_SetRandomJob(playerid);
case VehicleMaverick, VehicleCargobob: // Select a random job for helicopters
PilotJobSet = Pilot_Heli_SetRandomJob(playerid);
case 592:
PilotJobSet = Pilot_Andromada_SetRandomJob(playerid);
}
// Check if a job was set correctly
switch (PilotJobSet)
{
case 1, 2:
{
// Setup local variables
new StartLoc[50], EndLoc[50], Load[50], RouteText[255], Float:x, Float:y, Float:z, LoadMsg[128];
// Job has started
APlayerData[playerid][JobStarted] = true;
// Set jobstep to 1 (going to load the goods)
APlayerData[playerid][JobStep] = 1;
// Get the startlocation, endlocation and the load texts
format(StartLoc, 50, ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
format(EndLoc, 50, ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
format(Load, 50, ALoads[APlayerData[playerid][LoadID]][LoadName]);
// Combine it all into a string for the TextDraw (the player can see this all the time) to describe the mission
format(RouteText, 255, TXT_TransportingFromToPickup, Load, StartLoc, EndLoc);
// Set the TextDraw so the player can see it
TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
// Grab the x, y, z positions for the first location
x = ALocations[APlayerData[playerid][JobLoc1]][LocX];
y = ALocations[APlayerData[playerid][JobLoc1]][LocY];
z = ALocations[APlayerData[playerid][JobLoc1]][LocZ];
// Create a checkpoint where the player should load the goods
SetPlayerRaceCheckpoint(playerid, 2, x, y, z, 0, 0, 0, 7);
// Inform the player that he must load his goods
format(LoadMsg, 128, TXT_PickupCargoAt, Load, StartLoc);
SendClientMessage(playerid, 0xFFFFFFFF, LoadMsg);
}
}
return 1;
}
pawn Код:
Pilot_Andromada_SetRandomJob(playerid)
{
// If the player is the driver of the vehicle (GetPlayerVehicleSeat returns -1 if the player is not in a vehicle)
if (GetPlayerVehicleSeat(playerid) == 0)
{
// Check the vehicle-model of the player to decide which job the player can get
switch (GetVehicleModel(GetPlayerVehicleID(playerid)))
{
case VehicleAndromada:
{
// Get a random LoadID from the pilot-products (only the planes)
APlayerData[playerid][LoadID] = Product_GetRandom(PCV_VehicleAndromada);
// Also get a random start-location and end-location
APlayerData[playerid][JobLoc1] = Product_GetRandomStartLoc(APlayerData[playerid][LoadID]);
APlayerData[playerid][JobLoc2] = Product_GetRandomEndLoc(APlayerData[playerid][LoadID]);
// Make sure the destination is not closeby (pilot-locations are ALL includes in the array)
while (Locations_CheckDistance(APlayerData[playerid][JobLoc1], APlayerData[playerid][JobLoc2], 1000.0) == 0)
{
// If both locations are too close together, keep searching for a random delivery-location that's further away
APlayerData[playerid][JobLoc2] = Product_GetRandomEndLoc(APlayerData[playerid][LoadID]);
}
// Return 1 to indicate that a job has been set correctly
return 1;
}
}
}
// If no job could be set correctly, return 0
return 0;
}