04.03.2012, 22:13
Can you figure out what's causing the vehicle position being set to 0, 0, 0 rather than the actual position?
Enum:
GameModeInit:
GameModeExit:
Loading the vehicle:
Creating the vehicle: (Works properly)
Enum:
pawn Код:
enum
e_VEHVARS {
ModelID, PrimaryColour, SecondaryColour, Modification[MAX_VEHICLE_MODS],
Owner[MAX_PLAYER_NAME], LicensePlate[MAX_PLATE_LENGTH], Locked,
Float:XPOS, Float:YPOS, Float:ZPOS, Float:APOS
}
pawn Код:
for( new v = 0; v < MAX_OWNED_VEHICLES; v++ ) {
format( vPath, sizeof( vPath ), VEHICLE_PATH, v);
if( fexist ( vPath ) ) {
INI_ParseFile( vPath, "LoadVehicle_%s", .bExtra = true, .extra = v);
vehID[ v ] = CreateVehicle( vehInfo[v][ ModelID ], vehInfo[v][ XPOS ], vehInfo[v][ YPOS ], vehInfo[v][ ZPOS ], vehInfo[v][ APOS ], vehInfo[v][ PrimaryColour ], vehInfo[v][ SecondaryColour ], -1 );
if(vehInfo[v][Locked] == 1) { SetVehicleParamsEx( vehID[v], 1, 1, 0, 0, 1, 0, 0); }
SetVehicleNumberPlate( vehID[ v ], vehInfo[v][ LicensePlate ] );
printf("[LOAD] Vehicle ID %d loaded | Model: %d, Owner: %s, Plate: %s", v, vehInfo[v][ModelID], vehInfo[v][Owner], vehInfo[v][LicensePlate]);
}
}
pawn Код:
for( new v = 0; v < MAX_OWNED_VEHICLES; v++ ) {
format( vPath, sizeof( vPath ), VEHICLE_PATH, v);
if( fexist ( vPath ) ) {
new
mStr[32],
Float:vPos[4],
C1, C2,
INI:vehFile = INI_Open( vPath );
GetVehiclePos( v, vPos[0], vPos[1], vPos[2] );
GetVehicleZAngle( v, vPos[3] );
GetVehicleColor( v, C1, C2 );
INI_SetTag(vehFile, "vehicle");
INI_WriteInt(vehFile, "ModelID", vehInfo[v][ModelID]);
INI_WriteInt(vehFile, "PrimaryColour", C1);
INI_WriteInt(vehFile, "SecondaryColour", C2);
INI_WriteInt(vehFile, "Locked", vehInfo[v][Locked]);
for( new m = 0; m < MAX_VEHICLE_MODS; m++ ) {
format( mStr, sizeof( mStr ), "Modification%d", m);
INI_WriteInt(vehFile, mStr, vehInfo[v][Modification][m]);
}
INI_WriteString(vehFile, "Owner", vehInfo[v][Owner]);
INI_WriteString(vehFile, "LicensePlate", vehInfo[v][LicensePlate]);
INI_WriteFloat(vehFile, "XPOS", vPos[0]);
INI_WriteFloat(vehFile, "YPOS", vPos[1]);
INI_WriteFloat(vehFile, "ZPOS", vPos[2]);
INI_WriteFloat(vehFile, "APOS", vPos[3]);
INI_Close( vehFile );
}
}
pawn Код:
stock LoadVehicles( ) {
new
vStr[32];
for( new v = 0; v < MAX_OWNED_VEHICLES; v++ ) {
format( vStr, sizeof( vStr ), VEHICLE_PATH, v);
if( fexist( vStr ) ) {
INI_ParseFile(vStr, "LoadVehicle_%s", .bExtra = true, .extra = v);
}
}
return true;
}
pawn Код:
stock CreateOwnedVehicle(Model, Colour1, Colour2, Lock, Float:POSX, Float:POSY, Float:POSZ, Float:POSA, vOwner[ MAX_PLAYER_NAME ] )
{
new
ID = GetOpenVehicleID(),
vehStr[64];
format( vehStr, sizeof( vehStr ), "MissionServer/Vehicles/%d.ini", ID);
if( !fexist( vehStr ) )
{
new
ranStr[32];
new
INI:vehFile = INI_Open(vehStr);
INI_SetTag(vehFile, "vehicle");
INI_WriteInt(vehFile, "ModelID", Model);
INI_WriteInt(vehFile, "Locked", Lock);
INI_WriteFloat(vehFile, "XPOS", POSX);
INI_WriteFloat(vehFile, "YPOS", POSY);
INI_WriteFloat(vehFile, "ZPOS", POSZ);
INI_WriteFloat(vehFile, "APOS", POSA);
INI_WriteInt(vehFile, "Colour1", Colour1);
INI_WriteInt(vehFile, "Colour2", Colour2);
INI_WriteInt(vehFile, "Modification1", 0);
INI_WriteInt(vehFile, "Modification2", 0);
INI_WriteInt(vehFile, "Modification3", 0);
INI_WriteInt(vehFile, "Modification4", 0);
INI_WriteInt(vehFile, "Modification5", 0);
INI_WriteInt(vehFile, "Modification6", 0);
INI_WriteInt(vehFile, "Modification7", 0);
INI_WriteInt(vehFile, "Modification8", 0);
INI_WriteInt(vehFile, "Modification9", 0);
INI_WriteInt(vehFile, "Modification10", 0);
INI_WriteString(vehFile, "Owner", vOwner);
format(ranStr, sizeof(ranStr), "SA-%d", minrand(1000, 100000));
INI_WriteString(vehFile, "LicensePlate", ranStr);
INI_Close(vehFile);
vehID[ID] = CreateVehicle( Model, POSX, POSY, POSZ, POSA, Colour1, Colour2, -1 );
if(Lock == 0) { SetVehicleParamsEx( vehID[ID], 1, 1, 0, 0, 0, 0, 0); }
else if(Lock == 1) { SetVehicleParamsEx( vehID[ID], 1, 1, 0, 1, 0, 0, 0); }
SetVehicleNumberPlate( vehID[ID], ranStr );
}
return true;
}