0.3c vehicle,lights etc
#1

Ok i have problem with this code but get no errors. When the car engine is off you can only turn on/open the other commands and when the engine is on you can only turn off/close the other commands. I need it to where you can open close/ turn off on the features without depending if the engine is off or on someone please help me

pawn Код:
if(strcmp(cmdtext, "/engine", true) == 0)
    {
        if(!IsPlayerConnected(playerid)) return false;
        if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid,0xB4B5B7FF,"You're not in a car!");
        new vehicleid  = GetPlayerVehicleID(playerid);
        new engine,lights,doors,alarm,bonnet,boot,objective;
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine != 1)
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s sticks the keys into the ignition and turns their vehicle on.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        else
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s sticks the keys into the ignition and turns the vehicle off.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        return true;
    }
    if(strcmp(cmdtext, "/lights", true) == 0)
    {
        if(!IsPlayerConnected(playerid)) return false;
        if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid,0xB4B5B7FF,"You're not in a car!");
        new vehicleid  = GetPlayerVehicleID(playerid);
        new engine,lights,doors,alarm,bonnet,boot,objective;
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine != 1)
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,engine,1,alarm,doors,bonnet,boot,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s turns on the vehicle lights.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        else
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,engine,0,alarm,doors,bonnet,boot,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s turns off the vehicle lights.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        return true;
    }
    if(strcmp(cmdtext, "/hood", true) == 0)
    {
        if(!IsPlayerConnected(playerid)) return false;
        if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid,0xB4B5B7FF,"You're not in a car!");
        new vehicleid  = GetPlayerVehicleID(playerid);
        new engine,lights,doors,alarm,bonnet,boot,objective;
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine != 1)
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,1,boot,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s pops the hood and opens it.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        else
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,0,boot,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s slams the hood shut.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        return true;
    }
    if(strcmp(cmdtext, "/trunk", true) == 0)
    {
        if(!IsPlayerConnected(playerid)) return false;
        if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid,0xB4B5B7FF,"You're not in a car!");
        new vehicleid  = GetPlayerVehicleID(playerid);
        new engine,lights,doors,alarm,bonnet,boot,objective;
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine != 1)
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,1,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s pops the trunk and opens it.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        else
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s slams the trunk shut.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        return true;
    }
Reply
#2

Did you make this?
Reply
#3

after the engine bit yes
Reply
#4

So you made from lights down? And explain to me better what you want to do because I don't understand.
Reply
#5

correct
Reply
#6

And explain to me better what you want to do because I don't understand.
Reply
#7

Ok when the car is off and you do the other commands it only turns on the other features once you do the command again it still turns it on not off. when the car is on and you type the other commands it only turns off/closes it not turn on. i need it to where if the car engine is off/on you can open/close/turn on/turn off the other functions.
Reply
#8

Try this:

pawn Код:
f(strcmp(cmdtext, "/engine", true) == 0)
    {
        if(!IsPlayerConnected(playerid)) return false;
        if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid,0xB4B5B7FF,"You're not in a car!");
        new vehicleid  = GetPlayerVehicleID(playerid);
        new engine,lights,doors,alarm,bonnet,boot,objective;
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine != 1)
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s sticks the keys into the ignition and turns their vehicle on.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        else
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s sticks the keys into the ignition and turns the vehicle off.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        return true;
    }
    if(strcmp(cmdtext, "/lights", true) == 0)
    {
        if(!IsPlayerConnected(playerid)) return false;
        if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid,0xB4B5B7FF,"You're not in a car!");
        new vehicleid  = GetPlayerVehicleID(playerid);
        new engine,lights,doors,alarm,bonnet,boot,objective;
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(lights != 1)
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,engine,1,alarm,doors,bonnet,boot,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s turns on the vehicle lights.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        else
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,engine,0,alarm,doors,bonnet,boot,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s turns off the vehicle lights.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        return true;
    }
    if(strcmp(cmdtext, "/hood", true) == 0)
    {
        if(!IsPlayerConnected(playerid)) return false;
        if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid,0xB4B5B7FF,"You're not in a car!");
        new vehicleid  = GetPlayerVehicleID(playerid);
        new engine,lights,doors,alarm,bonnet,boot,objective;
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(bonnet != 1)
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,1,boot,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s pops the hood and opens it.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        else
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,0,boot,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s slams the hood shut.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        return true;
    }
    if(strcmp(cmdtext, "/trunk", true) == 0)
    {
        if(!IsPlayerConnected(playerid)) return false;
        if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid,0xB4B5B7FF,"You're not in a car!");
        new vehicleid  = GetPlayerVehicleID(playerid);
        new engine,lights,doors,alarm,bonnet,boot,objective;
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(boot != 1)
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,1,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s pops the trunk and opens it.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        else
        {
            if(vehicleid != INVALID_VEHICLE_ID)
            {
                SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,0,objective);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "%s slams the trunk shut.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
                printf("%s", string);
            }
        }
        return true;
    }
Reply
#9

OMG that worked thank you so much
Reply
#10

No problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)