Coding.
#1

I have created a engine system in my script.

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;
}
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.
Reply
#2

use something like GetVehicleParamsEx then check if the engine is on

some thing like this

pawn Код:
if(GetVehicleParamsEx(vehicleid, 1, //others)) //checks if vehicle engine is on
{
//put your textdraw code
}
else if(GetVehicleParamsEx(vehicleid, 0, //others)) //checks if vehicle engine is off
{
//put your textdraw hide code
}
Reply
#3

I don't want to make another thread. So I'll post it here.

Is there any way I could skip the Class Selection.

What I want is to skip the Class Selection and continue to dialogs.
Reply
#4

Create a new topic. That's what you're meant to do. It's not illegal >.>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)