Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

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

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

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

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

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

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

    2. Forum Support

    3. Suggestions

C++ Script Hook


aru
 Share

Recommended Posts

 

Is there any way to find the x y z of where the player is aiming at?

Yeah im hoping for a fuction like this myself. But im afraid there isnt cryani.gif Would be so cool if there was. You could just aim where you want to spawn something, select object etc. Kinda like GMod.

Link to comment
Share on other sites

Is there any way to find the x y z of where the player is aiming at?

Yeah im hoping for a fuction like this myself. But im afraid there isnt cryani.gif Would be so cool if there was. You could just aim where you want to spawn something, select object etc. Kinda like GMod.

Exactly I have actually found GetCamPos that gives you the coords of your camera, perhaps there is some way to calculate to get it in front of the player

Link to comment
Share on other sites

 

...

How to set Object Heading?

 

Something like this?

 

static void SetObjectRotation(Object obj, f32 xRot, f32 yRot, f32 zRot) { NativeInvoke::Invoke<scriptVoid>("SET_OBJECT_ROTATION", obj, xRot, yRot, zRot); }

 

 

Peace!

Link to comment
Share on other sites

 

f32 xRot, f32 yRot, f32 zRot

 

How to use this?

what to do if i want to make the object is heading to a char?

 

How to speed up the animation of Char?

Like making the char do something in default speed but the other are slowed?

Link to comment
Share on other sites

Has anyone got SET_CAR_PROOFS to work, should be a car id and 5 bools. does nothing tho.???

Works fine in alice. Its not the only bool i have trouble with

 

nm i think it does work against explosions, just i thought it might be dent proof .

Edited by C06alt
Link to comment
Share on other sites

I don get the rotx,y,z thing, it doesnt do anything

what rot is used to change the left or right?

Edited by aceship
Link to comment
Share on other sites

just rig up 3 buttons to increment each and observe and remember the pitch roll and yaw.

I actually missed this command and ended up using Quaternion's. didn't even know there was a 4th dimension.

Edited by C06alt
Link to comment
Share on other sites

EDIT: Seems to work now...

 

Why does GTA crash when i do this: I want to spawn a obect.

 

 

f32 x,y,z; 	GetCharCoordinates(GetPlayerPed(), &x, &y, &z); 	RequestModel(MODEL_CJ_AIRCON9); 	while(!HasModelLoaded(MODEL_CJ_AIRCON9)) 	{   Wait(0); 	} 	Object tmp; 	z = z+ 40;//  	CreateObject(MODEL_CJ_AIRCON9,x,y,z, 0,true); 	CreateObject(MODEL_CJ_AIRCON9,x,y,z, &tmp,true); // <<< NEW CODE 	MarkModelAsNoLongerNeeded(MODEL_CJ_AIRCON9);

 

 

When i run the code, Niko gets lifted in the air about 1 meter, asif the object spawn under him. But before anything is visible the game crashes.

Edited by Intosia
Link to comment
Share on other sites

 

f32 x,y,z; GetCharCoordinates(GetPlayerPed(), &x, &y, &z); RequestModel(MODEL_CJ_AIRCON9); while(!HasModelLoaded(MODEL_CJ_AIRCON9)) {  Wait(0); } Object tmp; z = z+ 40; CreateObject(MODEL_CJ_AIRCON9,x,y,z,&tmp,true);<--------------- this is the problem MarkModelAsNoLongerNeeded(MODEL_CJ_AIRCON9);

 

The problem is you must make it an obj

 

Edit: How to use X rot?

Edited by aceship
Link to comment
Share on other sites

f32 x,y,z; GetCharCoordinates(GetPlayerPed(), &x, &y, &z); RequestModel(MODEL_CJ_AIRCON9); while(!HasModelLoaded(MODEL_CJ_AIRCON9)) {  Wait(0); } Object tmp; z = z+ 40; CreateObject(MODEL_CJ_AIRCON9,x,y,z,&tmp,true);<--------------- this is the problem MarkModelAsNoLongerNeeded(MODEL_CJ_AIRCON9);

 

The problem is you must make it an obj

??

 

It works like that.

Link to comment
Share on other sites

I changed it and forgot it was changed

 

How To Get the Object that we created on other script?

Edited by aceship
Link to comment
Share on other sites

Is there a way to use a definition in another part of a thread like sets say you have something like this:

 

 

 

void CustomFiberThread::RunScript(){if ((GetAsyncKeyState(VK_F5) & 1) != 0){ Object objid; CreateObject(MODEL_CJ_BOWLING_BALL3, xNew, yNew, zNew, &objid, true);}if ((GetAsyncKeyState(VK_F6) & 1) != 0){ if (IsPlayerTargettingObject(GetPlayer(), objid)) {  Do stuff here...  }}}

 

 

I could try setting it at the begining after void CustomFiberThread::RunScript() But then it would be gone after one run.

Link to comment
Share on other sites

what is your CreateObject(MODEL_CJ_BOWLING_BALL3, xNew, yNew, zNew, &objid, true); script?

Link to comment
Share on other sites

Is there a way to use a definition in another part of a thread like sets say you have something like this:

 

 

 

void CustomFiberThread::RunScript(){if ((GetAsyncKeyState(VK_F5) & 1) != 0){ Object objid; CreateObject(MODEL_CJ_BOWLING_BALL3, xNew, yNew, zNew, &objid, true);}if ((GetAsyncKeyState(VK_F6) & 1) != 0){ if (IsPlayerTargettingObject(GetPlayer(), objid)) {  Do stuff here...  }}}

 

 

I could try setting it at the begining after void CustomFiberThread::RunScript() But then it would be gone after one run.

Nevermind, I fixed it i put Object objid; above using namespace Scripting; lol. suicidal.gif

Link to comment
Share on other sites

Im asking how to create CreateObject &obj?

I cant make it

&objid will contain the id so you other functions know what object you mean. If you mean model then MODEL_CJ_BOWLING_BALL3 is predefined in ScriptEnums.h

Link to comment
Share on other sites

C++ is easy orly.gif but seriously it is, it's like GTA Programming but slightly harder.  But where do I place the files?  In the IV directory.

Any help?

You basically answered your own question, depending on the asi loader you use, you need to place the asi in the GTAIV directory, I believe Xliveless also would work from a plugins directory.

 

 

Link to comment
Share on other sites

Does passing a Vector3 as reference work? Because when i try the code below, pos.X etc are empty...

 

 

static void GetPedBonePosition(Ped ped, u32 boneid, f32 boneOffsetX, f32 boneOffsetY, f32 boneOffsetZ, Vector3 *pos) { NativeInvoke::Invoke<scriptVoid>("GET_PED_BONE_POSITION", ped, boneid, boneOffsetX, boneOffsetY, boneOffsetZ, pos); } 	Vector3 pos; 	GetPedBonePosition(GetPlayerPed(),1219, 0.0f, 0.0f, 0.0f, &pos); 	LogInfo("PLAYER POS X: %f Y: %f Z: %f", x, y, z); 	LogInfo("BONE POS X: %f Y: %f Z: %f", pos.X, pos.Y, pos.Z);

 

Link to comment
Share on other sites

not that what i meant

 

void CustomFiberThread::SpawnObject(eModel model,f32 x,f32 y,f32 z){RequestModel(model);while(!HasModelLoaded(model)){ Wait(0);}Object obj;CreateObject(model, x, y, z, &obj, true);MarkModelAsNoLongerNeeded(model);Wait(10);DeleteObject(&obj);}

 

I want to add &obj To my spawnobject like

 

CustomFiberThread::SpawnObject(eModel model,f32 x,f32 y,f32 z,[color=red]&obj[/color])

 

The red one is what i want to add

Edited by aceship
Link to comment
Share on other sites

 

void CustomFiberThread::SpawnObject(eModel model,f32 x,f32 y,f32 z, Object *obj){RequestModel(model);while(!HasModelLoaded(model)){ Wait(0);}CreateObject(model, x, y, z, &obj, true);MarkModelAsNoLongerNeeded(model);Wait(10);}-----------Object myObject;SpawnObject(MODEL_1337, 0.0f, 0.0f, 0.0f, &myObject); 

 

 

 

Plz, learn about Pointers. smile.gif

Link to comment
Share on other sites

 

and the header?

 

 

void SpawnObject(eModel model,f32 x,f32 y,f32 z, Object *obj)

 

 

Its just the same without the classname...

 

Do you ever try to learn something yourself???

Link to comment
Share on other sites

Im trying it along time,but never work,

yours is not working to

 

1>e:\program files\rockstar games\grand theft auto iv\samplecustomfiber\CustomFiberThread.h(16) : error C2061: syntax error : identifier 'Object'1>CustomFiberThread.cpp1>e:\program files\rockstar games\grand theft auto iv\samplecustomfiber\CustomFiberThread.h(16) : error C2061: syntax error : identifier 'Object'1>.\CustomFiberThread.cpp(65) : error C2511: 'void CustomFiberThread::SpawnObject(Scripting::eModel,f32,f32,f32,Scripting::Object *)' : overloaded member function not found in 'CustomFiberThread'1>        e:\program files\rockstar games\grand theft auto iv\samplecustomfiber\CustomFiberThread.h(7) : see declaration of 'CustomFiberThread'

 

 

Edit :

How to save an obj to a script until the script is turned off?

welll im still a noob with a high will to make something

Edited by aceship
Link to comment
Share on other sites

Does passing a Vector3 as reference work? Because when i try the code below, pos.X etc are empty...

Noticed the same. confused.gif Makes it impossible to get the current waypoint location.

Link to comment
Share on other sites

Yeah me too, too bad as getting the current waypoint would be great for teleportation.

 

 

Link to comment
Share on other sites

is there any way to save the object we make until the script is turned off?

or native that used like getclosestobjectwithmodel?

 

 

Link to comment
Share on other sites

 

Im trying it along time,but never work,

yours is not working to

 

1>e:\program files\rockstar games\grand theft auto iv\samplecustomfiber\CustomFiberThread.h(16) : error C2061: syntax error : identifier 'Object'1>CustomFiberThread.cpp1>e:\program files\rockstar games\grand theft auto iv\samplecustomfiber\CustomFiberThread.h(16) : error C2061: syntax error : identifier 'Object'1>.\CustomFiberThread.cpp(65) : error C2511: 'void CustomFiberThread::SpawnObject(Scripting::eModel,f32,f32,f32,Scripting::Object *)' : overloaded member function not found in 'CustomFiberThread'1>        e:\program files\rockstar games\grand theft auto iv\samplecustomfiber\CustomFiberThread.h(7) : see declaration of 'CustomFiberThread'

 

 

Edit :

How to save an obj to a script until the script is turned off?

welll im still a noob with a high will to make something

Owyeah, it should be Scripting::Object.

 

And:

CustomFiberThread::SpawnObject(Scripting::eModel,f32,f32,f32,Scripting::Object *)

 

Is wrong to. Scripting::Object *VARNAME. You're missing the varname.

I seriously suggest you learn some basic C++ first. Saves you alot of errors.

Edited by Intosia
Link to comment
Share on other sites

Does passing a Vector3 as reference work? Because when i try the code below, pos.X etc are empty...

Noticed the same. confused.gif Makes it impossible to get the current waypoint location.

Yeah i read it in your .Net thread. I hoped it would work in the C++ Hook. But it doesnt DAMN.

Link to comment
Share on other sites

It seems there is an object limit in MP going over 50 spawned objects the 51th object wont sync with the other players. (not sure if it is exactly 50).

Link to comment
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
 Share

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