PDA

View Full Version : Car problem....


Euan Hughes
19/06/2012, 10:03 PM
Hey guys, I have recently been trying to add a extra car slot to obviously players can have more than 3 cars.. It is fine apart from one thing which I have been stuck on for ages.. when I buy the vehicle it's fine, It gives me the "PlayerCarModel" and it saves when a player logs out.. but with the Car4LinkID.. Well once I have bought a vehicle it loads it and it's fine until I log out and when I log back in it just resets itself to 0.. Any one got any ideas?


public PurchaseCar(playerid, carid, price, slotid)
{
new string[128];
if(carid < 400 || carid > 611)
{
SendClientMessage(playerid, WHITE, "Valid car IDs start from 400, ending at 611.");
return 1;
}
else
{
if(Player[playerid][Money] >= price)
{
switch(slotid)
{
case 4:
{
if(Player[playerid][PlayerCarModel4] > 0)
{
SendClientMessage(playerid, WHITE, "You already have a vehicle in slot 4, /abandoncar first.");
}
else
{
Player[playerid][Car4OwnedCarModSlot0] = 0;
Player[playerid][Car4OwnedCarModSlot1] = 0;
Player[playerid][Car4OwnedCarModSlot2] = 0;
Player[playerid][Car4OwnedCarModSlot3] = 0;
Player[playerid][Car4OwnedCarModSlot4] = 0;
Player[playerid][Car4OwnedCarModSlot5] = 0;
Player[playerid][Car4OwnedCarModSlot6] = 0;
Player[playerid][Car4OwnedCarModSlot7] = 0;
Player[playerid][Car4OwnedCarModSlot8] = 0;
Player[playerid][Car4OwnedCarModSlot9] = 0;
Player[playerid][Car4OwnedCarModSlot10] = 0;
Player[playerid][Car4OwnedCarModSlot11] = 0;
Player[playerid][Car4OwnedCarModSlot12] = 0;
Player[playerid][Car4OwnedCarModSlot13] = 0;

Player[playerid][Money] -= price;
Player[playerid][Car4X] = OwnedCarSpawnX;
Player[playerid][Car4Y] = OwnedCarSpawnY;
Player[playerid][Car4Z] = OwnedCarSpawnZ;
Player[playerid][PlayerCarModel4] = carid;
Player[playerid][Car4Col1] = 0;
Player[playerid][Car4Col2] = 0;
SpawnOwnedCar(playerid, 4);
SavePlayerData(playerid);
}
}
}
}
}
}



stock SpawnOwnedCar(playerid, slotid)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
if(IsPlayerConnectedEx(playerid))
{
switch(slotid)
{
case 4:
{
if(Player[playerid][PlayerCarModel4] >= 1)
{
if(Player[playerid][Car4LinkID] >= 1)
{
DestroyVehicle(Player[playerid][Car4LinkID]);
Player[playerid][Car4LinkID] = 0;
}

CarCount++;
OwnedCarCount++;
Player[playerid][Car4LinkID] = CreateVehicle(Player[playerid][PlayerCarModel4], Player[playerid][Car4X], Player[playerid][Car4Y], Player[playerid][Car4Z], Player[playerid][Car4ZAngle], Player[playerid][Car4Col1], Player[playerid][Car4Col2], -1);
GetVehicleParamsEx(Player[playerid][Car4LinkID], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(Player[playerid][Car4LinkID], 0, lights, alarm, 0, bonnet, boot, 0);
SendClientMessage(playerid, WHITE, "Your forth owned vehicle has been spawned. If you can't find it, please use the /callcar command.");

if(GetVehicleModel(Player[playerid][Car4LinkID]) != Player[playerid][PlayerCarModel4])
{
DestroyVehicle(Player[playerid][Car4LinkID]);
Player[playerid][Car4LinkID] = 0;
Player[playerid][Car4LinkID] = CreateVehicle(Player[playerid][PlayerCarModel4], Player[playerid][Car4X], Player[playerid][Car4Y], Player[playerid][Car4Z], Player[playerid][Car4ZAngle], Player[playerid][Car4Col1], Player[playerid][Car4Col2], -1);
}

ChangeVehiclePaintjob(Player[playerid][Car4LinkID], Player[playerid][Car4PaintJobID]);

if(Player[playerid][Car4OwnedCarModSlot0] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot0]);
}

if(Player[playerid][Car4OwnedCarModSlot1] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot1]);
}

if(Player[playerid][Car4OwnedCarModSlot2] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot2]);
}

if(Player[playerid][Car4OwnedCarModSlot3] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot3]);
}

if(Player[playerid][Car4OwnedCarModSlot4] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot4]);
}

if(Player[playerid][Car4OwnedCarModSlot5] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot5]);
}

if(Player[playerid][Car4OwnedCarModSlot6] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot6]);
}

if(Player[playerid][Car4OwnedCarModSlot7] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot7]);
}

if(Player[playerid][Car4OwnedCarModSlot9] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot9]);
}

if(Player[playerid][Car4OwnedCarModSlot10] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot10]);
}

if(Player[playerid][Car4OwnedCarModSlot11] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot11]);
}

if(Player[playerid][Car4OwnedCarModSlot12] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot12]);
}

if(Player[playerid][Car4OwnedCarModSlot13] > 0)
{
AddVehicleComponent(Player[playerid][Car4LinkID], Player[playerid][Car4OwnedCarModSlot13]);
}
}
}
}
}


If you need to see any more code just let me know and i will post it..

Thanks