03.08.2012, 14:25
Hello SA-MP community,
I'm having troubles with an engine system. I want it that if the player is in a vehicle and the player presses the 'Y' button, the engine turns on. If the player presses 'Y' again, the engine turns off.
The problem is that if I press 'Y', my screen is overloaded with the 'You are not driving a vehicle!' message AND 'My_Name turns the engine on.' How can I fix that?
I already defined it on top of my script with
I don't either know if that is correct.
Any help will be respected of course.
Kind regards,
sidney123.
I'm having troubles with an engine system. I want it that if the player is in a vehicle and the player presses the 'Y' button, the engine turns on. If the player presses 'Y' again, the engine turns off.
The problem is that if I press 'Y', my screen is overloaded with the 'You are not driving a vehicle!' message AND 'My_Name turns the engine on.' How can I fix that?
pawn Код:
new engine, lights, alarm, doors, bonnet, boot, objective, vehicleid, string[128];
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle.");
if(IsPlayerInAnyVehicle(playerid))
if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(!engine)
{
if(PRESSED(KEY_YES))
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
{SetVehicleParamsEx(vehicleid, 1, lights, alarm, PlayerInfo[playerid][vLocked], bonnet, boot, objective);}
else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
{SetVehicleParamsEx(vehicleid, 1, lights, alarm, PlayerInfo[playerid][vVLocked], bonnet, boot, objective);}
format(string, sizeof(string), "* %s turns the vehicle's engine on.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
else
{
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
{SetVehicleParamsEx(vehicleid, 0, lights, alarm, PlayerInfo[playerid][vLocked], bonnet, boot, objective);}
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
{SetVehicleParamsEx(vehicleid, 0, lights, alarm, PlayerInfo[playerid][vVLocked], bonnet, boot, objective);}
format(string, sizeof(string), "* %s turns the vehicle's engine off.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
pawn Код:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
Any help will be respected of course.
Kind regards,
sidney123.