29.01.2014, 12:23
So, here's it, title says the problem I'm having
any ideas?
pawn Код:
#define MAX_VEHICLES_BUILT 1000
#define V_AMOUNT 1918
public GetDriverID(vehicleid)
{
for(new i=0; i<V_AMOUNT; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInAnyVehicle(i))
{
if(GetPlayerVehicleID(i) == vehicleid)
{
return i;
}
}
}
}
return -1;
}
enum VehicleInf
{
Owner[24],
Label[20],
Price,
Float:posX,
Float:posY,
Float:posZ,
Float:posA,
Col1,
Col2,
vModel,
vID,
vLock,
Text3D:VehicleLabel,
mod1,
mod2,
mod3,
mod4,
mod5,
mod6,
mod7,
mod8,
mod9,
mod10,
mod11,
mod12,
mod13,
mod14,
mod15,
mod16,
mod17,
paintjob
}
new VInfo[MAX_VEHICLES_BUILT][VehicleInf];
new Vehiclesnumbers;
new VehicleSpawn[MAX_VEHICLES_BUILT];
new InsideVehicle[MAX_PLAYERS];
//loading vehicles working fine, when I edit the file manually.
forward LoadVehicles_data(vehicleid, name[], value[]);
public LoadVehicles_data(vehicleid, name[], value[])
{
INI_String("Owner", VInfo[vehicleid][Owner], 24);
INI_Int("Price", VInfo[vehicleid][Price]);
INI_Float("posX", VInfo[vehicleid][posX]);
INI_Float("posY", VInfo[vehicleid][posY]);
INI_Float("posZ", VInfo[vehicleid][posZ]);
INI_Float("posA", VInfo[vehicleid][posA]);
INI_Int("Color1", VInfo[vehicleid][Col1]);
INI_Int("Color2", VInfo[vehicleid][Col2]);
INI_Int("Model", VInfo[vehicleid][vModel]);
INI_Int("ID", VInfo[vehicleid][vID]);
INI_Int("Lock", VInfo[vehicleid][vLock]);
INI_Int("mod1", VInfo[vehicleid][mod1]);
INI_Int("mod2", VInfo[vehicleid][mod2]);
INI_Int("mod3", VInfo[vehicleid][mod3]);
INI_Int("mod4", VInfo[vehicleid][mod4]);
INI_Int("mod5", VInfo[vehicleid][mod5]);
INI_Int("mod6", VInfo[vehicleid][mod6]);
INI_Int("mod7", VInfo[vehicleid][mod7]);
INI_Int("mod8", VInfo[vehicleid][mod8]);
INI_Int("mod9", VInfo[vehicleid][mod9]);
INI_Int("mod10", VInfo[vehicleid][mod10]);
INI_Int("mod11", VInfo[vehicleid][mod11]);
INI_Int("mod12", VInfo[vehicleid][mod12]);
INI_Int("mod13", VInfo[vehicleid][mod13]);
INI_Int("mod14", VInfo[vehicleid][mod14]);
INI_Int("mod15", VInfo[vehicleid][mod15]);
INI_Int("mod16", VInfo[vehicleid][mod16]);
INI_Int("mod17", VInfo[vehicleid][mod17]);
INI_Int("paintjob", VInfo[vehicleid][paintjob]);
return 1;
}
//Components IDs after
//Here's the problem I guess, note that, OnPlayerEnterVehicle, InsideVehicle[playerid] =VehicleID; is working fine when I use /lock and etc.. I use the same method for lock and park and it's working, so check it out
public SaveComponent(vehicleid, componentid)
{
new playerid = GetDriverID(vehicleid);
new file[60];
format(file,sizeof(file),"Vehicles/%i.ini",InsideVehicle[playerid]);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
for(new s=0; s<20; s++){
if(componentid == spoiler[s])
{
VInfo[InsideVehicle[playerid]][mod1] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod1", componentid);
INI_Close(File);
}
}
for(new s=0; s<3; s++) {
if(componentid == nitro[s])
{
VInfo[InsideVehicle[playerid]][mod2] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod2", componentid);
INI_Close(File);
}
}
for(new s=0; s<23; s++) {
if(componentid == fbumper[s])
{
VInfo[InsideVehicle[playerid]][mod3] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod3", componentid);
INI_Close(File);
}
}
for(new s=0; s<22; s++) {
if(componentid == rbumper[s])
{
VInfo[InsideVehicle[playerid]][mod4] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod4", componentid);
INI_Close(File);
}
}
for(new s=0; s<28; s++) {
if(componentid == exhaust[s])
{
VInfo[InsideVehicle[playerid]][mod5] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod5", componentid);
INI_Close(File);
}
}
for(new s=0; s<2; s++) {
if(componentid == bventr[s])
{
VInfo[InsideVehicle[playerid]][mod6] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod6", componentid);
INI_Close(File);
}
}
for(new s=0; s<2; s++) {
if(componentid == bventl[s])
{
VInfo[InsideVehicle[playerid]][mod7] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod7", componentid);
INI_Close(File);
}
}
for(new s=0; s<4; s++) {
if(componentid == bscoop[s])
{
VInfo[InsideVehicle[playerid]][mod8] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod8", componentid);
INI_Close(File);
}
}
for(new s=0; s<13; s++) {
if(componentid == rscoop[s])
{
VInfo[InsideVehicle[playerid]][mod9] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod9", componentid);
INI_Close(File);
}
}
for(new s=0; s<21; s++) {
if(componentid == lskirt[s])
{
VInfo[InsideVehicle[playerid]][mod10] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod10", componentid);
INI_Close(File);
}
}
for(new s=0; s<21; s++) {
if(componentid == rskirt[s])
{
VInfo[InsideVehicle[playerid]][mod11] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod11", componentid);
INI_Close(File);
}
}
for(new s=0; s<1; s++) {
if(componentid == hydraulics[s])
{
VInfo[InsideVehicle[playerid]][mod12] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod12", componentid);
INI_Close(File);
}
}
for(new s=0; s<1; s++) {
if(componentid == based[s])
{
VInfo[InsideVehicle[playerid]][mod13] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod13", componentid);
INI_Close(File);
}
}
for(new s=0; s<2; s++) {
if(componentid == rbbars[s])
{
VInfo[InsideVehicle[playerid]][mod14] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod14", componentid);
INI_Close(File);
}
}
for(new s=0; s<2; s++) {
if(componentid == fbbars[s])
{
VInfo[InsideVehicle[playerid]][mod15] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod15", componentid);
INI_Close(File);
}
}
for(new s=0; s<17; s++) {
if(componentid == wheels[s])
{
VInfo[InsideVehicle[playerid]][mod16] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod16", componentid);
INI_Close(File);
}
}
for(new s=0; s<2; s++) {
if(componentid == vlights[s])
{
VInfo[InsideVehicle[playerid]][mod17] = componentid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"mod17", componentid);
INI_Close(File);
}
}
return 1;
}
return 0;
}
public SavePaintjob(vehicleid, paintjobid)
{
new playerid = GetDriverID(vehicleid);
new file[60];
format(file,sizeof(file),"Vehicles/%i.ini",InsideVehicle[playerid]);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
VInfo[InsideVehicle[playerid]][paintjob] = paintjobid;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"paintjob", paintjobid);
INI_Close(File);
return 1;
}
return 0;
}
public SaveColors(vehicleid, color1, color2)
{
new playerid = GetDriverID(vehicleid);
new file[60];
format(file,sizeof(file),"Vehicles/%i.ini",InsideVehicle[playerid]);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
VInfo[InsideVehicle[playerid]][Col1] = color1;
VInfo[InsideVehicle[playerid]][Col2] = color2;
new INI:File = INI_Open(file);
INI_WriteFloat(File,"Color1", color1);
INI_WriteFloat(File,"Color2", color2);
INI_Close(File);
return 1;
}
return 0;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
SaveComponent(InsideVehicle[playerid], componentid);
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
SavePaintjob(InsideVehicle[playerid], paintjobid);
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
SaveColors(InsideVehicle[playerid], color1, color2);
return 1;
}