Confused as hell ..
#10

Okay I changed code to yours, it's working normal but I still don't know how to save each vehicle fuel ? if I'm driving with on and waste half of fuel and if I enter to another at start it shows same fuel as I had in car before, and when I write /engine command it resets it's fuel to full
here is engine cmd if you need to check anything
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/engine", true) == 0) {
        new vehicle = GetPlayerVehicleID(playerid);
        new engine,lights,alarm,doors,bonnet,boot,objective;
        GetVehicleParamsEx(vehicle,engine,lights,alarm,doors,bonnet,boot,objective);
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You need to be in vehicle to start engine.");
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You need to be driver to use this command.");
        if(engine == 1) {
            SetVehicleParamsEx(vehicle,0,lights,alarm,doors,bonnet,boot,objective);
            SendClientMessage(playerid, COLOR_PURPLE,"{00FF00}INFO: {FFFFFF}Engine turned off.");
            KillTimer(GasTimer[playerid]);
            return 1;
        } else {
            SendClientMessage(playerid, COLOR_PURPLE,"{00FF00}INFO: {FFFFFF}You twisted the key, wait 4 seconds.");
            SetTimerEx("EngStart", 4000, false, "d", playerid);
            return 1;
        }
    }
pawn Код:
public EngStart(playerid)
{
    // This will help us to detect vehicle HP
    new Float:vehHP, vehicle = GetPlayerVehicleID(playerid);
    GetVehicleHealth(vehicle, vehHP);
    new engine,lights,alarm,doors,bonnet,boot,objective;
    GetVehicleParamsEx(vehicle,engine,lights,alarm,doors,bonnet,boot,objective);
    // If vehicle HP is 550 or more it will turn it's engine on 100%
    if(vehHP >= 550)
    {
        SendClientMessage(playerid, COLOR_YELLOW,"{00FF00}INFO: {FFFFFF}Engine is succesfully started.");
        SetVehicleParamsEx(vehicle,1,lights,alarm,doors,bonnet,boot,objective);
        GasTimer[playerid] = SetTimerEx("FLower", 1000, true, "i", playerid);
        return 1;
    }
    // If vehicle HP is under 550 it will be  1/3 chance to turn it's engine one because it's broken
    else
    {
        switch(random(3))
        {
            case 0:
            {
                SendClientMessage(playerid, COLOR_YELLOW,"{00FF00}INFO: {FFFFFF}Engine is succesfully started.");
                SetVehicleParamsEx(vehicle,1,lights,alarm,doors,bonnet,boot,objective);
                GasTimer[playerid] = SetTimerEx("FLower", 1000, true, "i", playerid);
                return 1;
            }
            case 1:
            {
                SendClientMessage(playerid, COLOR_YELLOW,"{FF0000}INFO: {FFFFFF}Engine failed to start because your engine is broken, please try again.");
                SetVehicleParamsEx(vehicle,0,lights,alarm,doors,bonnet,boot,objective);
                return 1;
            }
            case 2: // added another case so it will be harder to turn on engine if car is broken
            {
                SendClientMessage(playerid, COLOR_YELLOW,"{FF0000}INFO: {FFFFFF}Engine failed to start because your engine is broken, please try again.");
                SetVehicleParamsEx(vehicle,0,lights,alarm,doors,bonnet,boot,objective);
                return 1;
            }
        }
    }
    return 1;
}
I hope you can help with this, thanks in advance
Reply


Messages In This Thread
Confused as hell .. - by Lajko1 - 21.11.2013, 16:50
Re: Confused as hell .. - by Loot - 21.11.2013, 17:09
Re: Confused as hell .. - by Lajko1 - 21.11.2013, 17:22
Re: Confused as hell .. - by Konstantinos - 21.11.2013, 17:29
Re: Confused as hell .. - by Lajko1 - 21.11.2013, 17:33
Re: Confused as hell .. - by Konstantinos - 21.11.2013, 18:08
Re: Confused as hell .. - by Lajko1 - 21.11.2013, 18:39
Re: Confused as hell .. - by Konstantinos - 21.11.2013, 19:19
Re: Confused as hell .. - by Lajko1 - 21.11.2013, 19:35
Re: Confused as hell .. - by Lajko1 - 21.11.2013, 22:48

Forum Jump:


Users browsing this thread: 1 Guest(s)