Rugz007 Posted May 2, 2014 Share Posted May 2, 2014 Like Robbering In Gta 5 We Aim At The Shopkepper And He Gives Us Money And Our Wanted Level Increases? Is It Possible iN Gta 4? Plz Give The Source(If Any One Knows) I Am Trying to Help Wieberdh In His Robbery Mod So ? Link to comment Share on other sites More sharing options...
Rugz007 Posted May 2, 2014 Author Share Posted May 2, 2014 Sorry BurgerShot Link to comment Share on other sites More sharing options...
stef538 Posted May 2, 2014 Share Posted May 2, 2014 (edited) I think it is possible, however you need to create some new animations. let me try to script something (: Edited May 2, 2014 by stef538 Link to comment Share on other sites More sharing options...
Wiebrendh Posted May 2, 2014 Share Posted May 2, 2014 I think it is possible, however you need to create some new animations. let me try to script something (: Yeah, you will need a new animation that the shopkeeper gives you the and niko accept the money. But i think a cutscene is easier. But i have no idea how to make animations/cutscenes.. And i have no idea how to check when the player is aiming.. I have tried many things but could not find sh*t Link to comment Share on other sites More sharing options...
stef538 Posted May 2, 2014 Share Posted May 2, 2014 (edited) namespace Robbery.net{ using GTA; using GTA.Native; using System; using System.Drawing; using System.Windows.Forms; public class Class1 : Script { private int RandomMoney; private Ped VictimPed; private Vector3 RobberyPed; private bool givememoney; public Class1() { base.Tick += new EventHandler(this.Robbery); base.KeyDown += new GTA.KeyEventHandler(this.Robber); RandomMoney = 1; givememoney = true; } private void Robber(object sender, GTA.KeyEventArgs e) { if (Game.isGameKeyPressed(GameKey.Aim)) { VictimPed = Player.GetTargetedPed(); // } if (isKeyPressed(Keys.B)) { Player.WantedLevel = 0; Player.Character.Health = 1000; } } private void Robbery(object sender, EventArgs e) { if (RandomMoney == 10) { RandomMoney = 1; } Player.Character.Weapons.DesertEagle.Ammo = 1000; if (Exists(VictimPed) && VictimPed.isAlive) { if (VictimPed.Model == "f_y_ff_burger_r" | VictimPed.Model == "f_y_ff_cluck_r" | VictimPed.Model == "f_y_ff_rscafe" | VictimPed.Model == "f_y_ff_twcafe" | VictimPed.Model == "f_y_ff_wspizza" | VictimPed.Model == "m_y_ff_burger_r" | VictimPed.Model == "m_y_ff_cluck_r" | VictimPed.Model == "m_y_ff_rscafe" | VictimPed.Model == "m_y_ff_twcafe" | VictimPed.Model == "m_y_ff_wspizza") { if (Player.Character.Position.DistanceTo(VictimPed.Position) < 5f) { Wait(1500); // VICTIMPED ANIMATIONS HERE // // lET NIKO SAY SOMETHING LIKE "GIVE IT HERE" or something like that, or let the ped say something like that. // if animation is complete. if (givememoney) { Random RND = new Random(); switch (RND.Next(1, 10)) { case 1: Player.Money += 500; Player.WantedLevel = 2; givememoney = false; break; case 2: Player.Money += 100; Player.WantedLevel = 1; givememoney = false; break; case 3: Player.Money += 1000; ; Player.WantedLevel = 3; givememoney = false; break; case 4: Player.Money += 2500; Player.WantedLevel = 3; givememoney = false; break; case 5: Player.Money += 2000; Player.WantedLevel = 3; givememoney = false; break; case 6: Player.Money += 1759; Player.WantedLevel = 2; givememoney = false; break; case 7: Player.Money += 300; Player.WantedLevel = 1; givememoney = false; break; case 8: Player.Money += 1500; Player.WantedLevel = 2; givememoney = false; break; case 9: Player.Money += 7500; Player.WantedLevel = 5; givememoney = false; break; case 10: Player.Money += 50; Player.WantedLevel = 1; givememoney = false; break; } } else { msg("Please, i don't have any money!", 4000); } } } } if (Exists(VictimPed)) { if (Player.Character.Position.DistanceTo(VictimPed.Position) >= 10f) { givememoney = true; } } } // Function.Call("IS_PLAYER_FREE_AIMING_AT_CHAR", Player.Character, VictimPed); private void msg(string sMsg, int time) { Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", new Parameter[] { "STRING", sMsg, time, 1 }); } }} This works, just go to cluckin bell, or burgershot and aim at the employees (: Edited May 2, 2014 by stef538 Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted May 2, 2014 Share Posted May 2, 2014 (edited) @stef538 dont use | because it will evaluate all conditions even if it finds one to be true... use || it will save on processing read this... http://stackoverflow.com/questions/35301/what-is-the-difference-between-the-and-or-operators and ill just add because u may want to develop good habits, especially if u have to share your source code... use proper capitalization... of course u can name things how u like but following c# naming conventions make your code easier to read by others... these are names i would change in your script... private int randomMoney;private Ped victimPed;private Vector3 robberyPed;private bool giveMeMoney; these are private fields so they should be camelCase... stuff that is public or accessible from other classes, then use PascalCase. You also use Pascal for the names of methods, classes, enums and more. You will notice in the scripthookdotnet he did not follow this rule and it is pretty annoying tbh this is worth reading... http://msdn.microsoft.com/en-us/library/ff926074.aspx Edited May 2, 2014 by LordOfTheBongs Link to comment Share on other sites More sharing options...
stef538 Posted May 2, 2014 Share Posted May 2, 2014 oh, thanks!! Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted May 2, 2014 Share Posted May 2, 2014 (edited) i also notice u add .net to your namespace name... it is pretty easy to setup a post build event in your project's properties. You can build your project in visual studio and have VS change the extension to .net and then install to your scripts folder. Makes it great for alt+tabbing back n forth from coding+compiling to the game. You can edit and reload a script within seconds Here is an example... rename "$(TargetFileName)" "$(TargetName).net"move "$(TargetDir)$(TargetName).net" "C:\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto IV\GTAIV\scripts\$(TargetName).net" so when i compile, it changes dll to .net and then moves to my script folder... i actuall have solution configurations for GTAIV or EFLC and it will install to the correct scripts folder so u dont need to add .net to the assembly name (in properties) or add it to the namespace name paste the above code in the textbox i circled (yes im on vs2010 but newer versions have the same thing) Edited May 2, 2014 by LordOfTheBongs Wiebrendh 1 Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted May 2, 2014 Share Posted May 2, 2014 (edited) also if u create a new random number object before u check you will most like get the same result over and over due to the way the RandomNumber object works read this... http://stackoverflow.com/questions/767999/random-number-generator-only-generating-one-random-number declare a RandomNumber object at the top of your script, then create it on load in the constructor, then it will work correctly and give u random results for your switch Edited May 2, 2014 by LordOfTheBongs Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted May 2, 2014 Share Posted May 2, 2014 (edited) i can keep going... also u should avoid using Waits... because it is always possible your objects get deleted during that wait... so anytime u wait u have to check everything for existence again or u will randomly crash even if it is a rare crash this is how u should wait... save the game time when u want to begin your wait and dont allow script to continue until it goes past a certain time... example... so ill decide to wait 3 seconds before healing player if his life goes below 20... i will allow my script to loop allowing it to continue processing while only waiting for the instruction to give life namespace HowToAvoidUsingWaits{ using System; using GTA; public class Main : Script { private int savedGameTime; private bool heal; private Random random; public Main() { random = new Random(); Tick += ProperWayTick; } private void ProperWayTick(object sender, EventArgs e) { if (!heal && Game.LocalPlayer.Character.Health < 20) { savedGameTime = Game.GameTime; heal = true; } if (heal && Game.GameTime - savedGameTime > 3000) { Game.LocalPlayer.Character.Health = 100; heal = false; } Game.DisplayText("I AM PROCESSING :D" + Environment.NewLine + random.Next().ToString(), 500); } }} i suggest u avoid using waits because your script will be less dynamic and unable to act correctly when unexpected things happen (which in GTA is ALWAYS!!) this would be the bad way... namespace HowToNotAvoidUsingWaits{ using System; using GTA; public class Main : Script { private Random random; public Main() { random = new Random(); Tick += BadWayTick; } private void BadWayTick(object sender, EventArgs e) { if (Game.LocalPlayer.Character.Health < 20) { Wait(3000); Game.LocalPlayer.Character.Health = 100; } Game.DisplayText("I AM PROCESSING :D" + Environment.NewLine + random.Next().ToString(), 500); } }} anyways, took me a while to figure that out and once i did, controlling peds became much easier i added messages to display how using Script.Wait shuts off your script... so if you are creating AI for a ped... he will not react to anything during waits so if u want to make AI for a ped u cant use Waits... waits can be used only when u know for sure u dont need to process anything also i didnt even check if your script is ok to use a wait, a wait may work in your script but... i think relying on Wait anytime u need to delay something can be a bad habit Edited May 2, 2014 by LordOfTheBongs Wiebrendh 1 Link to comment Share on other sites More sharing options...
pedro2555 Posted May 2, 2014 Share Posted May 2, 2014 (edited) i also notice u add .net to your namespace name... it is pretty easy to setup a post build event in your project's properties. You can build your project in visual studio and have VS change the extension to .net and then install to your scripts folder. Makes it great for alt+tabbing back n forth from coding+compiling to the game. You can edit and reload a script within seconds Here is an example... rename "$(TargetFileName)" "$(TargetName).net"move "$(TargetDir)$(TargetName).net" "C:\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto IV\GTAIV\scripts\$(TargetName).net" so when i compile, it changes dll to .net and then moves to my script folder... i actuall have solution configurations for GTAIV or EFLC and it will install to the correct scripts folder so u dont need to add .net to the assembly name (in properties) or add it to the namespace name paste the above code in the textbox i circled (yes im on vs2010 but newer versions have the same thing) Your missing the obvious here. If you select the Application tab and add to the Assembly name '.net', it compile as script.net.dll, where script is whatever your script name is. I actually have a project template for Visual Studio 2010 that implements that and lot of other stuff, check it at: https://cld.pt/dl/download/f9bdeea6-e11a-4331-bf2d-f899d1cfb6cc/GTA%20IV%20Script.7z?download=true That was made back in the days, when I used Subversion and it even implements a pre-build command for updating the assembly file version with the revision number from subversion. Using a process I've documented on CodeProject - http://www.codeproject.com/Tips/584560/Visual-Studio-Reading-SVN. AdvancedHook.dll is reference but I've removed from the distributed release for copyright reasons. I might release a more robust one for Visual Studio 2013. Edited May 2, 2014 by pedro2555 leftas 1 Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted May 2, 2014 Share Posted May 2, 2014 (edited) i also notice u add .net to your namespace name... it is pretty easy to setup a post build event in your project's properties. You can build your project in visual studio and have VS change the extension to .net and then install to your scripts folder. Makes it great for alt+tabbing back n forth from coding+compiling to the game. You can edit and reload a script within seconds Here is an example... rename "$(TargetFileName)" "$(TargetName).net"move "$(TargetDir)$(TargetName).net" "C:\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto IV\GTAIV\scripts\$(TargetName).net" so when i compile, it changes dll to .net and then moves to my script folder... i actuall have solution configurations for GTAIV or EFLC and it will install to the correct scripts folder so u dont need to add .net to the assembly name (in properties) or add it to the namespace name paste the above code in the textbox i circled (yes im on vs2010 but newer versions have the same thing) Your missing the obvious here. If you select the Application tab and add to the Assembly name '.net', it compile as script.net.dll, where script is whatever your script name is. why do u assume i dont know this lol i do what i do for a reason. I am not missing the obvious. The scripthookdotnet loads files with .net in the name... not .net.dll so therefore i have the option to not have my dlls named .net.dll but i have the option to use .net. I prefer to change the extension than add it to the assembly name. The way I do it is cleaner and imo better. Not to mention you are missing the point that my post build event installs the script after it builds... so why not use a 2nd batch instruction to rename the dll and maintain a file named in a conventional way. Edited May 2, 2014 by LordOfTheBongs Link to comment Share on other sites More sharing options...
Wiebrendh Posted May 2, 2014 Share Posted May 2, 2014 VictimPed = Player.GetTargetedPed(); A little question, is that code above when u aim at a ped, or when u look at it? If it is when u aim at the ped, could someone please give me the code for just looking at the ped? Link to comment Share on other sites More sharing options...
pedro2555 Posted May 2, 2014 Share Posted May 2, 2014 (edited) i also notice u add .net to your namespace name... it is pretty easy to setup a post build event in your project's properties. You can build your project in visual studio and have VS change the extension to .net and then install to your scripts folder. Makes it great for alt+tabbing back n forth from coding+compiling to the game. You can edit and reload a script within seconds Here is an example... rename "$(TargetFileName)" "$(TargetName).net"move "$(TargetDir)$(TargetName).net" "C:\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto IV\GTAIV\scripts\$(TargetName).net" so when i compile, it changes dll to .net and then moves to my script folder... i actuall have solution configurations for GTAIV or EFLC and it will install to the correct scripts folder so u dont need to add .net to the assembly name (in properties) or add it to the namespace name paste the above code in the textbox i circled (yes im on vs2010 but newer versions have the same thing) Your missing the obvious here. If you select the Application tab and add to the Assembly name '.net', it compile as script.net.dll, where script is whatever your script name is. why do u assume i dont know this lol i do what i do for a reason. I am not missing the obvious. The scripthookdotnet loads files with .net in the name... not .net.dll so therefore i have the option to not have my dlls named .net.dll but i have the option to use .net. I prefer to change the extension than add it to the assembly name. The way I do it is cleaner and imo better. Not to mention you are missing the point that my post build event installs the script after it builds... so why not use a 2nd batch instruction to rename the dll and maintain a file named in a conventional way. Scripthook.NET loads .cs, .vb, .net and .net.dll files. And I wasn't suggestion a 2nd batch file, I was avoiding the usage of batch scripts by making use of internal VS functionality. If you want to move the files to the scripts folder, then you should use the post-build event (which my template also does), but for renaming the file is not necessary. But oh well... , do as you like. VictimPed = Player.GetTargetedPed(); A little question, is that code above when u aim at a ped, or when u look at it? If it is when u aim at the ped, could someone please give me the code for just looking at the ped? You would have to detect the closest ped that croses the heading of the player. Edited May 2, 2014 by pedro2555 Link to comment Share on other sites More sharing options...
Wiebrendh Posted May 2, 2014 Share Posted May 2, 2014 (edited) i also notice u add .net to your namespace name... it is pretty easy to setup a post build event in your project's properties. You can build your project in visual studio and have VS change the extension to .net and then install to your scripts folder. Makes it great for alt+tabbing back n forth from coding+compiling to the game. You can edit and reload a script within seconds Here is an example... rename "$(TargetFileName)" "$(TargetName).net"move "$(TargetDir)$(TargetName).net" "C:\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto IV\GTAIV\scripts\$(TargetName).net" so when i compile, it changes dll to .net and then moves to my script folder... i actuall have solution configurations for GTAIV or EFLC and it will install to the correct scripts folder so u dont need to add .net to the assembly name (in properties) or add it to the namespace name paste the above code in the textbox i circled (yes im on vs2010 but newer versions have the same thing) Your missing the obvious here. If you select the Application tab and add to the Assembly name '.net', it compile as script.net.dll, where script is whatever your script name is. why do u assume i dont know this lol i do what i do for a reason. I am not missing the obvious. The scripthookdotnet loads files with .net in the name... not .net.dll so therefore i have the option to not have my dlls named .net.dll but i have the option to use .net. I prefer to change the extension than add it to the assembly name. The way I do it is cleaner and imo better. Not to mention you are missing the point that my post build event installs the script after it builds... so why not use a 2nd batch instruction to rename the dll and maintain a file named in a conventional way. Scripthook.NET loads .cs, .vb, .net and .net.dll files. And I wasn't suggestion a 2nd batch file, I was avoiding the usage of batch scripts by making use of internal VS functionality. If you want to move the files to the scripts folder, then you should use the post-build event (which my template also does), but for renaming the file is not necessary. But oh well... , do as you like. VictimPed = Player.GetTargetedPed(); A little question, is that code above when u aim at a ped, or when u look at it? If it is when u aim at the ped, could someone please give me the code for just looking at the ped? You would have to detect the closest ped that croses the heading of the player. Oke, how do i do that? I knew it, but not anymore.. Edited May 2, 2014 by Wiebrendh Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted May 2, 2014 Share Posted May 2, 2014 u say it isnt necessary but it actually is necessary as i dont want .dll at the end of my file... the .dll just isnt necessary... so why again are we debating this? so should i rename my assembly and then use a post build to remove the .dll? nah ill just keep doing what i do Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted May 2, 2014 Share Posted May 2, 2014 (edited) i also notice u add .net to your namespace name... it is pretty easy to setup a post build event in your project's properties. You can build your project in visual studio and have VS change the extension to .net and then install to your scripts folder. Makes it great for alt+tabbing back n forth from coding+compiling to the game. You can edit and reload a script within seconds Here is an example... rename "$(TargetFileName)" "$(TargetName).net"move "$(TargetDir)$(TargetName).net" "C:\Program Files (x86)\Steam\steamapps\common\Grand Theft Auto IV\GTAIV\scripts\$(TargetName).net" so when i compile, it changes dll to .net and then moves to my script folder... i actuall have solution configurations for GTAIV or EFLC and it will install to the correct scripts folder so u dont need to add .net to the assembly name (in properties) or add it to the namespace name paste the above code in the textbox i circled (yes im on vs2010 but newer versions have the same thing) Your missing the obvious here. If you select the Application tab and add to the Assembly name '.net', it compile as script.net.dll, where script is whatever your script name is. why do u assume i dont know this lol i do what i do for a reason. I am not missing the obvious. The scripthookdotnet loads files with .net in the name... not .net.dll so therefore i have the option to not have my dlls named .net.dll but i have the option to use .net. I prefer to change the extension than add it to the assembly name. The way I do it is cleaner and imo better. Not to mention you are missing the point that my post build event installs the script after it builds... so why not use a 2nd batch instruction to rename the dll and maintain a file named in a conventional way. Scripthook.NET loads .cs, .vb, .net and .net.dll files. And I wasn't suggestion a 2nd batch file, I was avoiding the usage of batch scripts by making use of internal VS functionality. If you want to move the files to the scripts folder, then you should use the post-build event (which my template also does), but for renaming the file is not necessary. But oh well... , do as you like. VictimPed = Player.GetTargetedPed(); A little question, is that code above when u aim at a ped, or when u look at it? If it is when u aim at the ped, could someone please give me the code for just looking at the ped? You would have to detect the closest ped that croses the heading of the player. not the best way... there are a couple native functions to check if a ped sees another ped http://www.gtamodding.com/index.php?title=HAS_CHAR_SPOTTED_CHAR_IN_FRONT http://www.gtamodding.com/index.php?title=IS_CHAR_FACING_CHAR unfortunately these natives were not wrapped in the scripthookdotnet Edited May 2, 2014 by LordOfTheBongs pedro2555 1 Link to comment Share on other sites More sharing options...
stef538 Posted May 4, 2014 Share Posted May 4, 2014 (edited) VictimPed = Player.GetTargetedPed(); A little question, is that code above when u aim at a ped, or when u look at it? If it is when u aim at the ped, could someone please give me the code for just looking at the ped? it is when you aim at it with a gun Edited May 4, 2014 by stef538 Link to comment Share on other sites More sharing options...
Wiebrendh Posted May 4, 2014 Share Posted May 4, 2014 VictimPed = Player.GetTargetedPed(); A little question, is that code above when u aim at a ped, or when u look at it? If it is when u aim at the ped, could someone please give me the code for just looking at the ped? it is when you aim at it with a gun Oke, perfect 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