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

Sign in to follow this  
MrGTAmodsgerman

[C#| .Net]Spawn Map Object infront of a player does not work

Recommended Posts

MrGTAmodsgerman

Hello,

 

I just have problems with the arguments

Ped Player = Game.Player.Character;GTA.Math.Vector3 spawnlocation = Player.Position + (Player.ForwardVector * 5);{string model_name = "hei_5";Object MapObject = GTA.Native.Function.Call(GTA.Native.Hash.CREATE_OBJECT, model_name, spawnlocation, spawnlocation, spawnlocation, true, true, true);

(I just edit the Code for make it more understandable)

I just already try spawnlocation.x y... but it does nothing in the Game.

So what is the problem?

 

Thanks

 

MrGTAmodsgerman

Share this post


Link to post
Share on other sites
Jitnaught

Why not just use the ScriptHookV .NET built-in function?

Ped player = Game.Player.Character;Prop worledObj = World.CreateProp(new Model("hei_5"), player.Position + player.ForwardVector * 5, true, false);

Also, you shouldn't set your variable names to the same names as classes, as it is bad practice. When the casing of the variable is different than the class's, then it's better, but really it should be renamed to something else.

 

Edit:

I should probably tell you what was wrong with your code though.

  1. For the model, you can't input a string ("hei_5"). You need to input a hash. With the SHV.NET functions you can input a string as it is converted automatically. To convert the string to a hash you need to use the GET_HASH_KEY native function.
  2. "spawnlocation, spawnlocation, spawnlocation" should be "spawnlocation.X, spawnlocation.Y, spawnlocation.Z"
Edited by LetsPlayOrDy

Share this post


Link to post
Share on other sites
darthbollo

Have you requested the object model?

Edited by darthbollo

Share this post


Link to post
Share on other sites
MrGTAmodsgerman

Have you requested the object model?

No? I dont find any Hash for it

 

 

 

Why not just use the ScriptHookV .NET built-in function?

Ped player = Game.Player.Character;Prop worledObj = World.CreateProp(new Model("hei_5"), player.Position + player.ForwardVector * 5, true, false);

Also, you shouldn't set your variable names to the same names as classes, as it is bad practice. When the casing of the variable is different than the class's, then it's better, but really it should be renamed to something else.

 

Edit:

I should probably tell you what was wrong with your code though.

  1. For the model, you can't input a string ("hei_5"). You need to input a hash. With the SHV.NET functions you can input a string as it is converted automatically. To convert the string to a hash you need to use the GET_HASH_KEY native function.
  2. "spawnlocation, spawnlocation, spawnlocation" should be "spawnlocation.X, spawnlocation.Y, spawnlocation.Z"

 

Thanks! So please could you send me a list with all Hash Codes?

 

Share this post


Link to post
Share on other sites
Jitnaught

To convert the string to a hash you need to use the GET_HASH_KEY native function.

I can't find a list that contains your "hei_5" model. Edited by LetsPlayOrDy

Share this post


Link to post
Share on other sites
MrGTAmodsgerman

 

To convert the string to a hash you need to use the GET_HASH_KEY native function.

I can't find a list that contains your "hei_5" model.

 

Thanks, but i edit the script here it isnt that model from this Thread here, i edit it for secruity reasons. So the GET HASH KEY function need a value

@LetsPlayOrDy

EDIT: I found the Hash by this Site. 1.So can i use the Hash as String?

2. And how i can attach this Model without any Error?

Edited by MrGTAmodsgerman

Share this post


Link to post
Share on other sites
MrGTAmodsgerman

@LetsPlayOrDy please answer, i try to spawn it like you say with/out string and nothing spawn

Share this post


Link to post
Share on other sites
Jitnaught

The CREATE_OBJECT function does not use a string, so inputting one would be useless.

You may need to request the object model first before you create the object.

P.S. Before you ask me how to do that, research first, then ask me.

Share this post


Link to post
Share on other sites
MrGTAmodsgerman

The CREATE_OBJECT function does not use a string, so inputting one would be useless.

You may need to request the object model first before you create the object.

P.S. Before you ask me how to do that, research first, then ask me.

I already search for loading a World Object,

64qdyu.png

 

So where is LOAD_OBJECT ?? @LetsPlayOrDy

 

Tell me, I just found nothing there

Edited by MrGTAmodsgerman

Share this post


Link to post
Share on other sites
Jitnaught

Search for "request" not "load."

Edited by LetsPlayOrDy

Share this post


Link to post
Share on other sites
MrGTAmodsgerman

Search for "request" not "load."

I try it, nothing found

Share this post


Link to post
Share on other sites
Jitnaught

REQUEST_MODEL?

Share this post


Link to post
Share on other sites
Prof_Farnsworth

EDIT: Here is how I spawn an object using the string:

new Model("prop_patio_lounger_3").Request();while (!new Model("prop_patio_lounger_3").IsLoaded) Wait(10);                testobject = World.CreateProp(new Model("prop_patio_lounger_3"), playerped.GetOffsetInWorldCoords(new Vector3(5f, 0f, 0f)), false, true);

There are a lot of ways to go about this, but hopefully this works for you.

Edited by Prof_Farnsworth

Share this post


Link to post
Share on other sites
MrGTAmodsgerman

EDIT: Here is how I spawn an object using the string:

new Model("prop_patio_lounger_3").Request();while (!new Model("prop_patio_lounger_3").IsLoaded) Wait(10);                testobject = World.CreateProp(new Model("prop_patio_lounger_3"), playerped.GetOffsetInWorldCoords(new Vector3(5f, 0f, 0f)), false, true);

There are a lot of ways to go about this, but hopefully this works for you.

Thanks, seems legit :lol: but i dont know why but he says testobject doesnt exist in the context, huh?? I try many thinks so he dont want to accept the own model name

 

@LetsPlayOrDy

Sorry buddy but he did found nothing

 

Edited by MrGTAmodsgerman

Share this post


Link to post
Share on other sites
Prof_Farnsworth

 

EDIT: Here is how I spawn an object using the string:

new Model("prop_patio_lounger_3").Request();while (!new Model("prop_patio_lounger_3").IsLoaded) Wait(10);                testobject = World.CreateProp(new Model("prop_patio_lounger_3"), playerped.GetOffsetInWorldCoords(new Vector3(5f, 0f, 0f)), false, true);

There are a lot of ways to go about this, but hopefully this works for you.

Thanks, seems legit :lol: but i dont know why but he says testobject doesnt exist in the context, huh?? I try many thinks so he dont want to accept the own model name

 

@LetsPlayOrDy

Sorry buddy but he did found nothing

 

 

"testobject" is just a variable I create using "GTA.Prop testobject". It is then assigned the value of "World.CreateProp". It could be anything you want, but you need to define it first. This should also work:

new Model("prop_patio_lounger_3").Request();while (!new Model("prop_patio_lounger_3").IsLoaded) Wait(10);               new GTA.Prop testobject = World.CreateProp(new Model("prop_patio_lounger_3"), playerped.GetOffsetInWorldCoords(new Vector3(5f, 0f, 0f)), false, true);

However doing this defines it locally so you cannot use it in other methods as is, only the one it is created in.

Share this post


Link to post
Share on other sites
MrGTAmodsgerman

 

 

EDIT: Here is how I spawn an object using the string:

new Model("prop_patio_lounger_3").Request();while (!new Model("prop_patio_lounger_3").IsLoaded) Wait(10);                testobject = World.CreateProp(new Model("prop_patio_lounger_3"), playerped.GetOffsetInWorldCoords(new Vector3(5f, 0f, 0f)), false, true);

There are a lot of ways to go about this, but hopefully this works for you.

Thanks, seems legit :lol: but i dont know why but he says testobject doesnt exist in the context, huh?? I try many thinks so he dont want to accept the own model name

 

@LetsPlayOrDy

Sorry buddy but he did found nothing

 

 

"testobject" is just a variable I create using "GTA.Prop testobject". It is then assigned the value of "World.CreateProp". It could be anything you want, but you need to define it first. This should also work:

new Model("prop_patio_lounger_3").Request();while (!new Model("prop_patio_lounger_3").IsLoaded) Wait(10);               new GTA.Prop testobject = World.CreateProp(new Model("prop_patio_lounger_3"), playerped.GetOffsetInWorldCoords(new Vector3(5f, 0f, 0f)), false, true);

However doing this defines it locally so you cannot use it in other methods as is, only the one it is created in.

Thanks, if i remove "new" from GTA.Prob, then i get no errors, its that possible that does work with? @Prof_Farnsworth

 

EDIT: Nope, i test it nothing

Edited by MrGTAmodsgerman

Share this post


Link to post
Share on other sites
Prof_Farnsworth

Should work, however I cannot test it right now. If you define it in your constructor as I did in the first post, it will work.

Share this post


Link to post
Share on other sites
MrGTAmodsgerman

Should work, however I cannot test it right now. If you define it in your constructor as I did in the first post, it will work.

@Prof_Farnsworth

Thanks, but i define it seems ok but it dont work, he dont want to accept the own new name. So i script in DotNet, is this code for it?

Or did i need to create a new constructor? I am new in C# i also work with Lua, Cleo but i dont get it sorry, Code seems right but he dont want it. I am too stupid for it :blink:

 

Edit: I think i understand it now i will test it

Edited by MrGTAmodsgerman

Share this post


Link to post
Share on other sites
Prof_Farnsworth

What do you mean by it won't accept new name? Which name?

 

Can you post some code here?

Share this post


Link to post
Share on other sites
MrGTAmodsgerman

What do you mean by it won't accept new name? Which name?

 

Can you post some code here?

Your code works now but my Model not, my Model is a Map Model like a little House your Model is a dynamic Prob, how i can change it? @Prof_Farnsworth

 

Ps: How do you find it out?

Edited by MrGTAmodsgerman

Share this post


Link to post
Share on other sites
Prof_Farnsworth

Ahh, I am not sure if this will work for static models like houses and buildings, they may need to be loaded another way (IPL?)

 

How do I find what out?

Share this post


Link to post
Share on other sites
MrGTAmodsgerman
How do I find what out?

The function and all that, i didnt found it in the native DB

 

 

Ahh, I am not sure if this will work for static models like houses and buildings, they may need to be loaded another way (IPL?)

For example, if i want to spawn a TV or something, sometimes it works but not on all Objects, I can spawn Trevors TV but not the TV from GTA Online or the Radio of Michael, i dont know why. So i can spawn the door of the little house that i want to spawn. So i need to load the IPL? I want to attach the Object, thats important.

I never thought that will be a so big problem to spawn the model. :blink:

Share this post


Link to post
Share on other sites
Jitnaught

The ScriptHookV .NET functions aren't documented on NativeDB. The natives they call are though. You can look through the ScriptHookV .NET source code here.

Edited by LetsPlayOrDy

Share this post


Link to post
Share on other sites
Prof_Farnsworth

 

How do I find what out?

The function and all that, i didnt found it in the native DB

 

 

Ahh, I am not sure if this will work for static models like houses and buildings, they may need to be loaded another way (IPL?)

For example, if i want to spawn a TV or something, sometimes it works but not on all Objects, I can spawn Trevors TV but not the TV from GTA Online or the Radio of Michael, i dont know why. So i can spawn the door of the little house that i want to spawn. So i need to load the IPL? I want to attach the Object, thats important.

I never thought that will be a so big problem to spawn the model. :blink:

 

I usually search through the natives and then see if anything has been wrapped in the .net hook. I also go through the game scripts to see how they did some things. Some objects behave differently and I am not sure why. For example, I can detect if I am next to most payphones, except for one type. It is like that with other objects as well, and I haven't figured it out yet.

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.

Sign in to follow this  

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