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. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

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

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    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 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 Mods
    10. GTA Vice City

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

      1. Guides & Strategies
      2. Help & Support
      3. GTA 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  
boomer678

[Q] Spawning an Object Using VB scripthook

Recommended Posts

boomer678

Imports System

Imports System.Windows.Forms

Imports GTA

 

 

 

Public Class fork

Inherits Script

 

Public Sub New()

WatchKey(Keys.K)

End Sub

 

Protected Overrides Sub KeyDown(ByVal key As System.Windows.Forms.Keys)

Game.DisplayText("Crane Spawned")

Native.Function.Call("CREATE_OBJECT", "d19freightcrane", Player.Character.Position.X, Player.Character.Position.Y, Player.Character.Position.Z, 0, 1)

 

End Sub

 

End Class

 

 

^^that is my code so far.. Im trying to spawn a crane. If i use the world.createobject ( ***,***) the crane spawns but it has no collision or anything. Plz can someone help me. Maybe if i can get this to work ill make a object spawner.

 

Also when i press K it says ERROR IN SCRIPT

Share this post


Link to post
Share on other sites
Rob.Zombie

Wow release it in a trainer, where you can select some props and I'll give you a cookie. It's 1 step closer to a zombie mod. I always wanted to barricade my self biggrin.gif

Share this post


Link to post
Share on other sites
boomer678
Wow release it in a trainer, where you can select some props and I'll give you a cookie. It's 1 step closer to a zombie mod. I always wanted to barricade my self biggrin.gif

Im still trying to get it working thats why i need some help

Share this post


Link to post
Share on other sites
Marduk123

i can have the models names... lol

im not good mfor coding u know it tounge.gif

Share this post


Link to post
Share on other sites
HazardX

Hi boomer and Marduk. smile.gif There are several problems in the script.

 

1) Do not give the model name directly into the CREATE_OBJECT function. Use the HASH of the model name instead. use native function GET_HASH_KEY to get the hash of the model name.

 

2) Before you pass the hash of the model to the CREATE_OBJECT, you have to call the native REQUEST_MODEL onto the model hash, to tell the game that it should load the model into memory. then wait as long as the native HAS_MODEL_LOADED returns false, to make sure that the model really is in memory. now you can call CREATE_OBJECT.

 

3) Do not create an object directly at the players position. The object will not spawn if the area if blocked by the player.

 

And most importantly: WHY do you do all this??? There is the function World.CreateObject already, that does ALL of those things automatically for you.

Share this post


Link to post
Share on other sites
boomer678
Hi boomer and Marduk. smile.gif There are several problems in the script.

 

1) Do not give the model name directly into the CREATE_OBJECT function. Use the HASH of the model name instead. use native function GET_HASH_KEY to get the hash of the model name.

 

2) Before you pass the hash of the model to the CREATE_OBJECT, you have to call the native REQUEST_MODEL onto the model hash, to tell the game that it should load the model into memory. then wait as long as the native HAS_MODEL_LOADED returns false, to make sure that the model really is in memory. now you can call CREATE_OBJECT.

 

3) Do not create an object directly at the players position. The object will not spawn if the area if blocked by the player.

 

And most importantly: WHY do you do all this??? There is the function World.CreateObject already, that does ALL of those things automatically for you.

I tried the world.createobject ! It has no COLLISION

Share this post


Link to post
Share on other sites
HazardX
I tried the world.createobject ! It has no COLLISION

Ah sorry, missed that point. Try the following:

 

 

           Dim crane As GTA.Object = World.CreateObject("d19freightcrane", Player.Character.Position.Around(5.0F))           Native.Function.Call("SET_OBJECT_COLLISION", crane, True)

 

Share this post


Link to post
Share on other sites
boomer678
I tried the world.createobject ! It has no COLLISION

Ah sorry, missed that point. Try the following:

 

 

           Dim crane As GTA.Object = World.CreateObject("d19freightcrane", Player.Character.Position.Around(5.0F))           Native.Function.Call("SET_OBJECT_COLLISION", crane, True)

 

sweet ill try it!

Share this post


Link to post
Share on other sites
boomer678

hmm i spawned it and my player just walks through it. Im spawning a skatepark()

 

Imports System

Imports System.Windows.Forms

Imports GTA

 

 

 

Public Class fork

Inherits Script

 

Public Sub New()

WatchKey(Keys.K)

End Sub

 

Protected Overrides Sub KeyDown(ByVal key As System.Windows.Forms.Keys)

 

Dim skate As GTA.Object = World.CreateObject("skaterink02_mh11", Player.Character.Position.Around(5.0F))

Native.Function.Call("SET_OBJECT_COLLISION", skate, True)

 

 

End Sub

 

End Class

 

Share this post


Link to post
Share on other sites
HazardX

hmm... i'll figure it out. I hope to get a new version up in a few hours. i'll fix it there, unless i find no way to do so.

Share this post


Link to post
Share on other sites
vaderfet

It would be wild to spawn stuff like buildings or other very large objects.

 

You'd get into a police chase and drop a building on them.

Share this post


Link to post
Share on other sites
Marduk123
hmm... i'll figure it out. I hope to get a new version up in a few hours. i'll fix it there, unless i find no way to do so.

thanks i hope it will work smile.gif

but

HAS_COLLISION_FOR_MODEL_LOADED

?

Share this post


Link to post
Share on other sites
boomer678
hmm... i'll figure it out. I hope to get a new version up in a few hours. i'll fix it there, unless i find no way to do so.

Great, also im gonna try to release first object spawner

Share this post


Link to post
Share on other sites
boomer678

Also hazard do u got xfire so ican talk to you faster

Share this post


Link to post
Share on other sites
boomer678

i spawned a quarter pipe and it has collision with me and other peds/ cars. but with world NO. it falls throgh ground once i touch it

Share this post


Link to post
Share on other sites
HazardX

 

i spawned a quarter pipe and it has collision with me and other peds/ cars. but with world NO. it falls throgh ground once i touch it

what is the name of it?

BTW: i don't have xfire.

Share this post


Link to post
Share on other sites
boomer678

 

i spawned a quarter pipe and it has collision with me and other peds/ cars. but with world NO. it falls throgh ground once i touch it

what is the name of it?

BTW: i don't have xfire.

bm_skate_quartpipe

 

 

Imports System

Imports System.Windows.Forms

Imports GTA

 

 

 

Public Class fork

Inherits Script

 

Public Sub New()

WatchKey(Keys.K)

End Sub

 

Protected Overrides Sub KeyDown(ByVal key As System.Windows.Forms.Keys)

 

Dim skate As GTA.Object = World.CreateObject("bm_skate_quartpipe", Player.Character.Position.Around(12.0F))

Native.Function.Call("SET_OBJECT_COLLISION", skate, True)

 

 

 

End Sub

 

End Class

 

 

Edited by boomer678

Share this post


Link to post
Share on other sites
HazardX

Okay, got it now. smile.gif Use this:

 

 

       Dim skate As GTA.Object = World.CreateObject("bm_skate_quartpipe", Player.Character.Position.Around(12.0F))       Native.Function.Call("FREEZE_OBJECT_POSITION", skate, True)       Native.Function.Call("SET_OBJECT_COLLISION", skate, True)

 

Share this post


Link to post
Share on other sites
boomer678
Okay, got it now. smile.gif Use this:

 

 

       Dim skate As GTA.Object = World.CreateObject("bm_skate_quartpipe", Player.Character.Position.Around(12.0F))       Native.Function.Call("FREEZE_OBJECT_POSITION", skate, True)       Native.Function.Call("SET_OBJECT_COLLISION", skate, True)

 

Yea sweet but... Ususally when you spawn an object it isnt on the ground All the way. Like will it stay there in midair?

Share this post


Link to post
Share on other sites
boomer678
Okay, got it now. smile.gif Use this:

 

 

       Dim skate As GTA.Object = World.CreateObject("bm_skate_quartpipe", Player.Character.Position.Around(12.0F))       Native.Function.Call("FREEZE_OBJECT_POSITION", skate, True)       Native.Function.Call("SET_OBJECT_COLLISION", skate, True)

 

Yea sweet but... Ususally when you spawn an object it isnt on the ground All the way. Like will it stay there in midair?

Yea it just stays there i just tried it. Anyway to make it collied with the world instead of freezing it

Share this post


Link to post
Share on other sites
boomer678

hazard do u know a way to make objects collide with the world instead of freezing them

Share this post


Link to post
Share on other sites
HazardX
hazard do u know a way to make objects collide with the world instead of freezing them

No, but you can use "World.GetGroundPosition" to get a position on the ground. then freeze it there. no more flying. I'll release a new version soon, it'll make all this a little bit easier. wink.gif

Share this post


Link to post
Share on other sites
boomer678
hazard do u know a way to make objects collide with the world instead of freezing them

No, but you can use "World.GetGroundPosition" to get a position on the ground. then freeze it there. no more flying. I'll release a new version soon, it'll make all this a little bit easier. wink.gif

awesome thanks

Share this post


Link to post
Share on other sites
HazardX

With the new version of the .Net ScriptHook you can do this:

 

Dim o As GTA.Object = World.CreateObject("bm_skate_quartpipe", World.GetGroundPosition(Player.Character.GetOffsetPosition(New Vector3(0,5,0))))o.CurrentRoom = Player.Character.CurrentRoomo.Heading = Player.Character.Headingo.FreezePosition = True

 

 

It will spawn the ramp 5 meters/yard infront of you on the ground. This is very funny to do while driving at high speeds. ^^

 

[EDIT] In the new version you can also use this command in the console to do the same:

 

 

spawn bm_skate_quartpipe

 

Edited by HazardX

Share this post


Link to post
Share on other sites
boomer678
With the new version of the .Net ScriptHook you can do this:

 

Dim o As GTA.Object = World.CreateObject("bm_skate_quartpipe", World.GetGroundPosition(Player.Character.GetOffsetPosition(New Vector3(0,5,0))))o.CurrentRoom = Player.Character.CurrentRoomo.Heading = Player.Character.Headingo.FreezePosition = True

 

 

It will spawn the ramp 5 meters/yard infront of you on the ground. This is very funny to do while driving at high speeds. ^^

ty

Share this post


Link to post
Share on other sites
P_4_CZT1
With the new version of the .Net ScriptHook you can do this:

 

Dim o As GTA.Object = World.CreateObject("bm_skate_quartpipe", World.GetGroundPosition(Player.Character.GetOffsetPosition(New Vector3(0,5,0))))o.CurrentRoom = Player.Character.CurrentRoomo.Heading = Player.Character.Headingo.FreezePosition = True

 

 

It will spawn the ramp 5 meters/yard infront of you on the ground. This is very funny to do while driving at high speeds. ^^

 

[EDIT] In the new version you can also use this command in the console to do the same:

 

 

spawn bm_skate_quartpipe

 

How to open the console (sorry nooby)

Share this post


Link to post
Share on other sites
Intosia
With the new version of the .Net ScriptHook you can do this:

 

Dim o As GTA.Object = World.CreateObject("bm_skate_quartpipe", World.GetGroundPosition(Player.Character.GetOffsetPosition(New Vector3(0,5,0))))o.CurrentRoom = Player.Character.CurrentRoomo.Heading = Player.Character.Headingo.FreezePosition = True

 

 

It will spawn the ramp 5 meters/yard infront of you on the ground. This is very funny to do while driving at high speeds. ^^

 

[EDIT] In the new version you can also use this command in the console to do the same:

 

 

spawn bm_skate_quartpipe

 

How to open the console (sorry nooby)

Tilde (~)

Share this post


Link to post
Share on other sites
P_4_CZT1

 

With the new version of the .Net ScriptHook you can do this:

 

Dim o As GTA.Object = World.CreateObject("bm_skate_quartpipe", World.GetGroundPosition(Player.Character.GetOffsetPosition(New Vector3(0,5,0))))o.CurrentRoom = Player.Character.CurrentRoomo.Heading = Player.Character.Headingo.FreezePosition = True

 

 

It will spawn the ramp 5 meters/yard infront of you on the ground. This is very funny to do while driving at high speeds. ^^

 

[EDIT] In the new version you can also use this command in the console to do the same:

 

 

spawn bm_skate_quartpipe

 

How to open the console (sorry nooby)

Tilde (~)

 

Tnx it worked now

 

GreetZ P

Edited by P_4_CZT1

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.

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.