SA-MP Forums Archive
Job cars respawn when exit them. [+REP] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Job cars respawn when exit them. [+REP] (/showthread.php?tid=597236)



Job cars respawn when exit them. [+REP] - EgyptForLife - 28.12.2015

Hello again SA-MP Forums,
I need some help in making vehicles that belong to jobs (truckers, mow cutter, pizza boy etc...) respawn when they exit them. I only need the job vehicles and not all of them!

PHP код:
// GARBAGE TRUCK
public IsAGarbageTruck(carid)
{
    if(
carid == garbage[1] || carid == garbage[2] || carid == garbage[3])
    {
        return 
1;
    }
    return 
0;
}
// BUS
public IsABus(carid)
{
    if(
carid == bus[1] || carid == bus[2] || carid == bus[3] || carid == bus[4] || carid == bus[5])
    {
        return 
1;
    }
    return 
0;
}
// PIZZA SCOOTER
public IsAPizza(carid)
{
    if(
carid == pizza[1] || carid == pizza[2] || carid == pizza[3] || carid == pizza[4] || carid == pizza[5])
    {
        return 
1;
    }
    return 
0;
}
// PRODUCT CAR
public IsAProdCar(carid)
{
    if(
carid == carprod[1] || carid == carprod[2] || carid == carprod[3] || carid == carprod[4])
    {
        return 
1;
    }
    return 
0;
}
// MOWER CAR
public IsAMower(carid)
{
    if(
carid == mower[1] || carid == mower[2] || carid == mower[3] || carid == mower[4])
    {
        return 
1;
    }
    return 
0;
}
// TRUCK
public IsATruck(carid)
{
    if(
carid == truck[1] || carid == truck[2] || carid == truck[3] || carid == truck[4] || carid == truck[5] || carid == truck[6] || carid == truck[7] || carid == truck[8])
    {
        return 
1;
    }
    return 
0;
}
// PETROL TRUCK
public IsAPetrolTruck(carid)
{
    if(
carid == truck2[1] || carid == truck2[2] || carid == truck2[3] || carid == truck2[4] || carid == truck2[5] || carid == truck2[6] || carid == truck2[7] || carid == truck2[8])
    {
        return 
1;
    }
    return 
0;

The one who'll help me will get +REP!


Re: Job cars respawn when exit them. [+REP] - TwinkiDaBoss - 28.12.2015

Do this
PHP код:
new MechanicJobCars[2];
MechanicJobCars[0] = CreateVehicle( .... );
MechanicJobCars[1] = CreateVehicle( .... );
public 
OnPlayerStateChange(playeridnewstateoldstate) {
    if(
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) { //if they entered the certain vehicle as driver
        
for(new isizeof(MechanicJobCars); i++) { //Loop thru all mechanic job cars
            
if(IsPlayerInVehicle(playerid,MechanicJobCars[i]) { //if they entered car ID MechanicJobCar
                
if(PlayerJob[playerid] != 1) { //if their job isnt ID 1, change with your check
                    
RemovePlayerFromVehicle(playerid); //remove them from the vehicle if they dont have the job they need
                
}
            }
        }
    }
    return 
true;




Re: Job cars respawn when exit them. [+REP] - SmoW - 28.12.2015

Try this:

Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
	if(IsAMower(vehicleid) || IsAPetrolTruck(vehicleid) || IsATruck(vehicle))
	{
		SetVehicleToRespawn(vehicleid);
	}
	else if(IsAProdCar(vehicleid) || IsAPizza(vehicleid) || IsAGarbageTruck(vehicleid))
	{
	    SetVehicleToRespawn(vehicleid);
	}
	return 1;
}



Re: Job cars respawn when exit them. [+REP] - ATGOggy - 28.12.2015

PHP код:
public OnPlayerExitVehicle(playeridvehicleid)
{
    if(
IsAGarbageTruck(vehicleid) || IsABus(vehicleid) || IsAPizza(vehicleid) || IsAProdCar(vehicleid) || IsAMower(vehicleid) || IsATruck(vehicleid) || IsAPetrolTruck(vehicleid)) SetVehicleToRespawn(vehicleid);
    return 
1;