Jump to content

How to add vehicle damage


Deactivated Member

Recommended Posts

it only has a getter, you can't set it to anything...

 

image.png.6b73f0ed5368920cc11efa7870014f98.png

 

if you want to damage a vehicle use the vehicle.Deform method

 

https://docs.ragepluginhook.net/html/M_Rage_Vehicle_Deform.htm

public static void Damage(this Vehicle vehicle, float radius, float amount)
{
    var model = vehicle.Model;
    model.GetDimensions(out var vector3_1, out var vector3_2);
    var num = new Random().Next(10, 45);
    for (var index = 0; index < num; ++index)
    {
        var randomInt1 = MathHelper.GetRandomSingle(vector3_1.X, vector3_2.X);
        var randomInt2 = MathHelper.GetRandomSingle(vector3_1.Y, vector3_2.Y);
        var randomInt3 = MathHelper.GetRandomSingle(vector3_1.Z, vector3_2.Z);
        vehicle.Deform(new Vector3(randomInt1, randomInt2, randomInt3), radius, amount);
    }
}
Edited by NoNameSet
Link to comment
Share on other sites

Thanks, so I've got the hole callout working, it's the speech now. So this is what I've got, but when I accept the callout, it just plays the text over and over again, when I haven't even pressed T.

 

  public override void Process()
        {
            base.Process();
            state1 = EConvostate.init;
            {
                if (Game.LocalPlayer.Character.Position.DistanceTo(CopPed.Position) <=3f)
                if (Game.LocalPlayer.Character.Position.DistanceTo(CopPed.Position) <= 3f)
                    GameFiber.Yield();
                while (Game.IsKeyDown(System.Windows.Forms.Keys.T))
                    GameFiber.Yield();
                VehicleBlip.DisableRoute();

                Game.DisplaySubtitle("~b~Officer:~s~ I saw the two vehicles crash as I was driving the other way, the ~g~victim~s~ seems to be alright, but the ~r~suspect~s~ is very aggressive, so be careful of him.", 9000);
                GameFiber.Wait(8000);
                Game.DisplaySubtitle("~b~Officer~s~ I've spoken to both of them, and they seem friendly towards each other but the suspect doesn't like me at all", 7000);
                GameFiber.Wait(6000);
                Game.DisplaySubtitle("~b~Officer:~s~ So now that you know what's going on, talk to the ~g~victim~s~ first, and then tlak to the ~r~suspect~s~.", 6500);

                if (Game.LocalPlayer.Character.Position.DistanceTo(Victimped.Position) <= 3f)
                    GameFiber.Yield();
                while (Game.IsKeyDown(System.Windows.Forms.Keys.T))
                    GameFiber.Yield();

                Game.DisplaySubtitle("~b~You:~s~ Hello Sir, I'm here to talk to you about the crash.", 4000);
                GameFiber.Wait(3000);
                Game.DisplaySubtitle("~g~Victim:~s~ Hello Officer, yes... This man was doing well over the speed limit, came up behind me and next thing ya know, BOOM! ploughed into my fucking car!", 6500);
                GameFiber.Wait(5500);
                Game.DisplaySubtitle("~b~You:~s~ Why isn't the suspect's vehicle here sir?", 3000);
                GameFiber.Wait(2000);
                Game.DisplaySubtitle("~g~Victim:~s~ The officer first on scene searched it, and got it towed away. I didn't really pay attention to that because I could care less what happens to that asshole.", 8000);
                GameFiber.Wait(7000);
                Game.DisplaySubtitle("~b~You:~s~ Are you hurt in anyway? Is anything bothering you?", 3500);
                GameFiber.Wait(2500);
                Game.DisplaySubtitle("~g~Victim:~s~ No sir, I just want that asshole put in prison for how he's treated the officer, hitting my car and then acting like he's done nothing wrong... Fucking idiot!", 7000);
                GameFiber.Wait(6000);
                Game.DisplaySubtitle("~b~You:~s~ Alright sir, I'll talk to him now.", 3000);
                GameFiber.Wait(2000);
                Game.DisplaySubtitle("~g~Victim:~s~ Thank you officer.", 2500);
                GameFiber.Wait(1500);
                Game.DisplaySubtitle("Talk to the ~r~suspect~s~ and deal with the situation how you think it fits.", 4000);

                if (Game.LocalPlayer.Character.Position.DistanceTo(SuspectPed) <= 3f)
                    GameFiber.Yield();
                while (Game.IsKeyDown(System.Windows.Forms.Keys.T))
                    GameFiber.Yield();

                Game.DisplaySubtitle("~b~You:~s~ Hello Sir, I'm to talk with you about the crash.", 3500);
                GameFiber.Wait(2500);
                Game.DisplaySubtitle("~r~Suspect:~s~ I'm not saying one fucking word dumbass, I've done nothing wrong, he should be dead for all I care, now fuck off and leave me alone!",

6500);
                state1 = EConvostate.Last;
                GameFiber.Wait(5500);
                Game.DisplayNotification("Arrest the ~r~suspect~s~.");
                {
                    if (Functions.IsPedArrested(SuspectPed))
                    {
                        End();
                    }

Link to comment
Share on other sites

Thats because you're looping it, just use the dialog class I gave you. From what I can see right now you are using GameFiber.Sleep without creating a new fiber which you shouldn't ever do lol. You should also use an enum and switch between callout states like I showed you before.

Edited by NoNameSet
Link to comment
Share on other sites

Okay, now this isn't working, not in game, the second to last bracket is underlined red. error is as follows "delegate

                                                                                                                                                                                                               {

                                                                                                                                                                                                                

                                                                                                                                                                                                               ; expected"

 

So I've tried putting the semicolon there, that didn't work, and I've tried putting the closed bracket and the semicolon, but still didn't work, e.g "GameFiber.StartNew(delegate);"

 

  state1 = EConvostate.OnScene;
            GameFiber.StartNew(delegate      <This is the delegate that's having errors
                {
                state1 = EConvostate.init;
                while (true)
                {
                    GameFiber.Yield();
                    if (Game.IsKeyDown(System.Windows.Forms.Keys.T))
                    {
                        GameFiber.Yield();
                    }
                    {
                        if (state1 == EConvostate.init)
                            if (isSpeechComplete)
                            {
                                GameFiber.Yield();
                                if (isSpeechComplete)
                                    if (state1 == EConvostate.OnScene && Game.LocalPlayer.Character.Position.DistanceTo(CopPed) <= 5f)
                                        Game.DisplaySubtitle("~b~You:~s~ Hello Officer, what seems to be the problem today?", 3500);
                                GameFiber.Wait(2500);

                                Game.DisplaySubtitle("~b~Officer:~s~ Well what I saw was the picador get rammed, almost pitted by the fugitive. Be careful with the suspect, he's pretty hostile.", 6000);
                                GameFiber.Wait(5000);

                                Game.DisplaySubtitle("~b~You:~s~ Thanks officer, I'll deal with the victim first, and then the suspect.", 4500);
                                GameFiber.Wait(3500);

                                GameFiber.Yield();
                                if (Game.LocalPlayer.Character.Position.DistanceTo(Victimped) <= 5f)
                                    if (Game.IsKeyDown(System.Windows.Forms.Keys.T))
                                        Game.DisplaySubtitle("~b~You:~s~ G'day sir, can you tell me exactly what happened today.", 3500);
                                GameFiber.Wait(2500);
                                Game.DisplaySubtitle("~g~Victim:~s~ Not much officer, I was heading to my mates place for a beer and shit, and all of a sudden BOOM! I get rammed from this fugitive                                  asshole, as he continues to ram my side.", 8500);
                                GameFiber.Wait(7500);
                                Game.DisplaySubtitle("~b~You:~s~ Okay sir, thank you for the information, have you been injured in any way?", 4000);
                                GameFiber.Wait(3000);
                                Game.DisplaySubtitle("~g~Victim:~s~ No officer, the ambo over there checked me and him out, I've got no injuries but the other guy has a sprained wrist, serves him right in my opinion.", 7000);
                                GameFiber.Wait(6000);
                                Game.DisplaySubtitle("~b~You:~s~ All good sir, just wait here while I talk to the ~r~suspect~s~ please.", 3500);
                                GameFiber.Wait(2500);

                                GameFiber.Yield();
                                if (Game.LocalPlayer.Character.Position.DistanceTo(SuspectPed) <= 5f)
                                    if (Game.IsKeyDown(System.Windows.Forms.Keys.T))
                                        Game.DisplaySubtitle("~b~You:~s~ Howdy' sir, I'm gonna have a word with you about this accident.", 4500);
                                GameFiber.Wait(3500);
                                Game.DisplaySubtitle("~r~Suspect:~s~ Fuck off dumbass, I'm not saying one fucking word, I've done nothing wrong, he cut me off so I had all right to hit him, NOW FUCK OFF AND LEAVE ME ALONE!!", 9000);
                                GameFiber.Wait(8000);
                                Game.DisplayNotification("Arrest the ~r~suspect~s~");
                                isSpeechComplete = true;

                                Functions.IsPedArrested(SuspectPed);
                                {
                                    End();
                                }
                            }
                    }
                }
            }        <This is the bracket that's underlined in red saying the error
        }

                public override void End()
        {
            base.End();
            if (Victimped.Exists()) Victimped.Dismiss();
            if (Victimvehicle.Exists()) Victimvehicle.Dismiss();
            if (SuspectBlip.Exists()) SuspectBlip.Delete();
            if (SuspectVehicle.Exists()) SuspectVehicle.Dismiss();
            if (SuspectPed.Exists()) SuspectPed.Dismiss();
            if (CopBlip.Exists()) CopBlip.Delete();
            if (PedBlip.Exists()) PedBlip.Delete();
            if (VehicleBlip.Exists()) VehicleBlip.Delete();
            if (CopPed.Exists()) CopPed.Dismiss();
            if (AmboPed.Exists()) AmboPed.Dismiss();
            CopPed.Tasks.EnterVehicle(CopVehicle, -1);
            AmboPed.Tasks.EnterVehicle(AmboVehicle, -1);
            CopPed.Tasks.CruiseWithVehicle(0f, VehicleDrivingFlags.Emergency);
            AmboPed.Tasks.CruiseWithVehicle(0f, VehicleDrivingFlags.Emergency);
            CopVehicle.IsSirenOn = false;
            AmboVehicle.IsSirenOn = false;
        }
    }
}

Link to comment
Share on other sites

you are still creating a while loop that isn't needed and sleeping the fiber for your dialog class. Guess you don't take advice, have fun with a callout that is stacked up with bugs and crashes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...