mysql_format(mysql, query, sizeof(query), "SELECT * FROM `vehicles`"); mysql_tquery(mysql, query, "OnCarsLoad");
public OnCarsLoad(vehicleid)
{
new tmp[256], string5[256];
cInfo[vehicleid][cModel] = cache_get_field_content_int(0, "carModel");
cInfo[vehicleid][cPosX] = cache_get_field_content_float(0, "carPosX");
cInfo[vehicleid][cPosY] = cache_get_field_content_float(0, "carPosY");
cInfo[vehicleid][cPosZ] = cache_get_field_content_float(0, "carPosZ");
cInfo[vehicleid][cPosF] = cache_get_field_content_float(0, "carPosF");
cInfo[vehicleid][cGroup] = cache_get_field_content_int(0, "carGroup");
cInfo[vehicleid][cVW] = cache_get_field_content_int(0, "carVirtualWorld");
cInfo[vehicleid][cColor1] = cache_get_field_content_int(0, "carColor1");
cInfo[vehicleid][cColor2] = cache_get_field_content_int(0, "carColor2");
cache_get_field_content(0, "carPlate", tmp, mysql), cInfo[vehicleid][cPlate] = strval(tmp);
CreateVehicle(cInfo[vehicleid][cModel], cInfo[vehicleid][cPosX], cInfo[vehicleid][cPosY], cInfo[vehicleid][cPosZ], cInfo[vehicleid][cPosF], cInfo[vehicleid][cColor1], cInfo[vehicleid][cColor2], -1);
SetVehicleVirtualWorld(vehicleid, cInfo[vehicleid][cVW]);
SetVehicleNumberPlate(vehicleid, cInfo[vehicleid][cPlate]);
vCount++;
format(string5, sizeof(string5), " %d cars loaded from database.", vCount);
print(string5);
return 1;
}
|
Perhaps because you are only accessing row 0? You will need a loop.
|
|
And how exactly do I do that?
I've tried with "for(new i" etc.. But it didn't work.. :c |
public OnCarsLoad()
{
for(new i,j=cache_num_rows();i<j;i++)
{
new tmp[256], string5[256];
cInfo[i][cModel] = cache_get_field_content_int(i, "carModel");
}
}
|
Simply because your code is wrong, you are expecting a vehicleid parameter when loading, which shouldn't be there
PHP код:
Oh, and I'm assuming you don't use this OnCarsLoad again, if you are you should assign a global var, and increment it everytime you create a car, and load your array according to that global variable. |