Log in to reply
 

How can you make car (side-) windows go away?!



  • How can you make car (side-) windows go away?! I have a car (new Porsche 918). I can use trainer to lower the shields, but every time Menyoo, or Simple Trainer auto-repairs the car, the shields are back up. Is there a way to remove the side shields altogether?!

    Thanks



  • Yeah, there are a bunch of natives for this.

    void REMOVE_VEHICLE_WINDOW(Vehicle vehicle, int windowIndex);
    void ROLL_DOWN_WINDOWS(Vehicle vehicle);
    void ROLL_DOWN_WINDOW(Vehicle vehicle, int windowIndex);
    void ROLL_UP_WINDOW(Vehicle vehicle, int windowIndex);
    void SMASH_VEHICLE_WINDOW(Vehicle vehicle, int index);
    void FIX_VEHICLE_WINDOW(Vehicle vehicle, int index);


  • @ikt said in How can you make car (side-) windows go away?!:

    Yeah, there are a bunch of natives for this.

    void REMOVE_VEHICLE_WINDOW(Vehicle vehicle, int windowIndex);
    void ROLL_DOWN_WINDOWS(Vehicle vehicle);
    void ROLL_DOWN_WINDOW(Vehicle vehicle, int windowIndex);
    void ROLL_UP_WINDOW(Vehicle vehicle, int windowIndex);
    void SMASH_VEHICLE_WINDOW(Vehicle vehicle, int index);
    void FIX_VEHICLE_WINDOW(Vehicle vehicle, int index);

    Thanks. :) I'll try those.



  • @ikt said in How can you make car (side-) windows go away?!:

    Yeah, there are a bunch of natives for this.

    void REMOVE_VEHICLE_WINDOW(Vehicle vehicle, int windowIndex);
    void ROLL_DOWN_WINDOWS(Vehicle vehicle);
    void ROLL_DOWN_WINDOW(Vehicle vehicle, int windowIndex);
    void ROLL_UP_WINDOW(Vehicle vehicle, int windowIndex);
    void SMASH_VEHICLE_WINDOW(Vehicle vehicle, int index);
    void FIX_VEHICLE_WINDOW(Vehicle vehicle, int index);

    Hmm, this doesn't exactly work:

                    Vehicle vehicle = Function.Call<Vehicle>(Hash.GET_VEHICLE_PED_IS_IN, playerPed, true);
                    if (vehicle.IsAlive) {
                        UI.ShowSubtitle (vehicle.ToString(), 500);
                    }
    

    That just gives me "GTA.vehicle", LOL.

    Seriously, I want the current vehicle, to lower the windows.

    EDIT: Okay, it's working. I can just do:

                    Function.Call (Hash.ROLL_DOWN_WINDOWS, vehicle);
    

    And check for vehicle.DisplayName.



  • @meimeiriver Instead of calling natives directly, you can summarize your code into this:

    Vehicle vehicle = playerPed.CurrentVehicle;
    if(vehicle != null) //check if you are actually in a vehicle.
    {
        vehicle.RollDownWindows();
    }
    

    Also, I don't know why you check for IsAlive, but if thats important you can add that too.



  • @AHK1221 said in How can you make car (side-) windows go away?!:

    @meimeiriver Instead of calling natives directly, you can summarize your code into this:

    Vehicle vehicle = playerPed.CurrentVehicle;
    if(vehicle != null) //check if you are actually in a vehicle.
    {
        vehicle.RollDownWindows();
    }
    

    Also, I don't know why you check for IsAlive, but if thats important you can add that too.

    Thanks! :) Your code is much cleaner!

    I figured I should use IsAlive as well, for cases where you car might be marked 'dead' (like under water) and lowering windows might crash the game.



  • @meimeiriver I don't know if lowering vehicles when the vehicle is dead crashes the game, but yeah, that's good thinking and you can add that:

    Vehicle vehicle = playerPed.CurrentVehicle;
    if(vehicle != null) //check if you are actually in a vehicle.
    {
        if(vehicle.IsAlive)
            vehicle.RollDownWindows();
    }
    

    Note that I don't actually just do && and add the IsAlive check after the vehicle != null check, that's because if the vehicle is null then referencing any part of that vehicle will cause a script crash.

    Also, with your original code, there would be a script crash if you are not in a vehicle, because you don't check if the vehicle is null (or doesn't exist) or not. You can also do something like this, which might be easier to read or something?

    if(playerPed.IsInVehicle())
    {
        Vehicle vehicle = playerPed.CurrentVehicle;
        if(vehicle.IsAlive)
            vehicle.RollDownWindows();
    }
    

    Note how I don't check if the vehicle is null or not, that's because if you are in a vehicle then the current vehicle is impossible to be null.



  • @AHK1221 said in How can you make car (side-) windows go away?!:

    Also, with your original code, there would be a script crash if you are not in a vehicle, because you don't check if the vehicle is null (or doesn't exist) or not

    In my full code, I have a line preceeding it, like:

            if (playerPed.IsInVehicle ()) {
    

    So there would not have been a crash. :)



  • @meimeiriver said in How can you make car (side-) windows go away?!:

    if (playerPed.IsInVehicle ()) {

    LOL. Just realized that's in your code too. :)



  • @AHK1221
    You don't need to split up && things. If the first condition is false the second condition isn't evaluated.



  • @ikt said in How can you make car (side-) windows go away?!:

    @AHK1221
    You don't need to split up && things. If the first condition is false the second condition isn't evaluated.

    Most modern languages have an early-out evaluation like that with && (after all, if the first condition equates to 'false', no need to evaluate any further).



  • @ikt Oh, didn't know that. I thought it checked every condition before deciding the final decision. Thanks for the info!



  • @AHK1221 said in How can you make car (side-) windows go away?!:

    @ikt Oh, didn't know that. I thought it checked every condition before deciding the final decision. Thanks for the info!

    LSL (Linden Script Language, for Second Life), for instance, evaluates every part too. Which can really matter, if you calculate & test the result on the inside of the right-hand side too. But yeah, modern languages are a bit more clever than that. :)

    Anyway, thx again for help. It's all working smooth now.



  • @meimeiriver Don't want to hijack the thread, but you can also use IS_VEHICLE_DRIVEABLE instead is.alive. Cause, isalive for vehicle, IDK, doesn't seem right. (:



  • @ashishcw You can use vehicle.IsDriveable instead of that, lol.



  • @AHK1221 I guess, they both get the same results, I just put the Native from Native DB, since, I am not on my PC.


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.