When the vehicle is destroyed Mission ends
#1

Hello,

I'm currently making a mission for ambulance where the crew load up supplies into it before taking it back to base.

However, I don't know how to get it so if the ambulance is destroyed (and the players survive) the mission ends and checkpoints are removed.

I've had a look at the OnVehicleDeath function but I don't want it to end everytime an ambulance is destroyed, only when it has been loaded up.

Thanks
Reply
#2

If I understand:
You need to make a variable like
PHP код:
//On top
new bool:IsAmbLoaded[MAX_VEHICLES]; 
Once you load the ambulance in your script set it to true with
PHP код:
IsAmbLoaded[vehicleid] = true//The vehicleid is the ambulance 
and do the check onvehicledeath like
PHP код:
public OnVehicleDeath(vehicleidkillerid

    if(
GetVehicleModel(vehicleid) == 416 && IsAmbLoaded[vehicleid] == true
    { 
        
//Mission failed
        
IsAmbLoaded[vehicleid] = false//Don't forget to reset the var to false after the mission end 
    


Reply
#3

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:
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(vehicleidkillerid)
{
    for(new 
isizeof gMissionInstancesi++)
    {
        if(
gMissionInstance[i][ambulanceId] == vehicleid)
        {
            
TriggerAmbulanceMissionFailed(i); // trigger a function that says instance "i" failed
            
break;
        }
    }

PHP код:
TriggerAmbulanceMissionFailed(instance)
{
    for(new 
iMAX_AMBULANCE_CREWi++)
    {
        
GameTextForPlayer(gMissionInstances[instance][crewIds][i], "~r~Mission Failed"90000);
    }

Reply
#4

Hi thanks for the replies,

Only the driver can use the command to start the mission. The command can be used in any ambulance on the server.

I'll have a read through it all and make sure I understand it.

Thanks again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)