Mission help -
SomebodyAndMe - 12.12.2011
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:
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;
}
And:
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;
}
Re: Mission help -
wildcookie007 - 12.12.2011
How are the vehicle variables defined which you use in case?
Re: Mission help -
SomebodyAndMe - 12.12.2011
As Vehicle... (onthe dots the modelname)
pawn Код:
enum TPlane
{
PlaneName[50], // Holds the name of the Plane
PlaneModel // Holds the model-ID of the Plane
}
new APlanes[][TPlane] =
{
{"Andromada", 592}, {"AT400", 577}, {"Beagle", 511}, {"Cargobob", 548}, // ID 0, 1, 2, 3
{"Cropduster", 512}, {"Dodo", 593}, {"Hunter", 425}, {"Hydra", 520}, // ID 4, 5, 6, 7
{"Leviathan", 417}, {"Maverick", 487}, {"Nevada", 553}, {"Police Maverick", 497}, // ID 8, 9, 10, 11
{"Raindance", 563}, {"Rustler", 476}, {"SAN News Maverick", 488}, {"Seasparrow", 447}, // ID 12, 13, 14, 15
{"Shamal", 519}, {"Skimmer", 460}, {"Sparrow", 469}, {"Stuntplane", 513} // ID 16, 17, 18, 19
};
Re: Mission help -
wildcookie007 - 12.12.2011
Well, try doing a simple clientmessage to yourself to check what vehicle it returns, if the vehicleid is bad you can use less defines and easier way to do this.
By the way, you can define only vehicle names and theres a function to get ID from the name(I'm saying that your defines are probably wrong)