SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 27/11/2012, 10:52 PM   #1
EAsT-OAK_510
Huge Clucker
 
EAsT-OAK_510's Avatar
 
Join Date: Jul 2012
Location: Your mom's panties
Posts: 207
Reputation: 15
Default Car will not spawn away (get destroyed)

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 Code:
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;
}
EAsT-OAK_510 is offline   Reply With Quote
Old 28/11/2012, 01:59 AM   #2
PlayLSX_Founder
Big Clucker
 
Join Date: Jul 2012
Posts: 85
Reputation: 30
Default Re: Car will not spawn away (get destroyed)

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

pawn Code:
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.
PlayLSX_Founder is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 12:51 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.