DestroyVechicle(vechicleid)
#1

Anyone can help me after spawning another car the vehicle destroy. And after exiting the car it will destroy after 3mins.
Reply
#2

Code:
public OnPlayerExitVehicle(playerid, vehicleid)
{ 
        SetTimerEx("DestoryCars",180000,0,"i",vehicleid);
	return 1;
}
forward DesytoryCars(vehicleid);
public DesytoryCars(vehicleid)
{
DestroyVechicle(vechicleid);
return 1;
}
i think is like that
Reply
#3

Quote:
Originally Posted by peterory
View Post
Code:
public OnPlayerExitVehicle(playerid, vehicleid)
{ 
        SetTimerEx("DestoryCars",180000,0,"i",vehicleid);
	return 1;
}
forward DesytoryCars(vehicleid);
public DesytoryCars(vehicleid)
{
DestroyVechicle(vechicleid);
return 1;
}
i think is like that
then when the player spawn he's first car
you should do that
Code:
new cars[MAX_PLAYERS];
           COMMAND:car(playerid,params[]) //you can change to another command
           {
           CreateVehicle(vechicleid,x,y,z); //don't follow me to do
           cars[playerid] = vechicleid; // the most important
           return 1;
           }
then
when player spawn a new car using the command
you can use DestroyVechicle(cars[playerid]); to destory that car
Reply
#4

For your first want

pawn Code:
new IsVehTemp[MAX_VEHICLES]; // a global variable for temporary vehicles


// now in your vehicle spawner command //

// make sure you do this with any temporary vehicle
new veh = GetPlayerVehicleID(playerid); // after putting the player into the vehicle get its id
IsVehTemp[veh] = 1; // now setting it to 1 which means it's temporary


// and add this before you spawn a new vehicle for a player, it will destroy the prev vehicle
if(IsPlayerInAnyVehicle(playerid))
{
    new veh = GetPlayerVehicleID(playerid);
    RemovePlayerFromVehicle(playerid);
    IsVehTemp[veh] = 0; // setting it to 0 means it's not temporary
    DestroyVehicle(veh); // destroy it
}
and this to destroy a vehicle after 3 minutes:
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_DRIVER) // if driver
    {
        new v = GetPlayerVehicleID(playerid); // storing the player's vehicle id into the variable v
        SetTimerEx("DestroyVehic", 180000, false, "d", v); // setting a timer that will call DestroyVehic after 3 minutes
    }
    return 1;
}

// forwarding the public
forward DestroyVehic(v);

public DestroyVehic(v)
{
    // when the DestroyVehic public is called
    DestroyVehicle(v); // destroy the vehicle v
    return 1;
}
Reply
#5

Quote:
Originally Posted by peterory
View Post
then when the player spawn he's first car
you should do that
Code:
new cars[MAX_PLAYERS];
           COMMAND:car(playerid,params[]) //you can change to another command
           {
           CreateVehicle(vechicleid,x,y,z); //don't follow me to do
           cars[playerid] = vechicleid; // the most important
           return 1;
           }
then
when player spawn a new car using the command
you can use DestroyVechicle(cars[playerid]); to destory that car
Im using this vehicle dialog http://pastebin.com/D95eGrWr i dont want to use other or make a new command coz i think its not compatible and will give me errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)