Zolika1351 Posted December 5, 2016 Share Posted December 5, 2016 (edited) -snip- Edited April 22, 2020 by Zolika1351 removed hack Link to comment Share on other sites More sharing options...
fastman92 Posted December 5, 2016 Share Posted December 5, 2016 (edited) The code needs to be put inside a function, you added an orphaned code and wonder why it can't be compiled. Edited December 5, 2016 by fastman92 Link to comment Share on other sites More sharing options...
Jitnaught Posted December 5, 2016 Share Posted December 5, 2016 Multiple problems with the code. 1. You are using a mix of C# and VB code. Pick one of the languages and use that one solely. 2. You have to declare a class that inherits the GTA.Script class, and put your code within. 3. You have to handle the KeyDown/Up event and put your If statement in that function. Like this (VB) Imports SystemImports GTAImports System.DrawingImports System.Windows.FormsPublic Class SwimmingAnimScript Inherits Script Public Sub New() End Sub Shadows Sub SwimmiongAnimScript_KeyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown If e.Key = Keys.NumPad1 Then Dim AnimSet As AnimationSet Dim AnimName As String = "idle" AnimSet = New AnimationSet("swimming") Player.Character.Animation.Play(AnimSet, AnimName, 8, AnimationFlags.Unknown11 Or AnimationFlags.Unknown05) End If End SubEnd Class or this (C#) using System;using GTA;using System.Drawing;using System.Windows.Forms;public class SwimmingAnimScript : Script{ public SwimmingAnimScript() { KeyDown += SwimmingAnimScript_KeyDown; } private void SwimmiongAnimScript_KeyDown(object sender, GTA.KeyEventArgs e) { if (e.Key == Keys.NumPad1) { AnimationSet animSet = new AnimationSet("swimming"); string animName = "idle"; Player.Character.Animation.Play(animSet, animName, 8, AnimationFlags.Unknown11 | AnimationFlags.Unknown05); } }} Link to comment Share on other sites More sharing options...
Zolika1351 Posted December 5, 2016 Author Share Posted December 5, 2016 Multiple problems with the code. 1. You are using a mix of C# and VB code. Pick one of the languages and use that one solely. 2. You have to declare a class that inherits the GTA.Script class, and put your code within. 3. You have to handle the KeyDown/Up event and put your If statement in that function. Thanks, now I have another error, I wanted to speed up the animation with another script, but I got the error: The term "native" does not exist in the current context. Tried adding "using GTA.Native" but it didn't work Code: using System; using GTA; using GTA.Native; using System.Drawing; using System.Windows.Forms; public class FastAnimScript : Script { public FastAnimScript() { KeyDown += FastAnimScript_KeyDown; } private void FastAnimScript_KeyDown(object sender, GTA.KeyEventArgs e) { if (e.Key == Keys.Add) { Native.Function.Call("SET_CHAR_ALL_ANIMS_SPEED", Player.Character, 2.0); } if (e.Key == Keys.Y) { Native.Function.Call("SET_CHAR_ALL_ANIMS_SPEED", Player.Character, 5.0); } } } Link to comment Share on other sites More sharing options...
Jitnaught Posted December 5, 2016 Share Posted December 5, 2016 (edited) Add "GTA." (without quotes) in front of your Native.Function.Call's. So that it looks like "GTA.Native.Function.Call(...);" Edited December 5, 2016 by Jitnaught Link to comment Share on other sites More sharing options...
Zolika1351 Posted December 5, 2016 Author Share Posted December 5, 2016 (edited) Thanks Edited December 5, 2016 by Zolika1351 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now