Log in to reply
 

I need some help with a mod please!



  • So I made a script with Visual Studio, ran it, works perfectly other than the blips and I can't make the player do an animation...

    Can anyone here show me how you guys create blips and do you put them in the OnTick void or where? Mine don't seem to work...

    Second, I try making the player do an animation but it just doesn't work... I tried doing it through a Function Call like this:
    Function.Call(Hash.TASK_PLAY_ANIM, Game.Player.Character, "animation@name");
    or
    Function.Call(Hash.PLAY_ENTITY_ANIM, Game.Player.Character, "animation@name");

    Am I writing these wrong or are there any better ways to do it?
    I have JetBrains dotPeek and I tried so many sources this is the last one I have...



  • @Eyon Game.Player.Character.Task.PlayAnimation("swat", "rally_point", 8.0f, -8.0f, 2000, AnimationFlags.UpperBodyOnly, 0.0f);



  • Thank you aimless!



  • @aimless Hey I'm sorry if this makes me look like an idiot, but can you also explain me how do I fix this error?

    InputArgument.implicit operator InputArgument(Rope)': cannot explicitly call operator or accessor

    Here's the code:

            void SayThanks()
            {
                Function.Call(Hash._PLAY_AMBIENT_SPEECH_WITH_VOICE, new InputArgument[3]
                {
                    InputArgument.op_Implicit(Game.Player.Character),
                    InputArgument.op_Implicit("GENERIC_THANKS"),
                    InputArgument.op_Implicit("SPEECH_PARAMS_FORCE"),
                });
            }


  • @aimless

    Function.Call(Hash._0x8E04FEDD28D42462, (InputArgument)Game.Player.Character, (InputArgument)"GENERIC_THANKS", (InputArgument)"SPEECH_PARAMS_FORCE", (InputArgument)0);

    I found this alternative. Even though can you still tell me what the problem with the one I did there was? Isn't op_Implicit supposed to mean implicit operator? Isn't it an operator already? Am I using it in the wrong place? I can't declare it that I know for sure...


  • MODERATOR

    @Eyon you don't need to cast to InputArgument.

    Function.Call((Hash)0x8E04FEDD28D42462, Game.Player.Character, "GENERIC_THANKS", "SPEECH_PARAMS_FORCE", 0);



  • @stillhere @aimless Hey, I have one last issue. My blips get duplicated whenever I reload the script. These are the 3 blips:

            Blip bl1 = World.CreateBlip(location1);
            bl1.Sprite = BlipSprite.Hospital;
            bl1.Color = BlipColor.Green;
            bl1.Name = "Hospital";
            bl1.IsShortRange = true;
            Blip bl2 = World.CreateBlip(location2);
            bl2.Sprite = BlipSprite.Hospital;
            bl2.Color = BlipColor.Green;
            bl2.Name = "Hospital";
            bl2.IsShortRange = true;
            Blip bl3 = World.CreateBlip(location3);
            bl3.Sprite = BlipSprite.Hospital;
            bl3.Color = BlipColor.Green;
            bl3.Name = "Hospital";
            bl3.IsShortRange = true;
    

    Any way to fix it? I tried adding them to a list and removing them with a for loop that deletes them one by one through an index. Dunno why it didn't work...

    public void CleanBlips()
    {
    for (int index = 0; index < ((IEnumerable<Blip>)blipList).Count<Blip>(); ++index)
    list[index].Remove();
    list.Clear();
    }

    What do you suggest?


  • MODERATOR

    @Eyon Try something like this out:

    List<Blip> blips = new List<Blip>();
    
    public YourScript()
    {
    	Aborted += YourScript_Aborted; //aborted event is called when reloading scripts
    	
    	addBlips();
    }
    
    //put the blip creation code in its own function so you aren't repeating 6 lines of code for each blip creation
    private void createBlip(BlipSprite sprite, BlipColor color, string name, bool shortRange)
    {
    	Blip blip = new Blip();
    	blip.Sprite = sprite;
    	blip.Color = color;
    	blip.Name = name;
    	blip.IsShortRange = shortRange;
    	
    	blips.Add(blip);
    }
    
    private void addBlips()
    {
    	createBlip(BlipSprite.Hospital, BlipColor.Green, "Hospital", true);
    	
    	//copy paste above for rest of blips and change accordingly
    }
    
    private void destroyBlips()
    {
    	while (blips.Count > 0) //while there are still blips left to delete
    	{
    		blips[0].Remove(); //delete blip
    		blips.RemoveAt(0); //remove blip from list
    	}
    }
    
    private void YourScript_Aborted(object sender, EventArgs e)
    {
    	//delete blips on script abort (script reload)
    	destroyBlips();
    }
    

    Note: This is totally untested, and I haven't coded a script for GTA V in months, so I don't know if this will work.



  • @Jitnaught It did work! I added some lists as well and it worked. Thanks! I will be releasing the mod later. :)


  • MODERATOR

    @Eyon I look forward to seeing it :)



  • @Jitnaught By the way, how do I find the hash for playing a sound



  • Nevermind, fixed it by myself.


Log in to reply
 

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