24.03.2012, 03:57
I have created a engine system in my script.
Look at these codes I have:
On entering a vehicle a textdraw saying 'Press CTRL to start engine' would appear on the screen. I used TextDrawShowForPlayer(playerid, Engine) under OnPlayerEnterVehicle. The textdraw would appear when enter a vehicle and when pressed CTRL the textdraw would disappear off the screen.
My problem with this is. The textdraw shows up whether the engine is off or on. I want the textdraw to show up if the engine is off. Please help me finish code this.
Look at these codes I have:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(newkeys & KEY_ACTION)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == 1)
{
SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
strreplace(pname, '_', ' ');
new string[126];
new vehiclename[50];
GetVehicleName(vehicleid, vehiclename, sizeof(vehiclename));
format(string, sizeof(string), "* %s turns the engine of their %s off.", pname, vehiclename);
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
if(VehicleFuel[vehicleid] > 0)
{
SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
strreplace(pname, '_', ' ');
new string[126];
new vehiclename[50];
GetVehicleName(vehicleid, vehiclename, sizeof(vehiclename));
format(string, sizeof(string), "* %s turns the engine of their %s on.", pname, vehiclename);
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
TextDrawHideForPlayer(playerid, Engine);
return 1;
}
else return SendClientMessage(playerid, -1, "> This vehicle is out of fuel.");
}
if(newkeys & KEY_CROUCH)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(lights == 1) SetVehicleParamsEx(vehicleid,engine,0,alarm,doors,bonnet,boot,objective);
else SetVehicleParamsEx(vehicleid,engine,1,alarm,doors,bonnet,boot,objective);
}
}
return 1;
}
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
TextDrawShowForPlayer(playerid, Engine);
return 1;
}
My problem with this is. The textdraw shows up whether the engine is off or on. I want the textdraw to show up if the engine is off. Please help me finish code this.