Log in to reply
 

Invincible Vehicle C#



  • so i'm new to modding and this doesnt work, any1 knows the problem

    using GTA;
    using GTA.Native;
    using GTA.Math;
    using System;
    using System.Windows.Forms;
    using System.Collections.Generic;
    using System.IO;
    using System.Drawing;
    using System.Media;

    public class ModName : Script
    {

    private Ped playerPed = Game.Player.Character;
    private Player player = Game.Player;
    
    
    public ModName()
    {
    	
    
    	Tick += OnTick;
    	KeyDown += OnKeyDown;
    	KeyUp += OnKeyUp;
    }
    
    
    private void OnTick(object sender, EventArgs e)
    {
    
    }
    
    
    private void OnKeyDown(object sender, KeyEventArgs e)
    {
       if (e.KeyCode == Keys.L)
        {
            Vehicle currentVehicle = playerPed.CurrentVehicle;
            currentVehicle.IsInvincible = true;
        }
    }
    
    
    private void OnKeyUp(object sender, KeyEventArgs e)
    {
    
    }
    

    }



  • Looks like it should work, although I don't think it will if you switch characters. What is the problem you're having? Do you get an error?



  • @Jitnaught nah just when i crash my car just keeps on getting more damage and after a while not drive anymore



  • Add a subtitle or something to notify you if the code is being run or not.

    UI.ShowSubtitle("Car now invincible");



  • @Jitnaught ik that code an it works but the invinvible car doesnt


  • MODERATOR

    I don't think IsInvincible is enough, you might want to apply the following other things:

    SET_VEHICLE_CAN_BREAK(vehicle, 0);
    SET_VEHICLE_CAN_BE_VISIBLY_DAMAGED(vehicle, 0);
    SET_VEHICLE_TYRES_CAN_BURST(vehicle, 0);
    SET_ENTITY_CAN_BE_DAMAGED(vehicle, 0);
    SET_ENTITY_INVINCIBLE(vehicle, 1);
    SET_ENTITY_PROOFS(vehicle, 1, 0, 1, 1, 1, 1, 1, 1);
    

    (Taken from Menyoo's current codebase)



  • @ikt still dindt work, i think it isnt compatible with a other mod i have wich give way more car damage thank you all for trying to help tho


  • MODERATOR

    Please don't delete topics. They might contain useful information for others.


Log in to reply
 

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