Hi ich bins wieder
Ich habe mir grad ein kleines Enginesystem erbastelt, in welchem man LEERTASTE+N gedrückt halten muss, um den Motor zu starten/stoppen.
Ich kann den Motor stoppen. Starten tut er nicht, warum?
Code:
public motortimerON(playerid,vehicleid) {
if(gettime()-pMotorTime[0][playerid]==2) {
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
Motor[vehicleid] = true;
KillTimer(motortimer[0][playerid]);
pMotorTime[0][playerid] = 0;
} else {
pMotorTime[0][playerid] = 0;
}
return 1;
}
public motortimerOFF(playerid,vehicleid) {
if(gettime()-pMotorTime[1][playerid]==1) {
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
Motor[vehicleid] = false;
KillTimer(motortimer[1][playerid]);
pMotorTime[1][playerid] = 0;
} else {
pMotorTime[1][playerid] = 0;
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleSeat(playerid) == 0) {
if(HOLDING(KEY_HANDBRAKE) && HOLDING(KEY_NO)) {
if(Motor[GetPlayerVehicleID(playerid)] == false) {
pMotorTime[0][playerid] = gettime();
motortimer[0][playerid]=SetTimerEx("motortimerON",1000,1,"dv",playerid,GetPlayerVehicleID(playerid));
} else {
pMotorTime[1][playerid] = gettime();
motortimer[1][playerid]=SetTimerEx("motortimerOFF",1000,1,"dv",playerid,GetPlayerVehicleID(playerid));
}
}
}
Der Wagen wird mit gestartetem Motor gespawnt.
lg