12.06.2017, 16:08
The best way to approach this depends on a lot of factors: whether a mission involves one player or multiple players, whether there is just one ambulance, a predetermined number of ambulances or an indeterminate number of ambulances and whether each crew manages exactly one ambulance.
I would probably create an enum structure somewhat similar to:
I would probably create an enum structure somewhat similar to:
PHP код:
#define MAX_AMBULANCE_CREW (4)
enum AmbulanceMission
{
ambulanceId, // contains vehicleid of ambulance
crewIds[MAX_AMBULANCE_CREW], // contains crew members playerids
loaded
}
new gMissionInstances[5][AmbulanceMission]; // 5 being the maximum number of missions that can be started simultaneously
PHP код:
public OnVehicleDeath(vehicleid, killerid)
{
for(new i; i < sizeof gMissionInstances; i++)
{
if(gMissionInstance[i][ambulanceId] == vehicleid)
{
TriggerAmbulanceMissionFailed(i); // trigger a function that says instance "i" failed
break;
}
}
}
PHP код:
TriggerAmbulanceMissionFailed(instance)
{
for(new i; i < MAX_AMBULANCE_CREW; i++)
{
GameTextForPlayer(gMissionInstances[instance][crewIds][i], "~r~Mission Failed", 9000, 0);
}
}