Moin
ich bin langsam am verzweifeln...
Ich möchte gerne abfragen ob der Tank leer ist vom Auto... Der sagt mir die ganze zeit, dass der Tank leer ist obwohl laut DB 5.00 Liter drinne stehen. Der Tank wird auch in die Variable (siehe OnPlayerCarsLoad) geladen...
enum carData{
db_id,
id_x,
owner,
model,
Float:c_x,
Float:c_y,
Float:c_z,
Float:c_r,
c_color1,
c_color2,
Float:tank
}
public OnPlayerCarsLoad(playerid){
new rows;
cache_get_row_count(rows);
if(rows == 0)return 1;
for(new i = 0; i < rows; i++){
new id = getFreeCarID();
cache_get_value_name_int(i, "id", cInfo[id][db_id]);
cache_get_value_name_int(i, "owner", cInfo[id][owner]);
cache_get_value_name_int(i, "model", cInfo[id][model]);
cache_get_value_name_float(i, "posx", cInfo[id][c_x]);
cache_get_value_name_float(i, "posy", cInfo[id][c_y]);
cache_get_value_name_float(i, "posz", cInfo[id][c_z]);
cache_get_value_name_float(i, "posr", cInfo[id][c_r]);
cache_get_value_name_int(i, "color1", cInfo[id][c_color1]);
cache_get_value_name_int(i, "color2", cInfo[id][c_color2]);
cache_get_value_name_float(i, "tank", cInfo[id][tank]);
cInfo[id][id_x] = CreateVehicle(cInfo[id][model], cInfo[id][c_x], cInfo[id][c_y], cInfo[id][c_z], cInfo[id][c_r], cInfo[id][c_color1], cInfo[id][c_color2], -1);
}
return 1;
}
Alles anzeigen
Nun versuche ich mein Motor Befehl wie folgt zu gestalten:
ocmd:motor(playerid, params[]){
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)return SCM(playerid,COLOR_RED, "[FEHLER] {FFFFFF}Du bist kein Fahrer eines Fahrzeugs");
new vID = GetPlayerVehicleID(playerid), tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective, cID = getCarID(playerid);
GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
if(cInfo[cID][tank] == 0) return SCM(playerid, COLOR_RED, "Dieses Fahrzeug hat kein Kraftstoff mehr");
if(tmp_engine == 1){
tmp_engine = 0;
TextDrawHideForPlayer(playerid,Tacho_TD[4]);
TextDrawColor(Tacho_TD[4], COLOR_RED);
TextDrawShowForPlayer(playerid, Tacho_TD[4]);
}else{
tmp_engine = 1;
TextDrawHideForPlayer(playerid,Tacho_TD[4]);
TextDrawColor(Tacho_TD[4], COLOR_GREEN);
TextDrawShowForPlayer(playerid, Tacho_TD[4]);
}
SetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
return 1;
}
Alles anzeigen
mein Stock GetVehicleID (für cID):
getCarID(playerid){
new vID = GetPlayerVehicleID(playerid);
for(new i = 0; i < sizeof(cInfo); i++){
if(cInfo[i][id_x] != vID) continue;
return cInfo[i][id_x];
}
return 0;
}
//EDIT habe eine Lösung gefunden, aber muss ich wirklich jedes mal, wenn ich auf die Info von dem Fahrzeug in dem man sitzt, zugreifen will, muss ich dann echt jedes mal die Schleife machen?:
ocmd:motor(playerid, params[]){
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)return SCM(playerid,COLOR_RED, "[FEHLER] {FFFFFF}Du bist kein Fahrer eines Fahrzeugs");
new vID = GetPlayerVehicleID(playerid), tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective, cID = getCarID(playerid);
GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
for(new i = 0; i < sizeof(cInfo); i++){
if(cInfo[i][id_x] != vID) continue;
if(cInfo[i][tank] == 0) return SCM(playerid, COLOR_RED, "Dieses Fahrzeug hat kein Kraftstoff mehr");
if(tmp_engine == 1){
tmp_engine = 0;
TextDrawHideForPlayer(playerid,Tacho_TD[4]);
TextDrawColor(Tacho_TD[4], COLOR_RED);
TextDrawShowForPlayer(playerid, Tacho_TD[4]);
}else{
tmp_engine = 1;
TextDrawHideForPlayer(playerid,Tacho_TD[4]);
TextDrawColor(Tacho_TD[4], COLOR_GREEN);
TextDrawShowForPlayer(playerid, Tacho_TD[4]);
}
}
SetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
return 1;
}
Alles anzeigen