Hallooo Zusammen
ich brauche eine Überprüfung, ob der Fahrer der Besitzer des Fahrzeugs ist, somit soll dann NUr dann wenn er halt der Besitzer ist soll der Kilometerstand sich erhöhen
Zurzeit habe ich das Problem dass die KMH und die Kilometeranzeige rumspinnt, wenn 2 Spieler gleichzeitg fahren
Hier der KMH Teil
public Tachosek()
{
new string[128];
for(new i=0; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i))continue;
if(!IsPlayerInAnyVehicle(i))continue;
if(!IsPlayerInAnyVehicle(i))continue;
format(string,sizeof(string),"d",getPlayerSpeed(i));
TextDrawSetString(Textdraw23,string);
//format(string,sizeof(string),"%ikm/h", getPlayerSpeed(i));
//GameTextForPlayer(i, string, 1000, 3);
}
return 1;
}
{
new string[128];
for(new i=0; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i))continue;
if(!IsPlayerInAnyVehicle(i))continue;
if(!IsPlayerInAnyVehicle(i))continue;
format(string,sizeof(string),"d",getPlayerSpeed(i));
TextDrawSetString(Textdraw23,string);
//format(string,sizeof(string),"%ikm/h", getPlayerSpeed(i));
//GameTextForPlayer(i, string, 1000, 3);
}
return 1;
}
und hier der Kilometerteil
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)//mom
{
return 1;
}
public zehn(vehicleid)
{
{
return 1;
}
public zehn(vehicleid)
{
for(new i;i<MAX_PLAYERS;i++) {
if(!IsPlayerConnected(i))continue;
if(!IsPlayerInAnyVehicle(i))continue;
new Float:Distanz,km2[32];
GetVehiclePos(vehicleid,pNewKM[0][i],pNewKM[1][i],pNewKM[2][i]);
Distanz=GetVehicleDistanceFromPoint(vehicleid,pOldKM[0][i],pOldKM[1][i],pOldKM[2][i]);
if(Distanz > 150){ Distanz=0; }
cInfo[i][kmstand] += Distanz/1000;
pOldKM[0][i] = pNewKM[0][i];
pOldKM[1][i] = pNewKM[1][i];//Damit die schleife da bleibt kk ^^ kk = ok
pOldKM[2][i] = pNewKM[2][i];
format(km2,sizeof km2,"%0.2f",cInfo[i][kmstand]);
//SendClientMessage(i,-1,"Kilometerstand aktualisiert");
TextDrawSetString(Textdraw25, km2);//Das cInfo [kmstand]sollte besser eine Float sein, da man damit finde ich präziser arbeiten kann ok könntest du evtl Speichern und auslesen noch überprüfen glaube habe da auch gefailt klar
}
return 1;
}
if(!IsPlayerConnected(i))continue;
if(!IsPlayerInAnyVehicle(i))continue;
new Float:Distanz,km2[32];
GetVehiclePos(vehicleid,pNewKM[0][i],pNewKM[1][i],pNewKM[2][i]);
Distanz=GetVehicleDistanceFromPoint(vehicleid,pOldKM[0][i],pOldKM[1][i],pOldKM[2][i]);
if(Distanz > 150){ Distanz=0; }
cInfo[i][kmstand] += Distanz/1000;
pOldKM[0][i] = pNewKM[0][i];
pOldKM[1][i] = pNewKM[1][i];//Damit die schleife da bleibt kk ^^ kk = ok
pOldKM[2][i] = pNewKM[2][i];
format(km2,sizeof km2,"%0.2f",cInfo[i][kmstand]);
//SendClientMessage(i,-1,"Kilometerstand aktualisiert");
TextDrawSetString(Textdraw25, km2);//Das cInfo [kmstand]sollte besser eine Float sein, da man damit finde ich präziser arbeiten kann ok könntest du evtl Speichern und auslesen noch überprüfen glaube habe da auch gefailt klar
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
TextDrawHideForPlayer(playerid,Textdraw20);
TextDrawHideForPlayer(playerid,Textdraw21);
TextDrawHideForPlayer(playerid,Textdraw22);
TextDrawHideForPlayer(playerid,Textdraw23);
TextDrawHideForPlayer(playerid,Textdraw24);
TextDrawHideForPlayer(playerid,Textdraw25);
TextDrawHideForPlayer(playerid,Textdraw26);
saveCarToDB(playerid,vehicleid);
return 1;
}
{
TextDrawHideForPlayer(playerid,Textdraw20);
TextDrawHideForPlayer(playerid,Textdraw21);
TextDrawHideForPlayer(playerid,Textdraw22);
TextDrawHideForPlayer(playerid,Textdraw23);
TextDrawHideForPlayer(playerid,Textdraw24);
TextDrawHideForPlayer(playerid,Textdraw25);
TextDrawHideForPlayer(playerid,Textdraw26);
saveCarToDB(playerid,vehicleid);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
{
{
new vehicleid=GetPlayerVehicleID(playerid);
TextDrawShowForPlayer(playerid,Textdraw20);
TextDrawShowForPlayer(playerid,Textdraw21);
TextDrawShowForPlayer(playerid,Textdraw22);
TextDrawShowForPlayer(playerid,Textdraw23);
TextDrawShowForPlayer(playerid,Textdraw24);
TextDrawShowForPlayer(playerid,Textdraw25);
TextDrawShowForPlayer(playerid,Textdraw26);
zehn(vehicleid);
GetPlayerVehicleID(playerid);
GetVehiclePos(GetPlayerVehicleID(playerid),pOldKM[0][playerid],pOldKM[1][playerid],pOldKM[2][playerid]);
SetTimerEx("zehn",1000,true,"d",GetPlayerVehicleID(playerid));
}
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
{
{
new vehicleid=GetPlayerVehicleID(playerid);
TextDrawShowForPlayer(playerid,Textdraw20);
TextDrawShowForPlayer(playerid,Textdraw21);
TextDrawShowForPlayer(playerid,Textdraw22);
TextDrawShowForPlayer(playerid,Textdraw23);
TextDrawShowForPlayer(playerid,Textdraw24);
TextDrawShowForPlayer(playerid,Textdraw25);
TextDrawShowForPlayer(playerid,Textdraw26);
zehn(vehicleid);
GetPlayerVehicleID(playerid);
GetVehiclePos(GetPlayerVehicleID(playerid),pOldKM[0][playerid],pOldKM[1][playerid],pOldKM[2][playerid]);
SetTimerEx("zehn",1000,true,"d",GetPlayerVehicleID(playerid));
}
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT) // Player went out of a vehicle as a driver
{
TextDrawHideForPlayer(playerid,Textdraw20);
TextDrawHideForPlayer(playerid,Textdraw21);
TextDrawHideForPlayer(playerid,Textdraw22);
TextDrawHideForPlayer(playerid,Textdraw23);
TextDrawHideForPlayer(playerid,Textdraw24);
TextDrawHideForPlayer(playerid,Textdraw25);
TextDrawHideForPlayer(playerid,Textdraw26);
}
{
TextDrawHideForPlayer(playerid,Textdraw20);
TextDrawHideForPlayer(playerid,Textdraw21);
TextDrawHideForPlayer(playerid,Textdraw22);
TextDrawHideForPlayer(playerid,Textdraw23);
TextDrawHideForPlayer(playerid,Textdraw24);
TextDrawHideForPlayer(playerid,Textdraw25);
TextDrawHideForPlayer(playerid,Textdraw26);
}
Bin selbstverständlich auch über Teamviewer erreichbar, danke für jede Hilfe