Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (86,304 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

Rugz007

If We Aim At The Shopkepper (server) In BurgerKing Then We Should Get

Recommended Posts

Rugz007

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 ?

Share this post


Link to post
Share on other sites
Rugz007

Sorry BurgerShot

Share this post


Link to post
Share on other sites
stef538

I think it is possible, however you need to create some new animations. let me try to script something (:

Edited by stef538

Share this post


Link to post
Share on other sites
Wiebrendh

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 :(

Share this post


Link to post
Share on other sites
stef538
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 by stef538

Share this post


Link to post
Share on other sites
LordOfTheBongs

@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 by LordOfTheBongs

Share this post


Link to post
Share on other sites
stef538

oh, thanks!!

Share this post


Link to post
Share on other sites
LordOfTheBongs

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

 

AGkJrE6.png

 

paste the above code in the textbox i circled (yes im on vs2010 but newer versions have the same thing)

Edited by LordOfTheBongs

Share this post


Link to post
Share on other sites
LordOfTheBongs

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 by LordOfTheBongs

Share this post


Link to post
Share on other sites
LordOfTheBongs

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 by LordOfTheBongs

Share this post


Link to post
Share on other sites
pedro2555

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

 

AGkJrE6.png

 

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 by pedro2555

Share this post


Link to post
Share on other sites
LordOfTheBongs

 

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

 

AGkJrE6.png

 

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 by LordOfTheBongs

Share this post


Link to post
Share on other sites
Wiebrendh

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?

Share this post


Link to post
Share on other sites
pedro2555

 

 

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

 

AGkJrE6.png

 

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 by pedro2555

Share this post


Link to post
Share on other sites
Wiebrendh

 

 

 

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

 

AGkJrE6.png

 

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 by Wiebrendh

Share this post


Link to post
Share on other sites
LordOfTheBongs

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

Share this post


Link to post
Share on other sites
LordOfTheBongs

 

 

 

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

 

AGkJrE6.png

 

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 by LordOfTheBongs

Share this post


Link to post
Share on other sites
stef538

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 by stef538

Share this post


Link to post
Share on other sites
Wiebrendh

 

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.