[help] Engine
#1

I have problem,when i want to rent vehicle i cannot start engine i do /rentveh and i rent it but i can't turn engine off or on. I dont understand what is wrong


pawn Код:
.
    if(strcmp(cmd, "/rentcar", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new string[128],sendername[MAX_PLAYER_NAME];
            GetPlayerName(playerid, sendername,sizeof(sendername));
            new hirefee = HireCost(GetPlayerVehicleID(playerid));
            if(SBizzInfo[1][sbProducts] == 0)
            {
                GameTextForPlayer(playerid, "~r~No Products", 5000, 1);
                return 1;
            }
            if(!IsARentableVeh(GetPlayerVehicleID(playerid)))
            {
                SCM(playerid, COLOR_GRAD2, "   This car are not for Rent !");
                return 1;
            }
            if(GetPlayerMoney(playerid) <  SBizzInfo[1][sbEntranceCost])
            {
                SCM(playerid, COLOR_GRAD2, "   You don't have enough money to Rent a Car !");
                return 1;
            }
            if(HireCar[playerid] != 9999)
            {
                UnLockCar(HireCar[playerid]);
                SCM(playerid, COLOR_GREY, "   You need unrent your current car/bike/boat first !");
                return 1;
            }
            foreach(Player, i)
            {
                if(HireCar[i] == GetPlayerVehicleID(playerid))
                {
                    SCM(playerid, COLOR_GREY, "   Someone already rents this car !");
                    return 1;
                }
            }
            SafeGivePlayerMoney(playerid,-SBizzInfo[1][sbEntranceCost]);
            SBizzInfo[1][sbTill] += SBizzInfo[1][sbEntranceCost];
            ExtortionSBiz(1, SBizzInfo[1][sbEntranceCost]);
            SBizzInfo[1][sbProducts]--;
            HireCar[playerid] = GetPlayerVehicleID(playerid);
            OnPropUpdate(3,1);
            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
            format(string, sizeof(string), "~w~Don't forget to ~r~/unrentcar~n~~g~/lock ~w~to lock your car.",hirefee);
            SCM(playerid, COLOR_YELLOW2, "You can turn engine now !");
            gEngine[playerid] = 0;
            engineOn[GetPlayerVehicleID(playerid)] = false;
            GameTextForPlayer(playerid, string, 5000, 3);
            new y, m, d;
            new h,mi,s;
            getdate(y,m,d);
            gettime(h,mi,s);
            format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /rentcar",d,m,y,h,mi,s,sendername);
            CommandLog(string);
        }
        return 1;
    }
Engine command
pawn Код:
.
    if(!strcmp(cmd, "/engine", true))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new carid = GetPlayerVehicleID(playerid)
            if(CarInfo[carid][cBrokeVehicle] == 0)
            {
                if(!engineOn[GetPlayerVehicleID(playerid)])
                {
                    new idcar1 = GetPlayerVehicleID(playerid);
                    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
                    if(idcar1 == 510 || idcar1 == 462 || idcar1 == 481 || idcar1 == 509) return 1;
                    if(IsARentableVeh(idcar))
                    {
                        if(HireCar[playerid] != idcar) return 1;
                    }
                    if(IsAHarvest(idcar)) return 1;
                    if(IsADrugHarvest(idcar)) return 1;
                    if(IsASweeper(idcar)) return 1;
                    if(IsASalesVehicle(idcar)) return 1;
                    if(CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999)
                        return SCM(playerid, COLOR_GREY,"* You cannot turn this car's engine!");

                    new plname[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, plname, sizeof(plname));
                    format(string, sizeof(string), "The Driver spins the key of his car and Starts the engine.");
                    ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                    SCM(playerid, COLOR_WHITE, "You turned the engine {00FF00}On");
                    if(PlayerInfo[playerid][pAdmin] < 1336 && PlayerInfo[playerid][pAdminDuty] == 1)
                    {
                        SetTimerEx("StartingTheVehicle",1,0,"i",playerid);
                    }
                    else
                    {
                        SetTimerEx("StartingTheVehicle",1,0,"i",playerid);
                    }
                    gEngine[playerid] = 1;
                    new vid = GetPlayerVehicleID(playerid);
                    new engine,lights,alarm,doors,bonnet,boot,objective;
                    GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
                    engineOn[GetPlayerVehicleID(playerid)] = true;
                    new y, m, d;
                    new h,mi,s;
                    getdate(y,m,d);
                    gettime(h,mi,s);
                    format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /engine",d,m,y,h,mi,s,sendername);
                    CommandLog(string);
                    return 1;
                }
                else if(engineOn[GetPlayerVehicleID(playerid)])
                {
                    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
                    if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509) return 1;
                    if(IsARentableVeh(idcar))
                    if(IsASalesVehicle(idcar))
                    {
                        if(HireCar[playerid] != idcar) return 1;
                    }
                    if(IsAHarvest(idcar)) return 1;
                    if(IsADrugHarvest(idcar)) return 1;
                    if(IsASweeper(idcar)) return 1;
                    if(CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999)
                        return SCM(playerid, COLOR_GREY,"* You cannot turn this car's engine!");
                    format(string, sizeof(string), "The Driver spins a key and turns off the engine", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                    SCM(playerid, COLOR_WHITE, "You turned the engine {FF0000}Off");
                    gEngine[playerid] = 0;
                    new vid = GetPlayerVehicleID(playerid);
                    new engine,lights,alarm,doors,bonnet,boot,objective;
                    GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                    engineOn[GetPlayerVehicleID(playerid)] = false;
                    TogglePlayerControllable(playerid, true);
                    new y, m, d;
                    new h,mi,s;
                    getdate(y,m,d);
                    gettime(h,mi,s);
                    format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /engine",d,m,y,h,mi,s,sendername);
                    CommandLog(string);
                    return 1;
                }
            }
            else
            {
                SCM(playerid, COLOR_GREY, "Your vehicle engine is broken, call a mechanic!");
            }
        }
        return 1;
    }
Reply
#2

Anyone? i figured out when i /rentcar and i do /engine its say you cant start engine but when i exit from rented car and enter again all works perfect,i even tried to do it like this
respawncar and putplayerinvehicle but not working,
I dont know what can couse this problem,so when i /rentcar i cant start engine but when i exit from car and enter again it work perfect. if i unrent and rent new same story i need after i rented it only once to get out and get in and it will work :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)