Car will not spawn away (get destroyed)
#1

For some reason when I use this command my vehicle re-spawns after I park it. I have a separate command to spawn cars. I was wondering if anyone could help me out. Thanks

pawn Код:
CMD:park(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not in a vehicle.");
    // Family Vehicles
    if(IsFamVehicle(GetPlayerVehicleID(playerid)) && Fam[GetPlayerVehicleID(playerid)] == PlayerInfo[playerid][pFam])
    {
        new idx = PlayerInfo[playerid][pFam], veh = GFVS(GetPlayerVehicleID(playerid));

        GetVehiclePos(GetPlayerVehicleID(playerid), FamInfo[idx][fVehCoX][veh], FamInfo[idx][fVehCoY][veh], FamInfo[idx][fVehCoZ][veh]);
        GetVehicleZAngle(GetPlayerVehicleID(playerid), FamInfo[idx][fVehRot][veh]);
        if(FamInfo[idx][fVehType][veh])
        {
            DestroyVehicle(FamInfo[idx][fVeh][veh]);
        }
        FamInfo[idx][fVeh][veh] = CreateVehicle(FamInfo[idx][fVehType][veh], FamInfo[idx][fVehCoX][veh], FamInfo[idx][fVehCoY][veh], FamInfo[idx][fVehCoZ][veh], FamInfo[idx][fVehRot][veh], FamInfo[idx][fVehCol1][veh], FamInfo[idx][fVehCol2][veh], 1200);
        ChangeVehicleColor(FamInfo[idx][fVeh][veh], FamInfo[idx][fVehCol1][veh], FamInfo[idx][fVehCol2][veh]);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, " You have parked your family vehicle, it will always spawn here until you park it somewhere else.");
        return 1;
    }
    // Owned Vehicles
    if(GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pVeh] && GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pVVeh]) return SendClientMessage(playerid, COLOR_GREY, "You are not in a vehicle you can park.");
    SendClientMessage(playerid, COLOR_LIGHTBLUE, " You have parked your vehicle, it will always spawn here until you park it somewhere else.");
    if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
    {
        for(new i=0; i<14; i++)
        {
            PlayerInfo[playerid][pVehMod][i] = GetVehicleComponentInSlot(PlayerInfo[playerid][pVeh], i);
        }
        GetVehiclePos(PlayerInfo[playerid][pVeh],PlayerInfo[playerid][vX], PlayerInfo[playerid][vY], PlayerInfo[playerid][vZ]);
        GetVehicleZAngle(PlayerInfo[playerid][pVeh],PlayerInfo[playerid][vA]);
        DestroyVehicle(PlayerInfo[playerid][pVeh]);
        PlayerInfo[playerid][pVeh] = CreateVehicle(PlayerInfo[playerid][vModel], PlayerInfo[playerid][vX], PlayerInfo[playerid][vY], PlayerInfo[playerid][vZ],PlayerInfo[playerid][vA],PlayerInfo[playerid][vC1],PlayerInfo[playerid][vC2],1200);
        ChangeVehiclePaintjob(PlayerInfo[playerid][pVeh], PlayerInfo[playerid][vPJ]);
        for(new i=0; i<14; i++)
        {
            AddVehicleComponent(PlayerInfo[playerid][pVeh], PlayerInfo[playerid][pVehMod][i]);
        }
    }
    else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
    {
        for(new i=0; i<14; i++)
        {
            PlayerInfo[playerid][pVVehMod][i] = GetVehicleComponentInSlot(PlayerInfo[playerid][pVVeh], i);
        }
        GetVehiclePos(PlayerInfo[playerid][pVVeh],PlayerInfo[playerid][vVX], PlayerInfo[playerid][vVY], PlayerInfo[playerid][vVZ]);
        GetVehicleZAngle(PlayerInfo[playerid][pVVeh],PlayerInfo[playerid][vVA]);
        DestroyVehicle(PlayerInfo[playerid][pVVeh]);
        PlayerInfo[playerid][pVVeh] = CreateVehicle(PlayerInfo[playerid][vVModel], PlayerInfo[playerid][vVX], PlayerInfo[playerid][vVY], PlayerInfo[playerid][vVZ],PlayerInfo[playerid][vVA],PlayerInfo[playerid][vVC1],PlayerInfo[playerid][vVC2],1200);
        ChangeVehiclePaintjob(PlayerInfo[playerid][pVVeh], PlayerInfo[playerid][vVPJ]);
        for(new i=0; i<14; i++)
        {
            AddVehicleComponent(PlayerInfo[playerid][pVVeh], PlayerInfo[playerid][pVVehMod][i]);
        }
    }
    return 1;
}
Reply
#2

I think because you are creating the vehicle again after you are destroying it.

pawn Код:
FamInfo[idx][fVeh][veh] = CreateVehicle(FamInfo[idx][fVehType][veh], FamInfo[idx][fVehCoX][veh], FamInfo[idx][fVehCoY][veh], FamInfo[idx][fVehCoZ][veh], FamInfo[idx][fVehRot][veh], FamInfo[idx][fVehCol1][veh], FamInfo[idx][fVehCol2][veh], 1200);
        ChangeVehicleColor(FamInfo[idx][fVeh][veh], FamInfo[idx][fVehCol1][veh], FamInfo[idx][fVehCol2][veh]);
Try putting that above the DestroyVehicle statement.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)