Okay, Test hat funktionier.
if(newkeys & KEY_LOOK_BEHIND)
{
pHoldingTime[playerid] = gettime();
for(new g;g<MAX_GAS;g++) {
new car = GetPlayerVehicleID(playerid);
if(GetPlayerVehicleSeat(playerid) != 0) return SendClientMessage(playerid,error,"Du bist in keinem Fahrzeug (oder kein Fahrer)!");
if(TanktGerade[car]) return SendClientMessage(playerid,error,"Du bist bereits dabei dein Auto aufzutanken!");
else if(Motor[car] == true) return SendClientMessage(playerid,error,"Du musst vor dem Tanken den Motor ausschalten!");
else if(!IsPlayerInRangeOfPoint(playerid,Gasstation[g][Gasradius], Gasstation[g][Gasx],Gasstation[g][Gasy],Gasstation[g][Gasz])) return SendClientMessage(playerid,error,"Du bist an keiner Tankstelle!"); {
if(GetVehicleTankArt(GetVehicleModel(car)) == 0)
{
new ZuTanken = 100-GetVehicleMaxTank(car);
new preis = ZuTanken * BENZINPREIS;
if(GetPlayerMoney(playerid)-preis < 0) return SendClientMessage(playerid,error,"Du hast nicht genug Geld!");
GivePlayerMoney(playerid, -preis);
SendClientMessage(playerid, info, "Tankvorgang wird gestartet...");
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid,0);
TanktGerade[car] = true;
dsl = 1;
tanktimer[playerid] = SetTimerEx("Auftanken",500,true,"i",playerid); }
{
if(GetVehicleTankArt(GetVehicleModel(car)) == 1)
{
new ZuTanken = 100-GetVehicleMaxTank(car);
new preis = ZuTanken * DIESELPREIS;
if(GetPlayerMoney(playerid)-preis < 0) return SendClientMessage(playerid,error,"Du hast nicht genug Geld!");
GivePlayerMoney(playerid, -preis);
SendClientMessage(playerid, info, "Tankvorgang wird gestartet...");
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid,0);
TanktGerade[car] = true;
bnz = 1;
tanktimer[playerid] = SetTimerEx("Auftanken",500,true,"i",playerid); }
}
}
}
if(RELEASED(KEY_LOOK_BEHIND))
{
new string[32];
format(string, sizeof string, "%d Sekunden", gettime()-pHoldingTime[playerid]);
SendClientMessage(playerid, -1, string);
KillTimer(tanktimer[playerid]);
}
}
{
pHoldingTime[playerid] = gettime();
for(new g;g<MAX_GAS;g++) {
new car = GetPlayerVehicleID(playerid);
if(GetPlayerVehicleSeat(playerid) != 0) return SendClientMessage(playerid,error,"Du bist in keinem Fahrzeug (oder kein Fahrer)!");
if(TanktGerade[car]) return SendClientMessage(playerid,error,"Du bist bereits dabei dein Auto aufzutanken!");
else if(Motor[car] == true) return SendClientMessage(playerid,error,"Du musst vor dem Tanken den Motor ausschalten!");
else if(!IsPlayerInRangeOfPoint(playerid,Gasstation[g][Gasradius], Gasstation[g][Gasx],Gasstation[g][Gasy],Gasstation[g][Gasz])) return SendClientMessage(playerid,error,"Du bist an keiner Tankstelle!"); {
if(GetVehicleTankArt(GetVehicleModel(car)) == 0)
{
new ZuTanken = 100-GetVehicleMaxTank(car);
new preis = ZuTanken * BENZINPREIS;
if(GetPlayerMoney(playerid)-preis < 0) return SendClientMessage(playerid,error,"Du hast nicht genug Geld!");
GivePlayerMoney(playerid, -preis);
SendClientMessage(playerid, info, "Tankvorgang wird gestartet...");
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid,0);
TanktGerade[car] = true;
dsl = 1;
tanktimer[playerid] = SetTimerEx("Auftanken",500,true,"i",playerid); }
{
if(GetVehicleTankArt(GetVehicleModel(car)) == 1)
{
new ZuTanken = 100-GetVehicleMaxTank(car);
new preis = ZuTanken * DIESELPREIS;
if(GetPlayerMoney(playerid)-preis < 0) return SendClientMessage(playerid,error,"Du hast nicht genug Geld!");
GivePlayerMoney(playerid, -preis);
SendClientMessage(playerid, info, "Tankvorgang wird gestartet...");
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid,0);
TanktGerade[car] = true;
bnz = 1;
tanktimer[playerid] = SetTimerEx("Auftanken",500,true,"i",playerid); }
}
}
}
if(RELEASED(KEY_LOOK_BEHIND))
{
new string[32];
format(string, sizeof string, "%d Sekunden", gettime()-pHoldingTime[playerid]);
SendClientMessage(playerid, -1, string);
KillTimer(tanktimer[playerid]);
}
}
Nur hört er jetzt nicht mehr auf zu Tanken :D?
also hat es irgendwie noch kein Unterschied..
Mein Auftank Timer:
public Auftanken(playerid)
{
new car = GetPlayerVehicleID(playerid);
new m = GetVehicleModel(car);
Tank[car]+=1;
if(Tank[car] >= GetVehicleMaxTank(m))
{
TanktGerade[car] = false;
Tank[car] = GetVehicleMaxTank(m);
if(bnz == 1) {
SendClientMessage(playerid, erfolg, "Dein Fahrzeug wurde %i€ vollgetankt BENZIN.");
TogglePlayerControllable(playerid,1);
KillTimer(tanktimer[playerid]);
}
else if(dsl == 1) {
SendClientMessage(playerid, erfolg, "Dein Fahrzeug wurde %i€ vollgetankt DIESEL.");
TogglePlayerControllable(playerid,1);
KillTimer(tanktimer[playerid]);
}
}
return 1;
}
{
new car = GetPlayerVehicleID(playerid);
new m = GetVehicleModel(car);
Tank[car]+=1;
if(Tank[car] >= GetVehicleMaxTank(m))
{
TanktGerade[car] = false;
Tank[car] = GetVehicleMaxTank(m);
if(bnz == 1) {
SendClientMessage(playerid, erfolg, "Dein Fahrzeug wurde %i€ vollgetankt BENZIN.");
TogglePlayerControllable(playerid,1);
KillTimer(tanktimer[playerid]);
}
else if(dsl == 1) {
SendClientMessage(playerid, erfolg, "Dein Fahrzeug wurde %i€ vollgetankt DIESEL.");
TogglePlayerControllable(playerid,1);
KillTimer(tanktimer[playerid]);
}
}
return 1;
}
Wenn ich von Auftanken den KillTimer weg nehme hört er irgendwie nicht auf zu Spammen "Dein Fahrzeug wurde vollgetankt"
Achja und irgendwie kann ich nur an der ersten Tankstelle Tanken, bei den anderen sagt er mir ich bin nicht an der Tanke..
new Gasstation[MAX_GAS][GasEnum] = {
{20.0, -2026.5264,156.2846,29.0391, "SF BHF"},
{20.0, 1944.3260,-1772.9254,13.3906, "Test"},
{20.0, -90.5515,-1169.4578,2.4079, "Test"},
{20.0, -1609.7958,-2718.2048,48.5391, "Test"},
{20.0, -2029.4968,156.4366,28.9498, "Test"},
{20.0, -2408.7590,976.0934,45.4175, "Test"},
{20.0, -2243.9629,-2560.6477,31.8841, "Test"},
{20.0, -1676.6323,414.0262,6.9484, "Test"},
{20.0, 2202.2349,2474.3494,10.5258, "Test"},
{20.0, 614.9333,1689.7418,6.6968, "Test"},
{20.0, -1328.8250,2677.2173,49.7665, "Test"},
{20.0, 70.3882,1218.6783,18.5165, "Test"},
{20.0, 2113.7390,920.1079,10.5255, "Test"},
{20.0, -1327.7218,2678.8723,50.0625, "Test"},
{20.0, 2146.6143,2748.4758,10.3852, "Test"},
{20.0, 2639.0022,1108.0353,10.3852, "Test"},
{20.0, 1598.2035,2198.6448,10.3856, "Test"},
{20.0, 1004.0070,-939.3102,42.1797, "Test"}
};
{20.0, 1944.3260,-1772.9254,13.3906, "Test"},
{20.0, -90.5515,-1169.4578,2.4079, "Test"},
{20.0, -1609.7958,-2718.2048,48.5391, "Test"},
{20.0, -2029.4968,156.4366,28.9498, "Test"},
{20.0, -2408.7590,976.0934,45.4175, "Test"},
{20.0, -2243.9629,-2560.6477,31.8841, "Test"},
{20.0, -1676.6323,414.0262,6.9484, "Test"},
{20.0, 2202.2349,2474.3494,10.5258, "Test"},
{20.0, 614.9333,1689.7418,6.6968, "Test"},
{20.0, -1328.8250,2677.2173,49.7665, "Test"},
{20.0, 70.3882,1218.6783,18.5165, "Test"},
{20.0, 2113.7390,920.1079,10.5255, "Test"},
{20.0, -1327.7218,2678.8723,50.0625, "Test"},
{20.0, 2146.6143,2748.4758,10.3852, "Test"},
{20.0, 2639.0022,1108.0353,10.3852, "Test"},
{20.0, 1598.2035,2198.6448,10.3856, "Test"},
{20.0, 1004.0070,-939.3102,42.1797, "Test"}
};
Mit freundlichen Grüßen