Car deleting/despawning ??
#1

Hello all, i have this code:
PHP код:
            new veh;
            if(
IsPlayerInAnyVehicle(playerid))
            {
            
SendClientMessage(playerid0xFFFFFFFF"You are already in a vehicle, leave your car to spawn a new one.");
            }
            else
            
veh CreateVehicle(4152135.12, -2552.6513.559000100000000000000000000000000);
            
PutPlayerInVehicle(playerid,veh,0);
            
SetCameraBehindPlayer(playerid); 
And i have:

PHP код:
public OnPlayerExitVehicle(playeridvehicleid)
{
    new 
vehicleid2 GetPlayerVehicleID(playerid);
    
DestroyVehicle(vehicleid2);
    return 
1;

But i want, when he exits the vehicle, the car mustn't spawn again. It must despawn/go away completely. But it just re-spawns when he exits.
Reply
#2

FOR THE LOVE OF GOD, LEARN TO CONSULT THE WIKIPEDIA FIRST AND TRY EXPERIMENT A BIT!
Reply
#3

Berlovan... FOR THE LOVE OF GOD, READ MY PROBLEM!

DestroyVehicle(vehicleid2);

I ALREADY TRIED but dont work -.-
Reply
#4

Nevermind i already fixed it on my own.
Reply
#5

pawn Код:
new UsualCar; // Top of script

UsualCar = CreateVehicle(415, 2135.12, -2552.65, 13.55, 90, 0, 0, 100000000000000000000000000);  //OnGameModeInit

///////////////////////////////////  [ Your Code ]  ////////////////////////////////////////////////////

            if(IsPlayerInAnyVehicle(playerid))
            {
            SendClientMessage(playerid, 0xFFFFFFFF, "You are already in a vehicle, leave your car to spawn a new one.");
            }
            else
            PutPlayerInVehicle(playerid,UsualCar,0);
            SetCameraBehindPlayer(playerid);  
////////////////////////////////////////////////// [ Sum Code ] //////////////////////////////////////////////////

public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(vehicleid == UsualCar)
{
    DestroyVehicle(UsualCar);
}
    return 1;
}
Try this.
Reply
#6

I already fixed that one. But got a problem with this one:

PHP код:
public OnVehicleDeath(vehicleidkillerid)
{
    new 
vehicleid3 GetPlayerVehicleID(killerid);
    
DestroyVehicle(vehicleid3);
    return 
1;

It wont destroy.
Reply
#7

Try mine.
Reply
#8

Quote:
Originally Posted by Berlovan
Посмотреть сообщение
pawn Код:
new UsualCar; // Top of script

UsualCar = CreateVehicle(415, 2135.12, -2552.65, 13.55, 90, 0, 0, 100000000000000000000000000);  //OnGameModeInit

///////////////////////////////////  [ Your Code ]  ////////////////////////////////////////////////////

            if(IsPlayerInAnyVehicle(playerid))
            {
            SendClientMessage(playerid, 0xFFFFFFFF, "You are already in a vehicle, leave your car to spawn a new one.");
            }
            else
            PutPlayerInVehicle(playerid,UsualCar,0);
            SetCameraBehindPlayer(playerid);  
////////////////////////////////////////////////// [ Sum Code ] //////////////////////////////////////////////////

public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(vehicleid == UsualCar)
{
    DestroyVehicle(UsualCar);
}
    return 1;
}
Try this.
so with this code you can destroy all vehicles with the variable usualcar or is it only 1?
Reply
#9

But Berlovan, in my script you can spawn that car with a menu. If someone destroys it all will get destroyed. And there are also 4-5 cars more, is there something like if no one drives the car, it will get destroyed?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)