SA-MP Forums Archive
0.3c vehicle,lights etc - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: 0.3c vehicle,lights etc (/showthread.php?tid=251215)



0.3c vehicle,lights etc - The_J0ker - 26.04.2011

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;
    }



Re: 0.3c vehicle,lights etc - Tee - 26.04.2011

Did you make this?


Re: 0.3c vehicle,lights etc - The_J0ker - 26.04.2011

after the engine bit yes


Re: 0.3c vehicle,lights etc - Tee - 26.04.2011

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


Re: 0.3c vehicle,lights etc - The_J0ker - 26.04.2011

correct


Re: 0.3c vehicle,lights etc - Tee - 26.04.2011

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


Re: 0.3c vehicle,lights etc - The_J0ker - 26.04.2011

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.


Re: 0.3c vehicle,lights etc - Tee - 26.04.2011

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;
    }



Re: 0.3c vehicle,lights etc - The_J0ker - 26.04.2011

OMG that worked thank you so much


Re: 0.3c vehicle,lights etc - Tee - 26.04.2011

No problem.