Hallo Brotfische,
Ich war gerade dabei mein Kilometersystem fertig zustellen, aber es werden die Kilometer nicht gezählt... Aber wenn ich jetzt ein Paar Meter fahre, wird mir in meinem Textdraw folgendes angzeigt: "Error: UNMATCHT TIL..." . (Leider ist mein Textdraw zu klein um den Error String anzuschauen...).
Codes:
Code
new Float:distancePlayer[MAX_PLAYERS],
Float:PlayerPos_[MAX_PLAYERS][3],
bool:IsInVehicle[MAX_PLAYERS];
forward KilometerZählTimer();
Beil Laden (erstellen) des PlayerCars:
OnPlayerStateChange:
Code
if(newstate == PLAYER_STATE_DRIVER)
{
if(IsPlayerInAnyVehicle(playerid))
{
new string[100],vehid;
vehid = GetPlayerVehicleID(playerid);
format(string,sizeof(string),"~g~%s",VehicleName[GetVehicleModel(vehid)-400]);
PlayerTextDrawSetString(playerid,tachofahrzeugname[playerid],string);
PlayerTextDrawShow(playerid, tachofahrzeugname[playerid]);
format(string,sizeof(string),"Kraftstoff: ~g~%s",SpritArt(GetVehicleModel(vID)));
PlayerTextDrawSetString(playerid,tachokraftstoffart[playerid],string);
PlayerTextDrawShow(playerid,tachokraftstoffart[playerid]);
PlayerTextDrawShow(playerid, tachobox[playerid]);
PlayerTextDrawShow(playerid, tachobox1[playerid]);
PlayerTextDrawShow(playerid, tachobox2[playerid]);
PlayerTextDrawShow(playerid, tachokmh[playerid]);
PlayerTextDrawShow(playerid, tachokmstand[playerid]);
PlayerTextDrawShow(playerid, tacholiter[playerid]);
PlayerTextDrawShow(playerid, tachozustand[playerid]);
for(new i; i < sizeof(cInfo); i++)
{
format(string,sizeof(string),"%d.%d KM",floatround((float(cInfo[i][Car_Meter])/10),floatround_floor),cInfo[i][Car_Meter]%10);
PlayerTextDrawSetString(playerid,tachokmstand[playerid],string);
PlayerTextDrawShow(playerid,tachokmstand[playerid]);
GetPlayerPos(playerid,PlayerPos_[playerid][0],PlayerPos_[playerid][1],PlayerPos_[playerid][2]);
IsInVehicle[playerid]=true;
}
}
}
if(newstate==PLAYER_STATE_ONFOOT)
{
IsInVehicle[playerid]=false;
PlayerTextDrawHide(playerid,tachobox[playerid]);
PlayerTextDrawHide(playerid,tachobox1[playerid]);
//usw.
}
Alles anzeigen
Public (Timer):
Code
public KilometerZählTimer()
{
new string[16];
new Float:tmpdistance;
new vehicleid;
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsInVehicle[i]==false) continue;
vehicleid=GetPlayerVehicleID(i);
tmpdistance=GetVehicleDistanceFromPoint(GetPlayerVehicleID(i),PlayerPos_[i][0],PlayerPos_[i][1],PlayerPos_[i][2]);
if(tmpdistance>100) continue;
distancePlayer[i]+=tmpdistance;
GetVehiclePos(vehicleid,PlayerPos_[i][0],PlayerPos_[i][1],PlayerPos_[i][2]);
if(distancePlayer[i]>100.0)
{
for(new ii; ii < sizeof(cInfo); ii++)
{
cInfo[ii][Car_Meter]++;
distancePlayer[i]-=100.0;
format(string,sizeof(string),"%d.%d KM",floatround((float(cInfo[ii][Car_Meter])/10),floatround_floor),cInfo[ii][Car_Meter]%10);
PlayerTextDrawSetString(i,tachokmstand[i],string);
}
}
return 1;
}
return 1;
}
Alles anzeigen
Ich hoffe ihr könnt mir helfen
MfG