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

    1. GTANet.com

    1. GTA Online

      1. Los Santos Tuners
      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. GTA San Andreas

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

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

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    1. Grand Theft Auto Series

      1. 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. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    6. 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

      1. GTANet 20th Anniversary
    2. Support

    3. Suggestions

C++ Script Hook


aru
 Share

Recommended Posts

 

@Sjakie  (sry I had to)

No problem, glad it works now.

BTW, GTASA always removed your vehicle when you went away from it, does IV always keep it at that spot where you left it?

 

 

@aru

Hmm, a SCO compiler, isn't this C++ Hook much more useful than that?

It seems to be doing that sometimes, I liked this function and sometimes after a mission, I forgot where I left the car, and used this function smile.gif

Link to comment
Share on other sites

Does anyone know of a way to make the game think that Nico did all the damage like ApplyForceTo...() and AddExplosion() ??

As in, you'll get wanted stars for ApplyForceToPed().

 

Does it have anything to do with GetTimeSincePlayerHit......() ?

Edited by L0uNGeR
Link to comment
Share on other sites

Ok, but it cant have a difference of almost 600? Even if the coords are in the front or center or back of the car. 600 is to much... Thats almost the otherside of the map(?)

 

GetCarCoordinates(closeCar, &x, &y, &x);

 

Don't feel bad, I do dumb crap like that ALL the time. lol.gif

ZOMG, i knew it had to be something like that! (When i was thinking in bed turn.gif ) Thanks wink.gif

Link to comment
Share on other sites

maybe using

if Wantedlevel < 1

{

Set wanted level (c,1)

}

this is just the source,not the real one, just example,not the real one(why i answer this two time?)

All of that , maybe it can make you wanted

 

and how to use Getclosestcar?

Edited by aceship
Link to comment
Share on other sites

Does anyone know of a way to make the game think that Nico did all the damage like ApplyForceTo...() and AddExplosion() ??

As in, you'll get wanted stars for ApplyForceToPed().

 

Does it have anything to do with GetTimeSincePlayerHit......() ?

Just increase the wanted level? tounge.gif

 

And about DisplayText, when you call it, it shows the text 1 frame. Make a button and hold it down, you will see the text flickering...

 

Is there a way to display text without the flickering?

Link to comment
Share on other sites

 

@Sacky... I thought about it for a bit... I think an approach like this should do:

 

1. Change NativeInvoke::Invoke(ch *, NativeContext *) to store the name/context somewhere, and then go into a loop until the code is executed.

 

2. Create a NativeThread that properly invokes the stored name/context (if available) and sets a flag for the parent thread to exit the loop.

 

Its somewhat hacky, and it blocks the caller thread but thats probably the best approach.

 

I've tried this approach to death unfortunately. Maybe I'm doing it wrong though. I make the native function pointer a global function, and the params info a global function, then I mark a global bool as true. In my native loop after I have executed the function pointer and params, i set the global bool to false (then theoretically the nativeFunction I have should come out of the while() loop when the global bool is set to false again after the execution). However this just doesn't happen, game gets caught in an infinite loop. I find this confusing... but I'll show some pseudocode so you know what I mean:

 

http://pastebin.com/m36cbfe79

 

In short, doesn't work like it should, just locks up. Maybe WaitForSingleObject or something?

Link to comment
Share on other sites

Make a bool to control it its state. And have the key toggle the bool instead.

No the text is only rendered one frame by the engine... Running the command once = text on one frame. Running the command in a loop = flickering text.

Link to comment
Share on other sites

 

Make a bool to control it its state. And have the key toggle the bool instead.

No the text is only rendered one frame by the engine... Running the command once = text on one frame. Running the command in a loop = flickering text.

It doesn't flicker for me, try it in a clean script loop , this maybe be a sign of stress in your code slowing things

 

On a different note here is some code for a bat file i find very useful . I just put this in my release or debug dir and make a shortcut on the taskbar.

the result is i compile, then run the compiled script in the game from a shortcut.

 

 

ren ScriptHook.dll ScriptHook.asicopy ScriptHook.asi "C:\Program Files\Rockstar Games\Grand Theft Auto IV" /yECHO Y | DEL ScriptHook.asicd C:\cd "C:\Program Files\Rockstar Games\Grand Theft Auto IV"GTAIV.exe

 

 

1 renames the dll to asi

2 copys the asi to the target dir (auto overwrite)

3 deletes the old copy from compiledir.

4 switches dir to gtaiv and runs the game.

 

You just copy this to a new text file , name it anything.bat and put it in your release / debug dir and click it after compile.

Some things may need to be changed to reflect your system, least obvious is "ECHO Y | DEL ScriptHook.asi"

the Y must be the Yes option for your language. change also install dir and asi name if needed.

 

Note: If you change between release and debug or entire projects in the compiler dont forget to launch the bat in the correct directory.

Always your current project directory and current compile mode , the bat only looks in its own dir for the .dll.

Edited by C06alt
Link to comment
Share on other sites

@Sacky.. that sounds about right assuming you are hooked into the scripting system just fine. Try using an Event and WaitForSingleObject to sych the two threads.

 

@Intosia... if you're using FiberThread, try changing the Wait(100) to Wait(0)... that might get rid of some flicker.

 

@C06alt... If you go to your C++ project properties, then choose Configuration Properties -> Linker. You can change the "Output File" location for your project here.... for example, set it to "C:\Program Files\Rockstar Games\Grand Theft Auto IV\$(ProjectName).asi" and you don't need to run a batch script smile.gif Note that after you do this, all the builds will go into that directory, so the files in the Debug/Release folders might be outdated.

 

If you want to make your life even easier... go to Configuration Properties -> Debugging, and set the working directory to ""C:\Program Files\Rockstar Games\Grand Theft Auto IV" and command to ""C:\Program Files\Rockstar Games\Grand Theft Auto IV\GTAIV.exe"... and set Attach to True. Now run the game with XLiveLess and after the game has loaded, go to Debug -> Start Debugging... Then you can use set breakpoints in your code and step through it.

Link to comment
Share on other sites

@Intosia... if you're using FiberThread, try changing the Wait(100) to Wait(0)... that might get rid of some flicker.

 

True, but doesnt Wait(0) stress the engine?

Link to comment
Share on other sites

Does anyone know of a way to make the game think that Nico did all the damage like ApplyForceTo...()  and AddExplosion() ??

As in, you'll get wanted stars for ApplyForceToPed().

 

Does it have anything to do with  GetTimeSincePlayerHit......()  ?

Just increase the wanted level? tounge.gif

Nahh, I don't want it like that....

It must be real, so people actually react as if I punched someone.

Link to comment
Share on other sites

@Intosia... if you're using FiberThread, try changing the Wait(100) to Wait(0)... that might get rid of some flicker.

 

True, but doesnt Wait(0) stress the engine?

Only thing that comes out of it is the extra overheard from the SwitchToFiber(...) win32 call, but I dont think it should be that bad. All non-idle scripts are executed every frame anyhow.

Link to comment
Share on other sites

 

Make a bool to control it its state. And have the key toggle the bool instead.

Yes and this works, however (I admit I'm new at this stuff), I press a button, and indeed, instead of just displaying the text for a brief moment, now the text (controlled by a bool) stays there forever smile.gif

 

Any way to just display the text for say a few seconds ?

 

On another note, I was having trouble yesterday with the saved_car principle, I followed the advice here to include it into the custom fiber, but it was only partially working, one native didn't work properly.

 

I have simply included

 

#include "../ScriptHook/ScriptingTypes.h"

using namespace Scripting;

 

into Customheader.h, and declared the variable as:

 

Vehicle Saved_Car;

 

Now I was able to compile, and also the native that didn't work properly, now works 100%. I hope doing this doens't have any negative effects (not that I have noticed anyway), and since I wasn't using the fiber, I prefer to have all in one asi.

Link to comment
Share on other sites

@sjaak327

 

 

Any way to just display the text for say a few seconds ?

i tryed "ShowHelpWithString", it´s not working for me (i´m a noob in c++, on mac i use alot Objectiv-C Cocoa, this helps a little blush.gif )

the "ShowHelpWithNumber" works fine, but only numbers will printed that way and stay for 5 seconds....

Anybody got this "ShowHelpWithString" native working in c++ ?

i used the "gtx" "STRING" and as 2nd parameter a const ch, may be we need something else for this string thing.

alice 0.2 can push string values now, how alexander do that cool.gif

 

Link to comment
Share on other sites

Is CHANGE_CAR_COLOUR usefull atm? Because of the eColour struct being empty? When i enter a int a param i get:

 

 

'Scripting::ChangeCarColour' : cannot convert parameter 2 from 'int' to 'Scripting::eColour'

 

Link to comment
Share on other sites

To counter this problem I change

 

enum eColour{};

 

 

In

 

typedef u32 eColour;

 

 

And it works very well for me, you can also enum the color in gtamoding wiki but is very long.

Link to comment
Share on other sites

I got around this to actually do the enumeration smile.gif

 

So I copied the values in carcols.dat into the enumeration.h file.

 

Now I can actually use meaningfull names.

 

Link to comment
Share on other sites

I'm still having fun with this hook, there is one thing left to do, that is the text display.

 

Now I have tried another native, PrintHelpWithString, and defined it in the scripting.h like this:

 

 

static void PrintHelpWithString(const ch *gxtName, ch *text) { NativeInvoke::Invoke<scriptVoid>("PRINT_HELP_WITH_STRING", gxtName, text); }

 

 

I'm trying to print the text using:

 

PrintHelpWithString("NUMBER", "test");

 

When ingame, and pressing the corresponding key combination, I hear the sound that you normally hear when text gets displayed, I see a block in the upper left corner of the screen, but not the text, any idea why ?

 

 

 

 

Link to comment
Share on other sites

If you look at the script examples you can see that it is a string referenced by a string assigned to it so as it can display the popper string for that language.

 

 

PRINT_HELP_WITH_STRING("CP_MAX_0", "CP_DESCRP_0");

 

 

try that and you will probably find CP_DESCRP_0 is some random help message from the game.

 

only commands with the word LITERAL can be used for custom strings. eg

 

DISPLAY_TEXT_WITH_LITERAL_STRING

 

No help text commands can do this afaik.

Link to comment
Share on other sites

Hey, My question is not answered,

Q

How to use GetClosestCar(x, y, z, 25, 0, 70)?

like this?

car = GetClosestCar(x, y, z, 25, 0, 70)

or

(GetClosestCar(x, y, z, 25, 0, 70)),x,y,z)?

 

Link to comment
Share on other sites

DISPLAY_TEXT_WITH_LITERAL_STRING works 'fine'. But is there a way to set a smaller font? Found LoadTextFont, but that enum is also empty. So i guess i can just use ints, say 1 to 5? Gonne try that when i get home smile.gif

Link to comment
Share on other sites

The settextscale uses what type of size?

html type?

or notepad type?

and how to use GetClosestcar?

I think Intosia have this script like in the Your movie,

Intosia: you have the Brucie what trick dont you?

how to use Getclosestcar?

the brucie one use that right?

Link to comment
Share on other sites

Intosia knows how to use GetClosestCar() so he doesn't need my Bruce script.

The latest version of the scripthook already has GetClosestCar() and GetClosestChar() included, so you'll only have to look at the parameters and you should know how it works.

 

static Vehicle GetClosestCar(f32 x, f32 y, f32 z, f32 radius, b8 unknownFalse, u32 unknown70){   return NativeInvoke::Invoke<Vehicle>("GET_CLOSEST_CAR", x, y, z, radius, unknownFalse, unknown70);}

 

 

A call that would make sense can be something like

 

Vehicle myCloseCar = GetClosestCar(x, y, z, 10.0, false, 70);

 

Ofcourse you'll have to fill in x,y,z by yourself.

 

 

And for some odd reason, GetClosestChar() does NOT work the same:

 

static b8 GetClosestChar(f32 x, f32 y, f32 z, f32 radius, b8 unknown1, b8 unknown2, Ped *pPed){   return NativeInvoke::Invoke<b8>("GET_CLOSEST_CHAR", x, y, z, radius, unknown1, unknown2, pPed);}

 

 

A call that would make sense for this function could be

 

Ped myClosePed;bool foundClosePed = GetClosestChar(x, y, z, 10.0, true, true, &myClosePed);

 

If a ped was found, "foundClosePed" is now True and "myClosePed" contains a ped.

Edited by L0uNGeR
Link to comment
Share on other sites

im using old one so im using a car not vehicle, how to use FreezePositionOfClosestObjectOfType()?

like this?

 

x,y,z= char coord

25 = radius

1 = yes

obj= object

FreezePositionOfClosestObjectOfType(obj, x, y, z, 25, 1)

 

 

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.