06.01.2016, 08:06
Sometimes the cars will stay for ages then sometimes not it's really odd. I'm not sure if it's in the saving or the loading too. Any help to tidy the script up would be nice
This may look newbie but I've just spend the last 3 hours trying different things
Car 1's Script (I'll add some //'s to explain what bit is which)
Car 2
This may look newbie but I've just spend the last 3 hours trying different things
Car 1's Script (I'll add some //'s to explain what bit is which)
pawn Код:
new Car[MAX_PLAYERS];
new CarPaint[MAX_PLAYERS];
new CarColor1[MAX_PLAYERS];
new CarColor2[MAX_PLAYERS];
if(Car[playerid]>0){DestroyVehicle(Car[playerid]);} // Destroys car when player leaves
public OnVehiclePaintjob(playerid,vehicleid,paintjobid)
{
if(vehicleid==Car[playerid]){CarPaint[playerid]=paintjobid;}
if(vehicleid==Car2[playerid]){CarPaint2[playerid]=paintjobid;}
return 1;
}
public OnVehicleRespray(playerid,vehicleid,color1,color2)
{
if(vehicleid==Car[playerid])
{
CarColor1[playerid]=color1;
CarColor2[playerid]=color2;
}
if(vehicleid==Car2[playerid])
{
CarColor21[playerid]=color1;
CarColor22[playerid]=color2;
}
return 1;
}
//Under Stock CStats
Car[playerid]=0;
CarColor1[playerid]=0;
CarColor2[playerid]=0;
CarPaint[playerid]=255;
//Under Stock LoadStats
CarColor1[playerid]=INI_Int(Acc(playerid),"Col1");
CarColor2[playerid]=INI_Int(Acc(playerid),"Col2");
CarPaint[playerid]=INI_Int(Acc(playerid),"CarPaint");
if(INI_Int(Acc(playerid),"Car")>0)
{
Car[playerid]=AddStaticVehicleEx(INI_Int(Acc(playerid),"Car"),INI_Int(Acc(playerid),"CarX"),INI_Int(Acc(playerid),"CarY"),INI_Int(Acc(playerid),"CarZ"),INI_Int(Acc(playerid),"CarR"),CarColor1[playerid],CarColor2[playerid],-1);
fuel[Car[playerid]]=INI_Int(Acc(playerid),"Fuel");
SetVehicleParamsEx(Car[playerid],0,0,0,1,0,0,0);
ChangeVehiclePaintjob(Car[playerid],CarPaint[playerid]);
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C1"));
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C2"));
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C3"));
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C4"));
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C5"));
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C6"));
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C7"));
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C8"));
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C9"));
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C10"));
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C11"));
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C12"));
AddVehicleComponent(Car[playerid],INI_Int(Acc(playerid),"C13"));
if(strcmp(VehNum[playerid],"None",true)!=0){SetVehicleNumberPlate(Car[playerid],VehNum[playerid]);}
if(strcmp(VehNum[playerid],"None",true)==0){SetVehicleNumberPlate(Car[playerid],PlayerName(playerid));}
//Under SStats
if(Car[playerid]==0)
{
INI_IntSet(Acc(playerid),"C1",0);
INI_IntSet(Acc(playerid),"C2",0);
INI_IntSet(Acc(playerid),"C3",0);
INI_IntSet(Acc(playerid),"C4",0);
INI_IntSet(Acc(playerid),"C5",0);
INI_IntSet(Acc(playerid),"C6",0);
INI_IntSet(Acc(playerid),"C7",0);
INI_IntSet(Acc(playerid),"C8",0);
INI_IntSet(Acc(playerid),"C9",0);
INI_IntSet(Acc(playerid),"C10",0);
INI_IntSet(Acc(playerid),"C11",0);
INI_IntSet(Acc(playerid),"C12",0);
INI_IntSet(Acc(playerid),"C13",0);
INI_IntSet(Acc(playerid),"Car",0);
INI_IntSet(Acc(playerid),"Fuel",0);
INI_IntSet(Acc(playerid),"CarX",0);
INI_IntSet(Acc(playerid),"CarY",0);
INI_IntSet(Acc(playerid),"CarZ",0);
INI_IntSet(Acc(playerid),"CarR",0);
INI_IntSet(Acc(playerid),"CarPaint",255);
}
if(Car[playerid]>0)
{
new Float:nx,Float:ny,Float:nz,Float:nrot;
GetVehicleZAngle(Car[playerid],nrot);
GetVehiclePos(Car[playerid],nx,ny,nz);
INI_IntSet(Acc(playerid),"CarX",floatround(nx));
INI_IntSet(Acc(playerid),"CarY",floatround(ny));
INI_IntSet(Acc(playerid),"CarZ",floatround(nz));
INI_IntSet(Acc(playerid),"CarR",floatround(nrot));
INI_IntSet(Acc(playerid),"Col1",CarColor1[playerid]);
INI_IntSet(Acc(playerid),"Col2",CarColor2[playerid]);
INI_IntSet(Acc(playerid),"Fuel",fuel[Car[playerid]]);
INI_IntSet(Acc(playerid),"CarPaint",CarPaint[playerid]);
INI_IntSet(Acc(playerid),"Car",GetVehicleModel(Car[playerid]));
INI_IntSet(Acc(playerid),"C1",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_SPOILER));
INI_IntSet(Acc(playerid),"C2",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_HOOD));
INI_IntSet(Acc(playerid),"C3",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_ROOF));
INI_IntSet(Acc(playerid),"C4",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_SIDESKIRT));
INI_IntSet(Acc(playerid),"C5",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_EXHAUST));
INI_IntSet(Acc(playerid),"C6",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_WHEELS));
INI_IntSet(Acc(playerid),"C7",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_HYDRAULICS));
INI_IntSet(Acc(playerid),"C8",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_FRONT_BUMPER));
INI_IntSet(Acc(playerid),"C9",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_REAR_BUMPER));
INI_IntSet(Acc(playerid),"C10",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_LAMPS));
INI_IntSet(Acc(playerid),"C11",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_NITRO));
INI_IntSet(Acc(playerid),"C12",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_VENT_RIGHT));
INI_IntSet(Acc(playerid),"C13",GetVehicleComponentInSlot(Car[playerid],CARMODTYPE_VENT_LEFT));
}
pawn Код:
new Car2[MAX_PLAYERS];
if(Car2[playerid]>0){DestroyVehicle(Car2[playerid]);}
public OnVehiclePaintjob(playerid,vehicleid,paintjobid)
{
if(vehicleid==Car[playerid]){CarPaint[playerid]=paintjobid;}
if(vehicleid==Car2[playerid]){CarPaint2[playerid]=paintjobid;}
return 1;
}
public OnVehicleRespray(playerid,vehicleid,color1,color2)
{
if(vehicleid==Car[playerid])
{
CarColor1[playerid]=color1;
CarColor2[playerid]=color2;
}
if(vehicleid==Car2[playerid])
{
CarColor21[playerid]=color1;
CarColor22[playerid]=color2;
}
return 1;
}
//Under Stock CStats
Car2[playerid]=0;
CarColor21[playerid]=0;
CarColor22[playerid]=0;
CarPaint2[playerid]=255;
//Under Stock LoadStats
CarColor21[playerid]=INI_Int(Acc(playerid),"Col21");
CarColor22[playerid]=INI_Int(Acc(playerid),"Col22");
CarPaint2[playerid]=INI_Int(Acc(playerid),"CarPaint2");
if(INI_Int(Acc(playerid),"Car2")>0)
{
Car2[playerid]=AddStaticVehicleEx(INI_Int(Acc(playerid),"Car2"),INI_Int(Acc(playerid),"CarXX"),INI_Int(Acc(playerid),"CarYY"),INI_Int(Acc(playerid),"CarZZ"),INI_Int(Acc(playerid),"CarRR"),CarColor21[playerid],CarColor22[playerid],-1);
fuel[Car2[playerid]]=INI_Int(Acc(playerid),"FuelL");
SetVehicleParamsEx(Car2[playerid],0,0,0,1,0,0,0);
ChangeVehiclePaintjob(Car2[playerid],CarPaint2[playerid]);
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C11"));
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C22"));
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C33"));
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C44"));
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C55"));
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C66"));
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C77"));
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C88"));
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C99"));
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C100"));
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C110"));
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C120"));
AddVehicleComponent(Car2[playerid],INI_Int(Acc(playerid),"C130"));
if(strcmp(VehNum[playerid],"None",true)!=0){SetVehicleNumberPlate(Car2[playerid],VehNum[playerid]);}
if(strcmp(VehNum[playerid],"None",true)==0){SetVehicleNumberPlate(Car2[playerid],PlayerName(playerid));}
//SStats
if(Car2[playerid]==0)
{
INI_IntSet(Acc(playerid),"C11",0);
INI_IntSet(Acc(playerid),"C22",0);
INI_IntSet(Acc(playerid),"C33",0);
INI_IntSet(Acc(playerid),"C44",0);
INI_IntSet(Acc(playerid),"C55",0);
INI_IntSet(Acc(playerid),"C66",0);
INI_IntSet(Acc(playerid),"C77",0);
INI_IntSet(Acc(playerid),"C88",0);
INI_IntSet(Acc(playerid),"C99",0);
INI_IntSet(Acc(playerid),"C100",0);
INI_IntSet(Acc(playerid),"C110",0);
INI_IntSet(Acc(playerid),"C120",0);
INI_IntSet(Acc(playerid),"C130",0);
INI_IntSet(Acc(playerid),"Car2",0);
INI_IntSet(Acc(playerid),"FuelL",0);
INI_IntSet(Acc(playerid),"CarXX",0);
INI_IntSet(Acc(playerid),"CarYY",0);
INI_IntSet(Acc(playerid),"CarZZ",0);
INI_IntSet(Acc(playerid),"CarRR",0);
INI_IntSet(Acc(playerid),"CarPaint2",255);
}
if(Car2[playerid]>0)
{
new Float:nx,Float:ny,Float:nz,Float:nrot;
GetVehicleZAngle(Car2[playerid],nrot);
GetVehiclePos(Car2[playerid],nx,ny,nz);
INI_IntSet(Acc(playerid),"CarXX",floatround(nx));
INI_IntSet(Acc(playerid),"CarYY",floatround(ny));
INI_IntSet(Acc(playerid),"CarZZ",floatround(nz));
INI_IntSet(Acc(playerid),"CarRR",floatround(nrot));
INI_IntSet(Acc(playerid),"Col21",CarColor21[playerid]);
INI_IntSet(Acc(playerid),"Col22",CarColor22[playerid]);
INI_IntSet(Acc(playerid),"FuelL",fuel[Car2[playerid]]);
INI_IntSet(Acc(playerid),"CarPaint2",CarPaint2[playerid]);
INI_IntSet(Acc(playerid),"Car2",GetVehicleModel(Car2[playerid]));
INI_IntSet(Acc(playerid),"C11",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_SPOILER));
INI_IntSet(Acc(playerid),"C22",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_HOOD));
INI_IntSet(Acc(playerid),"C33",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_ROOF));
INI_IntSet(Acc(playerid),"C44",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_SIDESKIRT));
INI_IntSet(Acc(playerid),"C55",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_EXHAUST));
INI_IntSet(Acc(playerid),"C66",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_WHEELS));
INI_IntSet(Acc(playerid),"C77",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_HYDRAULICS));
INI_IntSet(Acc(playerid),"C88",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_FRONT_BUMPER));
INI_IntSet(Acc(playerid),"C99",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_REAR_BUMPER));
INI_IntSet(Acc(playerid),"C100",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_LAMPS));
INI_IntSet(Acc(playerid),"C110",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_NITRO));
INI_IntSet(Acc(playerid),"C120",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_VENT_RIGHT));
INI_IntSet(Acc(playerid),"C130",GetVehicleComponentInSlot(Car2[playerid],CARMODTYPE_VENT_LEFT));
}