new Iterator: BirlikArac[100]<10>; public OnGameModeInit() { Iter_Init(BirlikArac); mysql_tquery(g_SQL, "SELECT * FROM `birlikarac`", "BirlikAracYukle", ""); return 1; } fonksiyon-> BirlikAracYukle() { new rows; cache_get_row_count(rows); if(rows) { new sql, id, model, Float: vPos[4], vRenk[2], vPlaka[15], vfiyat, Float: vBenzin, Float: vKilometre, Float: vCan, vVergi, vVergi2, vSure, vTarih, vMod[17], vPaint, vehicleid, loader ; for(new i = 0; i < rows; ++i) { cache_get_value_name_int(i, "id", sql); cache_get_value_name_int(i, "birlikid", id); cache_get_value_name_int(i, "model", model); cache_get_value_name_float(i, "xx", vPos[0]); cache_get_value_name_float(i, "yy", vPos[1]); cache_get_value_name_float(i, "zz", vPos[2]); cache_get_value_name_float(i, "aa", vPos[3]); cache_get_value_name_int(i, "renk1", vRenk[0]); cache_get_value_name_int(i, "renk2", vRenk[1]); cache_get_value_name_int(i, "paintjob", vPaint); cache_get_value_name(i, "plaka", vPlaka, sizeof(vPlaka)); cache_get_value_name_int(i, "fiyat", vfiyat); cache_get_value_name_float(i, "benzin", vBenzin); cache_get_value_name_float(i, "kilometre", vKilometre); cache_get_value_name_float(i, "can", vCan); cache_get_value_name_int(i, "vergi", vVergi); cache_get_value_name_int(i, "vergi2", vVergi2); cache_get_value_name_int(i, "vergisure", vSure); cache_get_value_name_int(i, "tarih", vTarih); cache_get_value_name_int(i, "amod1", vMod[0]); cache_get_value_name_int(i, "amod2", vMod[1]); cache_get_value_name_int(i, "amod3", vMod[2]); cache_get_value_name_int(i, "amod4", vMod[3]); cache_get_value_name_int(i, "amod5", vMod[4]); cache_get_value_name_int(i, "amod6", vMod[5]); cache_get_value_name_int(i, "amod7", vMod[6]); cache_get_value_name_int(i, "amod8", vMod[7]); cache_get_value_name_int(i, "amod9", vMod[8]); cache_get_value_name_int(i, "amod10", vMod[9]); cache_get_value_name_int(i, "amod11", vMod[10]); cache_get_value_name_int(i, "amod12", vMod[11]); cache_get_value_name_int(i, "amod13", vMod[12]); cache_get_value_name_int(i, "amod14", vMod[13]); cache_get_value_name_int(i, "amod15", vMod[14]); cache_get_value_name_int(i, "amod16", vMod[15]); cache_get_value_name_int(i, "amod17", vMod[16]); vehicleid = CreateVehicle(model, vPos[0], vPos[1], vPos[2], vPos[3], vRenk[0], vRenk[1], -1); SetVehicleNumberPlate(vehicleid, vPlaka); BirlikAraclari[vehicleid][birlik_arac] = true; BirlikAraclari[vehicleid][sql_id] = sql; BirlikAraclari[vehicleid][birlik_id] = id; BirlikAraclari[vehicleid][birlik_pozisyon][0] = vPos[0]; BirlikAraclari[vehicleid][birlik_pozisyon][1] = vPos[1]; BirlikAraclari[vehicleid][birlik_pozisyon][2] = vPos[2]; BirlikAraclari[vehicleid][birlik_pozisyon][3] = vPos[3]; BirlikAraclari[vehicleid][birlik_renkler][0] = vRenk[0]; BirlikAraclari[vehicleid][birlik_renkler][1] = vRenk[1]; BirlikAraclari[vehicleid][birlik_Paintjob] = vPaint; format(BirlikAraclari[vehicleid][birlik_plaka], 15, vPlaka); BirlikAraclari[vehicleid][birlik_fiyat] = vfiyat; BirlikAraclari[vehicleid][birlik_benzin] = vBenzin; BirlikAraclari[vehicleid][birlik_kilometre] = vKilometre; BirlikAraclari[vehicleid][birlik_can] = vCan; BirlikAraclari[vehicleid][birlik_vergi] = vVergi; BirlikAraclari[vehicleid][birlik_vergi2] = vVergi2; BirlikAraclari[vehicleid][birlik_vergisure] = vSure; BirlikAraclari[vehicleid][birlik_tarih] = vTarih; ChangeVehicleColor(vehicleid, vRenk[0], vRenk[1]); ChangeVehiclePaintjob(vehicleid, vPaint - 1); for(new it = 0; it < 17; it++) { BirlikAraclari[vehicleid][birlik_mod][it] = vMod[it]; if(vMod[it] != 0) { AddVehicleComponent(vehicleid, vMod[it]); } } loader++; Iter_Add(BirlikArac[id], vehicleid); // This place doesn't work. foreach(new ix : BirlikArac[id]){ printf("vID: %d", ix); } } } return 1; }
#define max_vehs 100
enum vehEnum{
sid,
Slot,
Model,
Color[2],
Float:Pos[4],
Mod[13]
};
new Veh[max_vehs][vehEnum], //expended Vehicle, vehicleEnum
Iterator:fVehs<max_vehs>;//expended foreachVehicles
public OnGameModeInit()
{
mysql_tquery(g_SQL, "SELECT * FROM vehicles", "loadVehicles", "");
return 1;
}
//split your systems into functions, then you can use those function everywhere in your gamemode
CreateVehicleEx(i){
Veh[i][Slot]=CreateVehicle(Veh[i][Model],Veh[i][Pos][0],Veh[i][Pos][1],Veh[i][Pos][2],Veh[i][Pos][3],Veh[i][Color][0],Veh[i][Color][1]);
for(new i2; i2 < 13; i2++) {
if(Veh[i][Mod][i2] != 0) AddVehicleComponent(Veh[i][Slot],Veh[i][Mod][i2]);
}
}
//threaded vehicle info loading
forward loadVehicles();
public loadVehicles(){
new rows=cache_num_rows();
if(!rows)return print("no vehicles to load!");
for(new i; i < rows; i++){
cache_get_value_name_int(i, "id", Veh[i][sid]);
cache_get_value_name_int(i, "color1", Veh[i][Color][0]);
cache_get_value_name_int(i, "color2", Veh[i][Color][1]);
cache_get_value_name_int(i, "model", Veh[i][Model]);
cache_get_value_name_float(i, "xx", Veh[i][Pos][0]);
cache_get_value_name_float(i, "yy", Veh[i][Pos][1]);
cache_get_value_name_float(i, "zz", Veh[i][Pos][2]);
cache_get_value_name_float(i, "aa", Veh[i][Pos][3]);
cache_get_value_name_int(i, "mod0", Veh[i][Mod][0]);
cache_get_value_name_int(i, "mod1", Veh[i][Mod][1]);
cache_get_value_name_int(i, "mod2", Veh[i][Mod][2]);
cache_get_value_name_int(i, "mod3", Veh[i][Mod][3]);
cache_get_value_name_int(i, "mod4", Veh[i][Mod][4]);
cache_get_value_name_int(i, "mod5", Veh[i][Mod][5]);
cache_get_value_name_int(i, "mod6", Veh[i][Mod][6]);
cache_get_value_name_int(i, "mod7", Veh[i][Mod][7]);
cache_get_value_name_int(i, "mod8", Veh[i][Mod][8]);
cache_get_value_name_int(i, "mod9", Veh[i][Mod][9]);
cache_get_value_name_int(i, "mod10", Veh[i][Mod][10]);
cache_get_value_name_int(i, "mod11", Veh[i][Mod][11]);
cache_get_value_name_int(i, "mod12", Veh[i][Mod][12]);
CreateVehicleEx(i);
Iter_Add(fVehs,i);
}
printf("loaded %d vehicles.",rows);
return 1;
}
****** what beef you have with me?
maybe start doing something meaningful with your special coding skills, not sit whole day in half dead samp community and teach coding. like i write simple examples here not fully working code for them |