It is pulled from a database with this command.
pawn Код:
public loadPlayerVehicles(playerid){
new rows, fields, tmp[50];
new tmpvInternalId,tmpvModelId, tmpvColor1, tmpvColor2;
new Float:tmpvSpawnX,Float:tmpvSpawnY,Float:tmpvSpawnZ,Float:tmpvSpawnA, tmpvOwnerId,Float:tmpvHealth;
new tmpvFuelLevel, tmpvPanelDamage, tmpvDoorsDamage, tmpvLightsDamage, tmpvTyreDamage,tmpvMod1,tmpvMod2,tmpvMod3,tmpvMod4,tmpvMod5;
new tmpvMod6,tmpvMod7,tmpvMod8,tmpvMod9,tmpvMod10,tmpvMod11,tmpvMod12,tmpvMod13,tmpvMod14,tmpvMod15,tmpvMod16,tmpvMod17, tmpvPaintJob,i, vId, carCount, fCarCount[20];
cache_get_data(rows, fields);
while(i < rows) {
// Collect data from database
cache_get_row(i, 0, tmp);
tmpvInternalId = strval(tmp);
cache_get_row(i, 1, tmp);
tmpvModelId = strval(tmp);
cache_get_row(i, 2, tmp);
tmpvColor1 = strval(tmp);
cache_get_row(i, 3, tmp);
tmpvColor2 = strval(tmp);
cache_get_row(i, 4, tmp);
tmpvSpawnX = floatstr(tmp);
cache_get_row(i, 5, tmp);
tmpvSpawnY = floatstr(tmp);
cache_get_row(i, 6, tmp);
tmpvSpawnZ = floatstr(tmp);
cache_get_row(i, 7, tmp);
tmpvSpawnA = floatstr(tmp);
cache_get_row(i, 8, tmp);
tmpvOwnerId = strval(tmp);
cache_get_row(i, 9, tmp);
tmpvHealth = floatstr(tmp);
cache_get_row(i, 10, tmp);
tmpvFuelLevel = strval(tmp);
cache_get_row(i, 11, tmp);
tmpvPanelDamage = strval(tmp);
cache_get_row(i, 12, tmp);
tmpvDoorsDamage = strval(tmp);
cache_get_row(i, 13, tmp);
tmpvLightsDamage = strval(tmp);
cache_get_row(i, 14, tmp);
tmpvTyreDamage = strval(tmp);
cache_get_row(i, 15, tmp);
tmpvMod1 = strval(tmp);
cache_get_row(i, 16, tmp);
tmpvMod2 = strval(tmp);
cache_get_row(i, 17, tmp);
tmpvMod3 = strval(tmp);
cache_get_row(i, 18, tmp);
tmpvMod4 = strval(tmp);
cache_get_row(i, 19, tmp);
tmpvMod5 = strval(tmp);
cache_get_row(i, 20, tmp);
tmpvMod6 = strval(tmp);
cache_get_row(i, 21, tmp);
tmpvMod7 = strval(tmp);
cache_get_row(i, 22, tmp);
tmpvMod8 = strval(tmp);
cache_get_row(i, 23, tmp);
tmpvMod9 = strval(tmp);
cache_get_row(i, 24, tmp);
tmpvMod10 = strval(tmp);
cache_get_row(i, 25, tmp);
tmpvMod11 = strval(tmp);
cache_get_row(i, 26, tmp);
tmpvMod12 = strval(tmp);
cache_get_row(i, 27, tmp);
tmpvMod13 = strval(tmp);
cache_get_row(i, 28, tmp);
tmpvMod14 = strval(tmp);
cache_get_row(i, 29, tmp);
tmpvMod15 = strval(tmp);
cache_get_row(i, 30, tmp);
tmpvMod16 = strval(tmp);
cache_get_row(i, 31, tmp);
tmpvMod17 = strval(tmp);
cache_get_row(i, 32, tmp);
tmpvPaintJob = strval(tmp);
//spawn the vehicle
vId = CreateVehicle(tmpvModelId,tmpvSpawnX,tmpvSpawnY,tmpvSpawnZ,tmpvSpawnA,tmpvColor1,tmpvColor2,3600);
//update vehicle damage
UpdateVehicleDamageStatus(vId,tmpvPanelDamage,tmpvDoorsDamage,tmpvLightsDamage,tmpvTyreDamage);
//add mods to be added later
//set everything into the enum
playerVehicles[vId][vInternalId] = tmpvInternalId;
playerVehicles[vId][vModelId] = tmpvModelId;
playerVehicles[vId][vColor1] = tmpvColor1;
playerVehicles[vId][vColor2] = tmpvColor2;
playerVehicles[vId][vSpawnX] = tmpvSpawnX;
playerVehicles[vId][vSpawnY] = tmpvSpawnY;
playerVehicles[vId][vSpawnZ] = tmpvSpawnZ;
playerVehicles[vId][vSpawnA] = tmpvSpawnA;
playerVehicles[vId][vOwnerId] = tmpvOwnerId;
playerVehicles[vId][vHealth] = tmpvHealth;
playerVehicles[vId][vFuelLevel] = tmpvFuelLevel;
playerVehicles[vId][vPanelDamage] = tmpvPanelDamage;
playerVehicles[vId][vDoorsDamage] = tmpvDoorsDamage;
playerVehicles[vId][vLightsDamage] = tmpvLightsDamage;
playerVehicles[vId][vTyreDamage] = tmpvTyreDamage;
playerVehicles[vId][vMod1] = tmpvMod1;
playerVehicles[vId][vMod2] = tmpvMod2;
playerVehicles[vId][vMod3] = tmpvMod3;
playerVehicles[vId][vMod4] = tmpvMod4;
playerVehicles[vId][vMod5] = tmpvMod5;
playerVehicles[vId][vMod6] = tmpvMod6;
playerVehicles[vId][vMod7] = tmpvMod7;
playerVehicles[vId][vMod8] = tmpvMod8;
playerVehicles[vId][vMod9] = tmpvMod9;
playerVehicles[vId][vMod10] = tmpvMod10;
playerVehicles[vId][vMod11] = tmpvMod11;
playerVehicles[vId][vMod12] = tmpvMod12;
playerVehicles[vId][vMod13] = tmpvMod13;
playerVehicles[vId][vMod14] = tmpvMod14;
playerVehicles[vId][vMod15] = tmpvMod15;
playerVehicles[vId][vMod16] = tmpvMod16;
playerVehicles[vId][vMod17] = tmpvMod17;
playerVehicles[vId][vPaintJob] = tmpvPaintJob;
i++;
}
carCount = i++;
format(fCarCount,sizeof(fCarCount),"%i Vehicles Spawned",carCount);
SendClientMessage(playerid, COLOR_BRIGHTRED, fCarCount);
return 1;
}
This is the callback function from the dbquery, which is called in OnPlayerSpawn();