Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

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

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

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

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

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

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

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. 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. 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. News

    2. Forum Support

    3. Site Suggestions

Strikewolf11

help?

Recommended Posts

Strikewolf11

hello,

 

I have just gotten into GTA coding and have knowledge of C# and have started to create a script that will allow you to become a military ped and do military jobs in the base without getting cops or being shot.

 

i have the following questions and i will provide my current code if it will help:

 

questions:

 

1. how do i hook in ScriptHookVDotNet with my asi script?

2. how do i make it so that visual studio will recognize the contexts that i currently have in my script because pretty much all of my script contexts are underlined in red and im wondering why thats happening.

 

code:

using System;using System.Windows.Forms;using GTA;public class MilitaryScript : Script{    public MilitaryScript()    {        void SET_PLAYER_MODEL(Player ;0xF2DAA2ED ;Marine01SMM)            }    void SET_DISPATCH_COPS_FOR_PLAYER(Player, false);    {            }}

if anyone can help me with this i would greately appreciate it

Share this post


Link to post
Share on other sites
CamxxCore

hello,

 

I have just gotten into GTA coding and have knowledge of C# and have started to create a script that will allow you to become a military ped and do military jobs in the base without getting cops or being shot.

 

i have the following questions and i will provide my current code if it will help:

 

questions:

 

1. how do i hook in ScriptHookVDotNet with my asi script?

2. how do i make it so that visual studio will recognize the contexts that i currently have in my script because pretty much all of my script contexts are underlined in red and im wondering why thats happening.

 

code:

using System;using System.Windows.Forms;using GTA;public class MilitaryScript : Script{    public MilitaryScript()    {        void SET_PLAYER_MODEL(Player ;0xF2DAA2ED ;Marine01SMM)            }    void SET_DISPATCH_COPS_FOR_PLAYER(Player, false);    {            }}

if anyone can help me with this i would greately appreciate it

 

Whatever this is, it isn't C# syntax... so no doubt the compiler is throwing errors..

Share this post


Link to post
Share on other sites
Strikewolf11

It has to be, because im coding in C# and using the SCRIPTHOOKVDOTNET asi file as my root hook into gta v

 

also this is the beginning of my code since its still WIP. Im still kind of new to C# coding with gta v and Scripthooknet

Edited by Strikewolf11

Share this post


Link to post
Share on other sites
Inco


var playerModel = new Model( PedHash.Marine01SMM );

if ( playerModel.Request( 1000 ) )

{

Function.Call( Hash.SET_PLAYER_MODEL, Game.Player.Handle, playerModel.Hash );

}

Share this post


Link to post
Share on other sites
CamxxCore

It has to be, because im coding in C# and using the SCRIPTHOOKVDOTNET asi file as my root hook into gta v

 

also this is the beginning of my code since its still WIP. Im still kind of new to C# coding with gta v and Scripthooknet

Well judging by what it sounds like you want to accomplish maybe you can do something similar to this:

 

using System;using GTA;using GTA.Native;public class MilitaryScript : Script{    bool nearBase = false;    public MilitaryScript()    {        this.Tick += new EventHandler(OnTick);    }    private void OnTick(object sender, EventArgs e)    {        if (Game.Player.Character.IsInRangeOf(new GTA.Math.Vector3(-2138.234f, 3250.861f, 34f)/*military base*/, 2000f))         {            if (!nearBase)            {                Function.Call(Hash.SET_DISPATCH_COPS_FOR_PLAYER, Game.Player.Handle, false);                SetModel("Marine01SMM");                nearBase = true;            }        }        else        {            if (nearBase)            {                Function.Call(Hash.SET_DISPATCH_COPS_FOR_PLAYER, Game.Player.Handle, true);                SetModel("player_zero");                nearBase = false;            }        }    }    void SetModel(Model model)    {        model.Request(1000);        Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, model.Hash);    }}
You could probably simplify it even more by toggling the cops and player model with a key bind or something. :p But you shouldn't call natives or change model in the constructor.. Edited by CamxxCore

Share this post


Link to post
Share on other sites
Strikewolf11
var playerModel = new Model( PedHash.Marine01SMM );if ( playerModel.Request( 1000 ) ){	Function.Call( Hash.SET_PLAYER_MODEL, Game.Player.Handle, playerModel.Hash );}

okay, where do i place that in there?

 

It has to be, because im coding in C# and using the SCRIPTHOOKVDOTNET asi file as my root hook into gta v

 

also this is the beginning of my code since its still WIP. Im still kind of new to C# coding with gta v and Scripthooknet

Well judging by what it sounds like you want to accomplish maybe you can do something similar to this:

 

using System;using GTA;using GTA.Native;public class MilitaryScript : Script{    bool nearBase = false;    public MilitaryScript()    {        this.Tick += new EventHandler(OnTick);    }    private void OnTick(object sender, EventArgs e)    {        if (Game.Player.Character.IsInRangeOf(new GTA.Math.Vector3(-2138.234f, 3250.861f, 34f)/*military base*/, 2000f))         {            if (!nearBase)            {                Function.Call(Hash.SET_DISPATCH_COPS_FOR_PLAYER, Game.Player.Handle, false);                SetModel("Marine01SMM");                nearBase = true;            }        }        else        {            if (nearBase)            {                Function.Call(Hash.SET_DISPATCH_COPS_FOR_PLAYER, Game.Player.Handle, true);                SetModel("player_zero");                nearBase = false;            }        }    }    void SetModel(Model model)    {        model.Request(1000);        Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, model.Hash);    }}
You could probably simplify it even more by toggling the cops and player model with a key bind or something. :p But you probably shouldnt call natives or change model in the constructor..

 

Thanks for the code i appreciate it man, also what do you mean by i probably shouldnt call natives or change model in constructor? explain please

Share this post


Link to post
Share on other sites
CamxxCore

Thanks for the code i appreciate it man, also what do you mean by i probably shouldnt call natives or change model in constructor? explain please

The constructor (MilitaryScript() in your case) is the method that will be called when the script is first loaded.. It is meant for initializing variables and other things so you don't want to be running any scripts in the constructor. It will probably be called before the game world has even loaded.

Share this post


Link to post
Share on other sites
Strikewolf11

 

Thanks for the code i appreciate it man, also what do you mean by i probably shouldnt call natives or change model in constructor? explain please

The constructor (MilitaryScript() in your case) is the method that will be called when the script is first loaded.. It is meant for initializing variables and other things so you don't want to be running any scripts in the constructor. It will probably be called before the game world has even loaded.

 

okay, so in that case how do i rectify that issue? do i just add another funtion that will nullify the loading before the game world loads or what?

Share this post


Link to post
Share on other sites
CamxxCore

okay, so in that case how do i rectify that issue? do i just add another funtion that will nullify the loading before the game world loads or what?

You can just use the tick event handler that scripthook .net provides or use key binds. In my example it will check every tick for the player position and should call the native/ change model if the player is near the military base. Mind you, I've never used that native so I don't know if it will actually disable the cops.

Share this post


Link to post
Share on other sites
Strikewolf11

 

okay, so in that case how do i rectify that issue? do i just add another funtion that will nullify the loading before the game world loads or what?

You can just use the tick event handler that scripthook .net provides or use key binds. In my example it will check every tick for the player position and should call the native/ change model if the player is near the military base. Mind you, I've never used that native so I don't know if it will actually disable the cops.

 

okay cool, I hope it will work. The things i now have to code in are:

-Military AI able to get into vehicle with you

-The ability to recruit wingmen to assist you (if in jet)

-dogfights(future version)

-Customization and model selection (future version maybe)

-Supply run drops with the titan

 

Those are some features i wanna have in the mod but idk if they are even possible yet especially the recruiting of wingmen.

 

will some of these natives work if i add them?

void TASK_PLANE_MISSION(Any p0, Any p1, Any p2, Any p3, float p4,  float p5, float p6, Any p7, float p8, float p9, float p10,  Any p11, Any p12) // 0x23703CD154E83B88 0x1D007E65void TASK_HELI_MISSION(Ped ped, Vehicle vehicle, Any p2, Any p3,  float posX, float posY, float posZ, int p7, float p8,  float p9, float p10, int p11, int p12, float p13, int p14)// 0xDAD029E187A2BEB4 0x0C143E97void TASK_HELI_CHASE(Any p0, Any p1, float p2, float p3, float p4)// 0xAC83B1DB38D0ADA0 0xAC290A21void TASK_BOAT_MISSION(Any p0, Any p1, Any p2, Any p3, float p4,  float p5, float p6, Any p7, float p8, Any p9, float p10,  Any p11) // 0x15C86013127CE63F 0x5865B031void TASK_COMBAT_PED(Ped ped, Ped targetPed, Any p2, Any p3)// 0xF166E48407BAC484 0xCB0D8932
Edited by Strikewolf11

Share this post


Link to post
Share on other sites
thewhitehammer99

IMO, I think you should start from the basics instead of creating a more difficult mod without even understanding C# syntax.

 

Some useful links for learning -

 

http://csharp.net-tutorials.com

 

 

http://www.learncs.org(Incorporated interactive code editor which is useful)

 

 

Once you understand the language a bit, try making, say a vehicle spawner or something basic :)

Share this post


Link to post
Share on other sites
Strikewolf11

IMO, I think you should start from the basics instead of creating a more difficult mod without even understanding C# syntax.

 

Some useful links for learning -

 

http://csharp.net-tutorials.com

 

 

http://www.learncs.org(Incorporated interactive code editor which is useful)

 

 

Once you understand the language a bit, try making, say a vehicle spawner or something basic :)

@White Hammer i understand the Language its just i would like to know if those natives that i found and think might work if i were to add them in the proper syntax would work within the script im creating or if they are just completely unusable.

 

Also the reason im asking all these questions is because i wanna be completely sure i dont miss anything since i am coding and i wanna know ive done something really cool with gta scripting that no one else has even thought of or wanted to do. This level of coding challenges me in a way that also helps me learn the language more then i already know.

 

But i do appreciate the links to the different areas that teach C#

Share this post


Link to post
Share on other sites
Strikewolf11

okay here is the full code i have so far.

 

i used some of the helpful code that you guys have provided for me so i give credit to you guys for that initial code

using System;using System.Windows.Forms;using GTA;using GTA.Native;public class MilitaryScript : Script{    bool nearbase = false;    public MilitaryScript()    {        this.Tick += new EventHandler(OnTick);    }    private void Ontick(object sender, EventArgs e)    {        if (Game.Player.Character.IsInRangeOf(new GTA.Math.Vector3(-2138.234f, 3250.861f, 34f)/*military base*/, 200f))        {            if (!nearbase)            {                        Function.Call(Hash.SET_DISPATCH_COPS_FOR_PLAYER, Game.Player.Handler, false);            SetModel("Marine01SMM");            nearbase = true;                        }        }    }    else     {        if (nearbase)        {            Function.Call(hash.SET_DISPATCH_COPS_FOR_PLAYER, Game.Player.Hander, true);            SetModel("player_zero");            nearbase = false;        }    }}void SetModel(Model Model){    model.request(1000);    Function.Call(Hash.Set_Player_Model, Game.Player, Model.Hash);}{if (nearbase){bool GET_CURRENT_PED_WEAPON(ped, ped, Hash *weaponhash, bool, p2)vehicle CREATE_VEHICLE(hash modelhash, float x, float y, float z, float heading, bool networkHandle, bool vehiclehandle)void SET_PED_ARMOUR(ped, ped, int 100){    model.request(1000);    Funtion.Call(hash.Vehicle Create_Vehicle(Hash 0x132D5A1A, float x, float y, float z, float heading, bool networkHandle, bool vehiclehandle)    nearbase = true;    model.request(1000);    Function.Call(hash.bool GET_CURRENT_PED_WEAPON(ped, ped, Hash *0x7FD62962, bool, 0))    nearbase = true    Function.Call(hash.void SET_PED_ARMOUR(ped, ped, int 100))    nearbase = true}void GET_CURRENT_PED_WEAPON(ped, ped, Hash *0x7FD62962, bool, p2)void Create_Vehicle(hash modelhash, float x, float y, float z, float heading, bool networkHandle, bool vehiclehandle){ped CREATE_PED(int pedtype, Hash pedhash, float x, float y, float z, float heading, bool networkHandle, bool pedHandle)bool GET_CURRENT_PED_WEAPON(ped, ped, Hash *weaponhash, bool p2)vehicle CREATE_VEHICLE(hash modelhash, float x, float y, float z, bool networkHandle, bool vehiclehandle)void SET_PED_ARMOUR(ped, ped, int 100){    model.request(1000);    Function.Call(hash.Ped Create_Ped(int 29, Hash 0xF2DAA2ED, float x, float y, float z, float heading, book networkHandle, bool pedhandle);    nearbase = true;    model.request(1000);    Function.Call(hash.void CREATE_VEHICLE(hash 0x132D5A1A, float x, float y, float z, bool networkHandle, bool vehiclehandle);    nearbase = true;    model.request(1000);    Function.Call(hash.bool GET_CURRENT_PED_WEAPON(ped, ped, Hash *weaponhash, bool p2);    nearbase = true;    Function.Call(hash.bool SET_PED_ARMOUR(ped, ped, int 100));    nearbase = true    }void CREATE_PED(int pedtype, Hash pedhash, float x, float y, float z, float heading, bool networkHandle, bool pedHandle){if (nearbase)}    Any CREATE_PED_INSIDE_VEHICLE(Vehicle vehicle, int pedtype, hash modelhash, int seat, bool createNetHandle, bool createPedHandle){    Function.Call(hash.Any CREATE_PED_INSIDE_VEHICLE(Crusader crusader, int 29, hash 0xF2AA2ED, int seat, bool createNetHandle, bool createPedHandle))    nearbase = true}void CREATE_PED_INSIDE_VEHICLE(Vehicle vehicle, int pedtype, hash modelhash, int seat, bool createNetHandle, bool createPedHandle)

Share this post


Link to post
Share on other sites
c39687

not sure if anyone answered but you need to add the scripthookvdotnet.dll to your project as a reference (right click references in solution pane->add reference->browse->select the dll)

 

Then VS will understand what you are coding and to the first reply... nm looked closer and his code is f'd in opening post

Edited by c39687

Share this post


Link to post
Share on other sites
Strikewolf11

not sure if anyone answered but you need to add the scripthookvdotnet.dll to your project as a reference (right click references in solution pane->add reference->browse->select the dll)

 

Then VS will understand what you are coding and to the first reply... nm looked closer and his code is f'd in opening post

thanks dude, i appreciate the answer it totally helped me out

Share this post


Link to post
Share on other sites
Strikewolf11

okay now i have a question about the following the code and how i could use it to make a scenario

void TASK_VEHICLE_ESCORT(Ped ped, Vehicle vehicle, Vehicle targetVehicle,  int p3, float speed, int drivingStyle, float minDistance,  int p7, float p8) // 0x0FA6E4B75F302400 0x9FDCB250

could i make it so that the AI peds do a mission with me for a vehicle or when a player is near the base that a military ai person will spawn in a vehicle and escort the player into the base?

 

if i could how would i do something like that?

Edited by Strikewolf11

Share this post


Link to post
Share on other sites
c39687

no prob

 

well yeah there is probably a specialized native for this or just tel him to drive to locations depending on where he is. And you can check with distances or something to see if player is getting away from the escort. Just make it manually if you can't figure out the native, i never used that before so not sure on the args or whatever.

Edited by c39687

Share this post


Link to post
Share on other sites
Strikewolf11

c39687 is there a way i could use the code in my last reply to create something like what i had in mind?

Share this post


Link to post
Share on other sites
Strikewolf11

no prob

 

well yeah there is probably a specialized native for this or just tel him to drive to locations depending on where he is. And you can check with distances or something to see if player is getting away from the escort. Just make it manually if you can't figure out the native, i never used that before so not sure on the args or whatever.

is there a specific way i could manually do that and if so can you show me a quick example so that i could understand how to do that?

 

or should i just combine AI Task natives and hope for the best?

Edited by Strikewolf11

Share this post


Link to post
Share on other sites
thewhitehammer99

okay now i have a question about the following the code and how i could use it to make a scenario

void TASK_VEHICLE_ESCORT(Ped ped, Vehicle vehicle, Vehicle targetVehicle,  int p3, float speed, int drivingStyle, float minDistance,  int p7, float p8) // 0x0FA6E4B75F302400 0x9FDCB250
could i make it so that the AI peds do a mission with me for a vehicle or when a player is near the base that a military ai person will spawn in a vehicle and escort the player into the base?

 

if i could how would i do something like that?

Your best bet would be to look at the decompiled game scripts, try finding how the taxi driver is coded :)

Share this post


Link to post
Share on other sites
Strikewolf11

 

okay now i have a question about the following the code and how i could use it to make a scenario

void TASK_VEHICLE_ESCORT(Ped ped, Vehicle vehicle, Vehicle targetVehicle,  int p3, float speed, int drivingStyle, float minDistance,  int p7, float p8) // 0x0FA6E4B75F302400 0x9FDCB250
could i make it so that the AI peds do a mission with me for a vehicle or when a player is near the base that a military ai person will spawn in a vehicle and escort the player into the base?

 

if i could how would i do something like that?

Your best bet would be to look at the decompiled game scripts, try finding how the taxi driver is coded :)

 

which script is that?

Share this post


Link to post
Share on other sites
Strikewolf11

okay, i need someone to help me take a look at a particular set of coding in my script and tell me if what im using to setup a event is correct or i have to use something different.

void TASK_HELI_MISSION(ped ped, vehicle vehicle, any p2, any p3, float posX, float posY, float posZ, int p7, float p8, float p9, float p10, int p11, int p12, float p13, int p14){    Function.Call(hash.TASK_HELI_MISSION(vehicle vehicle, 0, 0, posX, posY, posZ, -2138.234f, 3250.861f, 34f);    Function.Call(hash.TASK_VEHICLE_HELI_PROTECT(Any 0, 1, 2, 3, 4, 5, 6, 7));    Function.Call(hash.TASK_VEHICLE_CHASE(Marine01SMM, Marine01SMM, Marine01SMM targetEnt);    Function.Call(hash.TASK_VEHICLE_ESCORT(vehicle vehicle, vehicle targetvehicle, int 3, 40, int safe, 5, 7, 8));    Function.Call(hash.TASK_VEHICLE_FOLLOW(Any 0, 1, 2, 3, 4, 5));    nearbase = true} 
Edited by Strikewolf11

Share this post


Link to post
Share on other sites
c39687

 

no prob

 

well yeah there is probably a specialized native for this or just tel him to drive to locations depending on where he is. And you can check with distances or something to see if player is getting away from the escort. Just make it manually if you can't figure out the native, i never used that before so not sure on the args or whatever.

is there a specific way i could manually do that and if so can you show me a quick example so that i could understand how to do that?

 

or should i just combine AI Task natives and hope for the best?

 

since ur using the scripthookdotnet, use the ped class. There is a tasks property that gives access to ped tasks. One of them is GoTo i believe. So in a tick event...

 

1. Validate he needs to go somewhere (too far from player or the destination, check distance... make sure you dont constantly task him every tick, so check if he is moving or not, add a delay before taking him to move again)

2. Task Him to go to where he needs to go... If he is to follow the player then task him to go to a positin that is relative to the player... get an offset position from the player.

 

You just have to research natives and more importantly... FIRST LOOK WHAT THE SCRIPTHOOKDOTNET IS CAPABLE OF AND USE IT... dont just always resort to Function.Call and looking for natives. The scripthookdotnet author already wrapped many common natives that you will use all the time.

 

Either browse his source code and look at his classes and what they do or download ILSpy and load the scripthookdotnet dll into it and read the source code in c#

Edited by c39687

Share this post


Link to post
Share on other sites
Fireboyd78

Uhh, has anyone realized yet that this would be throwing a ton of errors in Visual Studio? This kid doesn't even know what he's doing. He's writing this stuff in Notepad for christ sake.

Share this post


Link to post
Share on other sites
Strikewolf11

Uhh, has anyone realized yet that this would be throwing a ton of errors in Visual Studio? This kid doesn't even know what he's doing. He's writing this stuff in Notepad for christ sake.

okay first off, i am writing this in visual studio FireBoyd78

second i do sort of know what im doing so dont insult me please

Share this post


Link to post
Share on other sites
Fireboyd78

If you're writing this in Visual Studio then how is your code not giving you a bunch of errors?

Share this post


Link to post
Share on other sites
Strikewolf11

If you're writing this in Visual Studio then how is your code not giving you a bunch of errors?

i dont know man, I honestly dont know.

 

it isnt giving me the error's. even though im writing this in VS Express 2013 Community Update 4

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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