Quote:
Originally Posted by Fire_Hell
Olб adi1, agora o comando nгo funcina.
Eu gostaria de dar um tempo pressionado para ligar o carro e o farol.
Obrigado.
|
Okay. This is:
on top:
Код:
new TimerToVehicleParams[MAX_PLAYER];
in OnPlayerKeyStateChange:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if((newkeys == 128) && (IsPlayerInAnyVehicle(playerid)))
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
if(!engine)
{
TimerToVehicleParams[playerid] = SetTimerEx("ParamsVehicle", 3000, 0, "ii", playerid,1);
SendClientMessage(playerid,-1,"On vehicle...");
}
else
{
TimerToVehicleParams[playerid] = SetTimerEx("ParamsVehicle", 3000, 0, "ii", playerid,2);
SendClientMessage(playerid,-1,"Off vehicle...");
}
return 1;
}
if ((newkeys & 4) && (IsPlayerInAnyVehicle(playerid)))
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
if(!lights)
{
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, VEHICLE_PARAMS_ON, alarm, doors, bonnet, boot, objective);
}
else
{
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective);
}
return 1;
}
return 1;
}
}
now in OnPlayerStateChange:
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
KillTimer(TimerToVehicleParams[playerid]);
}
return 1;
}
now abajo:
Код:
forward ParamsVehicle(playerid,type);
public ParamsVehicle(playerid,type)
{
if(type == 1)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
}
else if(type == 2)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
}
return 1;
}