25.06.2013, 18:30
need help here, what makes the vehicles have same id ?
if image doesnt show :
https://www.dropbox.com/s/3pis5jfr50n2hci/sa-mp-000.png
foreach(Player, i) {
for(new c=0; c<MAX_PLAYER_VEHICLE; c++){
if(playerVariables[i][pCarID][c] == vehicleid) {
if(playerVariables[playerid][pAdminLevel] >= 1 && playerVariables[playerid][pAdminDuty] >= 1) {
SetVehicleParamsForPlayer(vehicleid, playerid, 0, 0);
GetPlayerName(i, szPlayerName, MAX_PLAYER_NAME);
format(szMessage, sizeof(szMessage), "This %s (model %d, ID %d) is owned by %s.", VehicleNames[playerVariables[i][pCarModel][c] - 400], playerVariables[i][pCarModel][c], playerVariables[i][pCarID][c], GetPlayerNameEx(i));
SendClientMessage(playerid, COLOR_GREY, szMessage);
}
else if(playerVariables[i][pCarLock][c] == 1) {
RemovePlayerFromVehicle(playerid);
new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz);
SendClientMessageEx(playerid, COLOR_LIGHTRED, "Kendaraan ini dikunci!");
}
}
}
}
The two vehicles don't have the same ID, the problem is probably this variable:
pawn Код:
|
playerVariables[i][pCarID][c]
stock SpawnPlayerVehicle(playerid,slot) {
if(playerVariables[playerid][pCarModel][slot] >= 1) {
if(systemVariables[vehicleCounts][0] + systemVariables[vehicleCounts][1] + systemVariables[vehicleCounts][2] < MAX_VEHICLES) {
DestroyVehicle(playerVariables[playerid][pCarID][slot]); // In case the IDs decide to f*$^# up.
playerVariables[playerid][pCarID][slot] = CreateVehicle(playerVariables[playerid][pCarModel][slot], playerVariables[playerid][pCarPosX][slot], playerVariables[playerid][pCarPosY][slot], playerVariables[playerid][pCarPosZ][slot], playerVariables[playerid][pCarPosZAngle][slot], playerVariables[playerid][pCarColour1][slot], playerVariables[playerid][pCarColour2][slot], -1);
#if defined DEBUG
printf("[debug] SpawnPlayerVehicle(%d, %d, %d)", playerid, slot, playerVariables[playerid][pCarID][slot]);
#endif
for(new i = 0; i < 14; i++) {
if(playerVariables[playerid][pCarMods1][i] >= 1) AddVehicleComponent(playerVariables[playerid][pCarID][0], playerVariables[playerid][pCarMods1][i]);
if(playerVariables[playerid][pCarMods2][i] >= 1) AddVehicleComponent(playerVariables[playerid][pCarID][1], playerVariables[playerid][pCarMods2][i]);
if(playerVariables[playerid][pCarMods3][i] >= 1) AddVehicleComponent(playerVariables[playerid][pCarID][2], playerVariables[playerid][pCarMods3][i]);
if(playerVariables[playerid][pCarMods4][i] >= 1) AddVehicleComponent(playerVariables[playerid][pCarID][3], playerVariables[playerid][pCarMods4][i]);
if(playerVariables[playerid][pCarMods5][i] >= 1) AddVehicleComponent(playerVariables[playerid][pCarID][4], playerVariables[playerid][pCarMods5][i]);
}
if(playerVariables[playerid][pCarPaintjob][slot] >= 0) ChangeVehiclePaintjob(playerVariables[playerid][pCarID][slot], playerVariables[playerid][pCarPaintjob][slot]);
systemVariables[vehicleCounts][1]++;
if(slot == 0) SetVehicleNumberPlate(playerVariables[playerid][pCarID][slot], playerVariables[playerid][pCarLicensePlate1]);
else if(slot == 1) SetVehicleNumberPlate(playerVariables[playerid][pCarID][slot], playerVariables[playerid][pCarLicensePlate2]);
else if(slot == 2) SetVehicleNumberPlate(playerVariables[playerid][pCarID][slot], playerVariables[playerid][pCarLicensePlate3]);
else if(slot == 3) SetVehicleNumberPlate(playerVariables[playerid][pCarID][slot], playerVariables[playerid][pCarLicensePlate4]);
else if(slot == 4) SetVehicleNumberPlate(playerVariables[playerid][pCarID][slot], playerVariables[playerid][pCarLicensePlate5]);
vehEngineStat[playerVariables[playerid][pCarID][slot]] = 0;
VehicleFuel[playerVariables[playerid][pCarID][slot]] = playerVariables[playerid][pCarFuel][slot];
if(playerVariables[playerid][pCarHp][slot] < 250) SetVehicleHealth(playerVariables[playerid][pCarID][slot], 253);
else SetVehicleHealth(playerVariables[playerid][pCarID][slot], playerVariables[playerid][pCarHp][slot]);
UpdateVehicleDamageStatus(playerVariables[playerid][pCarID][slot], playerVariables[playerid][pCarPanels][slot], playerVariables[playerid][pCarDoors][slot], playerVariables[playerid][pCarLights][slot], playerVariables[playerid][pCarTires][slot]);
// De-stream the vehicle
SetVehicleVirtualWorld(playerVariables[playerid][pCarID][slot], GetVehicleVirtualWorld(playerVariables[playerid][pCarID][slot])+1);
SetVehicleVirtualWorld(playerVariables[playerid][pCarID][slot], GetVehicleVirtualWorld(playerVariables[playerid][pCarID][slot])-1);
}
else printf("ERROR: Vehicle limit reached (MODEL %d, PLAYER %d, MAXIMUM %d, TYPE PLAYER) [01x08]", playerVariables[playerid][pCarModel][slot], playerid, MAX_VEHICLES);
}
return 1;
}