Quantcast

Jump to content

» «
Photo

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

18 replies to this topic
Rugz007
  • Rugz007

    Scripters ... roll out !

  • Members
  • Joined: 19 Apr 2014
  • India

#1

Posted 02 May 2014 - 03:49 AM

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 ?


Rugz007
  • Rugz007

    Scripters ... roll out !

  • Members
  • Joined: 19 Apr 2014
  • India

#2

Posted 02 May 2014 - 04:36 AM

Sorry BurgerShot


stef538
  • stef538

    It's just me, going 88 MPH.

  • Members
  • Joined: 06 Oct 2012
  • Netherlands

#3

Posted 02 May 2014 - 09:05 AM Edited by stef538, 02 May 2014 - 09:53 AM.

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


Wiebrendh
  • Wiebrendh

    C# Programmer

  • Members
  • Joined: 22 Mar 2014
  • Netherlands

#4

Posted 02 May 2014 - 09:10 AM

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


stef538
  • stef538

    It's just me, going 88 MPH.

  • Members
  • Joined: 06 Oct 2012
  • Netherlands

#5

Posted 02 May 2014 - 09:53 AM Edited by stef538, 02 May 2014 - 01:07 PM.

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


LordOfTheBongs
  • LordOfTheBongs

    Deceased

  • Members
  • Joined: 21 Sep 2013
  • None

#6

Posted 02 May 2014 - 02:21 PM Edited by LordOfTheBongs, 02 May 2014 - 02:29 PM.

@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...nd-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.microsof...y/ff926074.aspx


stef538
  • stef538

    It's just me, going 88 MPH.

  • Members
  • Joined: 06 Oct 2012
  • Netherlands

#7

Posted 02 May 2014 - 02:26 PM

oh, thanks!!


LordOfTheBongs
  • LordOfTheBongs

    Deceased

  • Members
  • Joined: 21 Sep 2013
  • None

#8

Posted 02 May 2014 - 02:47 PM Edited by LordOfTheBongs, 02 May 2014 - 02:51 PM.

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)

  • Wiebrendh likes this

LordOfTheBongs
  • LordOfTheBongs

    Deceased

  • Members
  • Joined: 21 Sep 2013
  • None

#9

Posted 02 May 2014 - 03:15 PM Edited by LordOfTheBongs, 02 May 2014 - 03:16 PM.

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...e-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


LordOfTheBongs
  • LordOfTheBongs

    Deceased

  • Members
  • Joined: 21 Sep 2013
  • None

#10

Posted 02 May 2014 - 03:33 PM Edited by LordOfTheBongs, 02 May 2014 - 05:06 PM.

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
  • Wiebrendh likes this

pedro2555
  • pedro2555

    Open Sourcer

  • Members
  • Joined: 02 Sep 2012
  • Portugal

#11

Posted 02 May 2014 - 08:18 PM Edited by pedro2555, 02 May 2014 - 08:41 PM.

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/do...z?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.codeproje...dio-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.

  • leftas likes this

LordOfTheBongs
  • LordOfTheBongs

    Deceased

  • Members
  • Joined: 21 Sep 2013
  • None

#12

Posted 02 May 2014 - 08:37 PM Edited by LordOfTheBongs, 02 May 2014 - 08:41 PM.

 

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.


Wiebrendh
  • Wiebrendh

    C# Programmer

  • Members
  • Joined: 22 Mar 2014
  • Netherlands

#13

Posted 02 May 2014 - 08:52 PM

   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?


pedro2555
  • pedro2555

    Open Sourcer

  • Members
  • Joined: 02 Sep 2012
  • Portugal

#14

Posted 02 May 2014 - 09:00 PM Edited by pedro2555, 02 May 2014 - 08:59 PM.

 

 

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.


Wiebrendh
  • Wiebrendh

    C# Programmer

  • Members
  • Joined: 22 Mar 2014
  • Netherlands

#15

Posted 02 May 2014 - 09:06 PM Edited by Wiebrendh, 02 May 2014 - 09:08 PM.

 

 

 

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..


LordOfTheBongs
  • LordOfTheBongs

    Deceased

  • Members
  • Joined: 21 Sep 2013
  • None

#16

Posted 02 May 2014 - 09:25 PM

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 


LordOfTheBongs
  • LordOfTheBongs

    Deceased

  • Members
  • Joined: 21 Sep 2013
  • None

#17

Posted 02 May 2014 - 09:32 PM Edited by LordOfTheBongs, 02 May 2014 - 09:33 PM.

 

 

 

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.gtamoddin...D_CHAR_IN_FRONT

http://www.gtamoddin...HAR_FACING_CHAR

 

unfortunately these natives were not wrapped in the scripthookdotnet

  • pedro2555 likes this

stef538
  • stef538

    It's just me, going 88 MPH.

  • Members
  • Joined: 06 Oct 2012
  • Netherlands

#18

Posted 04 May 2014 - 10:34 AM Edited by stef538, 04 May 2014 - 10:34 AM.

   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


Wiebrendh
  • Wiebrendh

    C# Programmer

  • Members
  • Joined: 22 Mar 2014
  • Netherlands

#19

Posted 04 May 2014 - 11:41 AM

 

   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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users