PDA

View Full Version : Owned vehicles creates its duplicate copies.


Laure
06/06/2014, 11:06 AM
I m having a serious problem with my server, the vehicles that are owned and /park respawn multiple of it in the particular place and even in the previously parked location and also i cant destroy those copies as it returns the vehicle is owned means it really is a serious problem.Hope a help frmu guyz. My park command...

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;
}

Laure
06/06/2014, 11:37 AM
C'mon man someone help me.

jessejanssen
06/06/2014, 11:58 AM
I don't really see what is causing it, all I can suspect is that the vehicle creation/storing it's ID in the variables will go wrong. You could/should easily test this (And could use this as solution) by replacing;
DestroyVehicle(FamInfo[idx][fVeh][veh]);
DestroyVehicle(PlayerInfo[playerid][pVeh]);
DestroyVehicle(PlayerInfo[playerid][pVVeh]);
All three by;
DestroyVehicle(GetPlayerVehicleID(playerid));
this was it should always destroy the vehicle you're in and then spawn a new one instead of keeping to duplicate it.

Best regards,
Jesse

EDIT:
With the FamInfo you should delete the if statement aswell, this is getting too complicated, use this;
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]);
new seat = GetPlayerVehicleSeat(playerid);
DestroyVehicle(GetPlayerVehicleID(playerid));
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);
PutPlayerInVehicle(playerid, FamInfo[idx][fVeh][veh], seat);
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]);
new seat = GetPlayerVehicleSeat(playerid);
DestroyVehicle(GetPlayerVehicleID(playerid));
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);
PutPlayerInVehicle(playerid, PlayerInfo[playerid][pVeh], seat);
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]);
new seat = GetPlayerVehicleSeat(playerid);
DestroyVehicle(GetPlayerVehicleID(playerid));
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);
PutPlayerInVehicle(playerid, PlayerInfo[playerid][pVVeh], seat);
ChangeVehiclePaintjob(PlayerInfo[playerid][pVVeh], PlayerInfo[playerid][vVPJ]);
for(new i=0; i<14; i++)
{
AddVehicleComponent(PlayerInfo[playerid][pVVeh], PlayerInfo[playerid][pVVehMod][i]);
}
}
return 1;
}

Laure
06/06/2014, 01:44 PM
Will this really work,?

jessejanssen
06/06/2014, 06:17 PM
Will this really work,?
I think it will, try and you will find out!

Best regards,
Jesse

Laure
07/06/2014, 01:57 AM
Well ye now i dont see the duplicate vehicles that had already been created, looks like script deleted it, thanks anyways, will holla at you if any problem regarding it arises again. :)

Laure
07/06/2014, 07:15 AM
This actually didnt work :(

jessejanssen
07/06/2014, 01:11 PM
This actually didnt work :(
What is it doing?

Best regards,
Jesse

Laure
07/06/2014, 01:25 PM
Fixed it, It wasnt deleting owned vehicles upon ClearChar while a player disconnected.