Hallo Community,
ich wollte gerade mein Tacho ausprobieren, jedoch wird er mir im Spiel nicht angezeigt. Ich weiss auch nicht wieso, und kann es mir nicht erklären. hier erstmal die Textdraws(Schicke nur die variablen):
new Text:T_StatusBox;
new Text:T_Box;
new Text:T_CarName[MAX_PLAYERS];
new Text:T_KmStand;
new Text:T_TankStand;
new Text:T_ZustandStand;
new Text:T_KmhStand;
new Text:T_Km[MAX_PLAYERS];
new Text:T_Tank[MAX_PLAYERS];
new Text:T_Zustand[MAX_PLAYERS];
new Text:T_Kmh[MAX_PLAYERS];
new Text:T_SMotor[MAX_PLAYERS];
new Text:T_SDoor[MAX_PLAYERS];
new Text:T_SLight[MAX_PLAYERS];
Hier ist das public TachoTimer, welches ich auch shcon debugt habe und es kam nichts ungewöhnliches vor:
public TachoTimer(playerid)
{
new _vehicleid = GetPlayerVehicleID(playerid), _speed = GetPlayerSpeed(playerid);
new _string[69], Float:_vhp, engine, lights, alarm, doors, bonnet, boot, objective;
new Float:_x, Float:_y, Float:_z, Float:_d, Float:_v;
GetPlayerPos(playerid, _x, _y, _z);
if(CarMotor[_vehicleid] == 1) _v = _d / 100 * CarVerbrauch[GetVehicleModel(_vehicleid)-400][Verbrauch], CarTank[_vehicleid] -= _v;
if(OldPos[playerid][0] != 0.0 && OldPos[playerid][1] != 0.0 && OldPos[playerid][2] != 0.0){
_d = GetDistanceFromPointToPoint(OldPos[playerid][0],OldPos[playerid][1],OldPos[playerid][2],_x,_y,_z) / 1000.0;
CarMeter[_vehicleid] += _d;
}
OldPos[playerid][0] = _x, OldPos[playerid][1] = _y, OldPos[playerid][2] = _z;
if(CarMotor[_vehicleid] == 1) {TextDrawSetString(T_SMotor[playerid], "~g~Motor");} else {TextDrawSetString(T_SMotor[playerid], "~r~Motor");}
if(CarLight[_vehicleid] == 1) {TextDrawSetString(T_SLight[playerid], "~g~Licht");} else {TextDrawSetString(T_SLight[playerid], "~r~Licht");}
if(CarLocked[_vehicleid] == 0) {TextDrawSetString(T_SDoor[playerid], "~g~Tueren");} else {TextDrawSetString(T_SDoor[playerid], "~r~Tueren");}
// ======================================================================
format(_string, sizeof _string, "%04.1f", CarMeter[_vehicleid]);
TextDrawSetString(T_Km[playerid], _string);
format(_string, sizeof _string, "%0.1f/%0.1f", CarTank[_vehicleid], GetGasMax(GetVehicleModel(_vehicleid)));
TextDrawSetString(T_Tank[playerid], _string);
format(_string, sizeof _string, "%s", VehicleName[GetVehicleModel(_vehicleid)-400]);
TextDrawSetString(T_CarName[playerid], _string);print("18");
format(_string, sizeof _string, "%d", _speed);print("19");
TextDrawSetString(T_Kmh[playerid], _string);print("20");
GetVehicleHealth(_vehicleid,_vhp);print("21");
_vhp = floatdiv(_vhp, 10.0);print("22");
format(_string, sizeof _string, "%.0f%%", _vhp);
TextDrawSetString(T_Zustand[playerid], _string);
// ======================================================================
TextDrawShowForPlayer(_vehicleid, T_StatusBox);
TextDrawShowForPlayer(_vehicleid, T_Box);
TextDrawShowForPlayer(_vehicleid, T_KmStand);
TextDrawShowForPlayer(_vehicleid, T_TankStand);
TextDrawShowForPlayer(_vehicleid, T_ZustandStand);
TextDrawShowForPlayer(_vehicleid, T_KmhStand);
TextDrawShowForPlayer(_vehicleid, T_CarName[playerid]);
TextDrawShowForPlayer(_vehicleid, T_Kmh[playerid]);
TextDrawShowForPlayer(_vehicleid, T_Zustand[playerid]);
TextDrawShowForPlayer(_vehicleid, T_Km[playerid]);
TextDrawShowForPlayer(_vehicleid, T_Tank[playerid]);
TextDrawShowForPlayer(_vehicleid, T_SMotor[playerid]);
TextDrawShowForPlayer(_vehicleid, T_SLight[playerid]);
TextDrawShowForPlayer(_vehicleid, T_SDoor[playerid]);
if(CarTank[_vehicleid] == 0 && CarNoFuel[_vehicleid] == 0){
GetVehicleParamsEx(_vehicleid ,engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(_vehicleid ,0 , lights, alarm, doors, bonnet, boot, objective);
SendClientMessage(playerid, COLOR_GREY, " Dein Auto hat kein Sprit mehr.");
CarMotor[_vehicleid] = 0;
CarNoFuel[_vehicleid] = 1;
}
return 1;
}
Bei OnPlayerStateChange wird das ganze gestartet, hier der Teil:
new newcar = GetVehicleModel(GetPlayerVehicleID(playerid));
if(newstate == PLAYER_STATE_DRIVER)
{
PlayerInfo[playerid][pTachotimer] = SetTimerEx("TachoTimer", 1000, true, "i", playerid);
Und so wird der Timer gekillt:
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
KillTimer(PlayerInfo[playerid][pTachotimer]);
SetPlayerDrunkLevel(playerid, OldDrunkLevel[playerid]);
TextDrawHideForPlayer(newcar, T_StatusBox);
TextDrawHideForPlayer(newcar, T_Box);
TextDrawHideForPlayer(newcar, T_KmStand);
TextDrawHideForPlayer(newcar, T_TankStand);
TextDrawHideForPlayer(newcar, T_ZustandStand);
TextDrawHideForPlayer(newcar, T_KmhStand);
TextDrawHideForPlayer(newcar, T_CarName[playerid]);
TextDrawHideForPlayer(newcar, T_Kmh[playerid]);
TextDrawHideForPlayer(newcar, T_Zustand[playerid]);
TextDrawHideForPlayer(newcar, T_Km[playerid]);
TextDrawHideForPlayer(newcar, T_Tank[playerid]);
TextDrawHideForPlayer(newcar, T_SMotor[playerid]);
TextDrawHideForPlayer(newcar, T_SLight[playerid]);
TextDrawHideForPlayer(newcar, T_SDoor[playerid]);
OldPos[playerid][0] = 0.0, OldPos[playerid][1] = 0.0, OldPos[playerid][2] = 0.0;
}
Ich bin am verzweifeln und frage mich, woran es liegt.
Ich hoffe ihr könnt mir helfen, denn vorher hatte er noch funktioniert, jedoch weis ich nicht, was ich geändert hatte.
MfG
Adrian Rodriguez