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

 

hey,

is there any possibility to unlock car doors? i can lock them but i dont find a function to unlock them   sad.gif

Thats most likely because people use the LOCK_CAR_DOORS native wrong. The second parameter is NOT the door id, but the lock level for all doors. Call LOCK_CAR_DOORS with 0 as second parameter and the doors are unlocked.

ty it works smile.gif

 

 

but next problem

 

i get everytime freeze when i use

 

 

 

...  Vehicle cCar;  GetClosestCar(x, y, z, 10.0, false, 70);     if(cCar.IsNull()){...

 

 

what is wrong?

Edited by WarBall
Link to comment
Share on other sites

I would think that getclosest car should be stored into cCar right ?

 

so I would assume, the last parm to have to be &cCar.

 

and then something like

 

if ((Ccar.IsValid())

 

 

Link to comment
Share on other sites

I would think that getclosest car should be stored into cCar right ?

 

so I would assume, the last parm to have to be &cCar.

 

and then something like

 

if ((Ccar.IsValid())

when i use

 

Vehicle cCar; GetClosestCar(x, y, z, 10.0, false, 70, &cCar);

 

 

freeze too sad.gif

 

i try this since days but i dont get it to run confused.gif

Link to comment
Share on other sites

I would think that getclosest car should be stored into cCar right ?

 

so I would assume, the last parm to have to be &cCar.

 

and then something like

 

if ((Ccar.IsValid())

when i use

 

Vehicle cCar; GetClosestCar(x, y, z, 10.0, false, 70, &cCar);

 

 

freeze too sad.gif

 

i try this since days but i dont get it to run confused.gif

Okay, try something like:

 

 

else if ((GetAsyncKeyState(VK_L) &1) != 0) 	{ 	Ped ped; 	Vehicle veh; 	f32 x,y,z; 	u32 playerIndex = ConvertIntToPlayerIndex(GetPlayerId()); 	GetPlayerChar(playerIndex, &ped); 	GetCharCoordinates(ped,&x,&y,&z); 	veh = GetClosestCar(x,y,z,10,false,70); 	if ((veh.IsValid())&&(DoesVehicleExist(veh) == 1)) 	{ 	ExplodeCar(veh,true, false); 	} 	else 	{ 	PrintStringWithLiteralStringNow("STRING","No Car",5000,1); 	}	 	}	

 

 

Pressing L will explode the nearest car, you might want to enabale god mode smile.gif

 

 

Link to comment
Share on other sites

Edit:

How to spawn a book?

What is the hexadecimal code of The Book?

Edited by aceship
Link to comment
Share on other sites

How to get targetted ped?

why when i link the .lib file from d3d sdk get a thousand error(it Is Really 1 thousand)

 

 

Link to comment
Share on other sites

 

How to get targetted ped?

why when i link the .lib file from d3d sdk get a thousand error(it Is Really 1 thousand)

It shouldn't do, try compiling one of the DirectX SDK examples. See if you have the same issue. I am able to link the DirectX libraries to my ASI module with no issues. Make sure you have set up the include/lib directories of visual studio to include the SDK directories.

Link to comment
Share on other sites

I cant,it still do that,so i think i mistaken in linking,

How to linking a lib file?

Link to comment
Share on other sites

 

  }	 	else if ((GetAsyncKeyState(VK_F8) & 1) != 0) 	{   LogInfo("Changing the player skin");   m_SkinModel = MODEL_F_Y_CDRESS_01;   RequestModel(m_SkinModel);   // Change our state so that we can change skin when available   m_State = StateChangeSkin; 	} 	else if ((GetAsyncKeyState(VK_F9) & 1) != 0) 	{   LogInfo("Changing the player skin back to Niko's");   m_SkinModel = MODEL_PLAYER;   RequestModel(m_SkinModel);   // Change our state so that we can change skin when available   m_State = StateChangeSkin; 	} } break;

 

 

How to change to a different character?

 

void CustomFiberThread::ChangePlayerSkin(eModel model){RequestModel(model);while(!HasModelLoaded(model)){ Wait(0);}eInteriorRoomKey roomKey;GetKeyForCharInRoom(GetPlayerPed(), &roomKey);ChangePlayerModel(GetPlayer(), model);SetRoomForCharByKey(GetPlayerPed(), roomKey);MarkModelAsNoLongerNeeded(model);} else if .... { 	 	ChangePlayerSkin(MODEL_NAME); }

 

 

you mean this? smile.gif

 

 

 

can anybody tell me how to make something like hold "k" button and then something happens? like hold "f" to get in taxi as passenger.

 

and does something now which params for attachpedtocar or cartocar

when i use

 

 AttachCarToCar(veh, myAuto, 0, x, y, z, 0, 0, 0);orAttachCarToCar(veh, myAuto, 0, x, y, z, 1, 1, 1); 

 

 

the veh disappears

Edited by WarBall
Link to comment
Share on other sites

Yeah, that's it. So, where do I place these .h/.cpp files? Because I place them in the IV directory and I just press F8. Nothing happens.

No smile.gif

 

You need to move only the .asi into the GTAIV directory, not the header and scource files of your app.

 

You can find that file in the release directory, called samplecustom.dll, rename it to something .asi

 

 

Link to comment
Share on other sites

You really should learn some basics before trying to script anything. confused.gif

It will create a .dll in the Debug folder if you're compiling it in debug mode, not in the Release folder.

Link to comment
Share on other sites

How do you compile?  confused.gif

Pressing F7 whilst somewhere in the scource.

In Visual Basic?

Select "build" from the Visual Studio Menu and then "Build Solution". This should work for any language in Visual Studio.

Link to comment
Share on other sites

 

Which menu?  There's like 6, View, Debug e.t.c.

Well from the Build menu..

 

[File] [Edit] [View] [Project] [build] [Debug] [Tools] [Window] [Help]

-> Build solution (F7)

Link to comment
Share on other sites

Well you have to open the solution (.sln file) first. Hence the name "Build solution (F7)". You can't compile just one .cpp file.

 

[File] -> Open -> Project/Solution... -> ScriptHook.sln

It's located in the root directory of the .zip you downloaded, the ScriptHook.sln file.

Link to comment
Share on other sites

Well you have to open the solution (.sln file) first. Hence the name "Build solution (F7)". You can't compile just one .cpp file.

 

[File] -> Open -> Project/Solution... -> ScriptHook.sln

It's located in the root directory of the .zip you downloaded, the ScriptHook.sln file.

so do I delete that code when I open it and add my own?

 

I got 2 errors

 

 

1>------ Build started: Project: SampleCustom, Configuration: Debug Win32 ------1>Compiling...1>CustomThread.cpp1>c:\documents and settings\compaq_owner\desktop\script hook\samplecustom\customthread.cpp(11) : error C2084: function 'CustomThread::CustomThread(void)' already has a body1>        c:\documents and settings\compaq_owner\desktop\script hook\samplecustom\customthread.h(26) : see previous definition of '{ctor}'1>c:\documents and settings\compaq_owner\desktop\script hook\samplecustom\customthread.cpp(17) : error C2084: function 'void CustomThread::RunTick(void)' already has a body1>        c:\documents and settings\compaq_owner\desktop\script hook\samplecustom\customthread.h(23) : see previous definition of 'RunTick'1>Main.cpp1>Generating Code...1>Build log was saved at "file://c:\Documents and Settings\Compaq_Owner\Desktop\Script Hook\SampleCustom\Debug\BuildLog.htm"1>SampleCustom - 2 error(s), 0 warning(s)========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========

 

Seems like you have the contructor (CustomThread::CustomThread) and Tick (CustomThread::Tick) function twice ('already has a body') in your code. Quick guess though.

Link to comment
Share on other sites

WOOOOOOHOOO!

YEAH!

Alright, I found it!!

 

Here's how to "freeze" Niko's health using a native:

1. Add the following to scripting.h:

 

static void IncreasePlayerMaxHealth(Player playerIndex, u32 value) { NativeInvoke::Invoke<scriptVoid>("INCREASE_PLAYER_MAX_HEALTH", playerIndex, value); }

 

Look closely, that's not SetCharMaxHealth, that's IncreasePlayerMaxHealth!

 

What I have in my RunTick():

 

if ((GetAsyncKeyState(GodModeKey) & 1) != 0)    {   	if (godmode == false)   	{     LogInfo("--Enabling godmode loop...");     looping = true;     godmode = true;     PrintStringWithLiteralStringNow("STRING", "Godmode ON", 1500, 1);   	}   	else   	{     LogInfo("--Godmode loop off");     looping = false;     godmode = false;     Player playerIndex = ConvertIntToPlayerIndex(GetPlayerId());     Ped Ped;     GetPlayerChar(playerIndex,&Ped);     SetPedDiesWhenInjured(Ped,true);     //SetCharMaxHealth(Ped,400);     IncreasePlayerMaxHealth(playerIndex, 400);     SetCharHealth(Ped,400);     AddArmourToChar(Ped,400);     //SetPlayerInvincible(playerIndex, false);     PrintStringWithLiteralStringNow("STRING", "Godmode OFF", 1500, 1);   	}   	   }   if (looping == true)   {   	Player playerIndex = ConvertIntToPlayerIndex(GetPlayerId());   	Ped Ped;   	GetPlayerChar(playerIndex,&Ped);   	IncreasePlayerMaxHealth(playerIndex, 4000000);   	SetCharHealth(Ped, 3999999);	   	AddArmourToChar(Ped,400);   	   	SetPedDiesWhenInjured(Ped, false);            }

 

And with this, Niko is Invincible, but can still fall of his bike, and is affected by explosions (you can rocketjump).

Edited by thaCURSEDpie
Link to comment
Share on other sites

It doesn't, atleast not on my PC or my brother's. That's because I'm not running it in the FiberThread, but in the normal one.

Link to comment
Share on other sites

I found a native called "NET_SEND_TEXT_CHAT" on the GtaGarage nativelist, and I'm wondering how I should put this in scripting.h. First of all, I need to know the amount of parameters. If I know that, I can try a couple of things and see if they work.

 

I've looked in Alice's documentation, (with the list of "all" natives), but the native wasn't listed.

 

It isn't listed in scripting-dirty. Where can I find the amount of parameters?

Link to comment
Share on other sites

 

I found a native called "NET_SEND_TEXT_CHAT" on the GtaGarage nativelist, and I'm wondering how I should put this in scripting.h. First of all, I need to know the amount of parameters. If I know that, I can try a couple of things and see if they work.

 

I've looked in Alice's documentation, (with the list of "all" natives), but the native wasn't listed.

 

It isn't listed in scripting-dirty. Where can I find the amount of parameters?

Search the game scripts (SCO files), to find a example. Open them with OpenIV or SparkIV

Link to comment
Share on other sites

I found a native called "NET_SEND_TEXT_CHAT" on the GtaGarage nativelist, and I'm wondering how I should put this in scripting.h. First of all, I need to know the amount of parameters. If I know that, I can try a couple of things and see if they work.

 

I've looked in Alice's documentation, (with the list of "all" natives), but the native wasn't listed.

 

It isn't listed in scripting-dirty. Where can I find the amount of parameters?

Search the game scripts (SCO files), to find a example. Open them with OpenIV or SparkIV

That function isn't used in any SCO script. There's some functions which do nothing but still exist in GTA IV. I think aru has cut out those from the ScriptingDirty.h file so that's why it's not there. Same with alice.

Link to comment
Share on other sites

That function isn't used in any SCO script. There's some functions which do nothing but still exist in GTA IV. I think aru has cut out those from the ScriptingDirty.h file so that's why it's not there. Same with alice.

Well, not all functions missing in Scripting.h AND ScriptingDirty.h do nothing. Functions not included in both files were just not used by ingame scripts, but this doesn't necessarily mean that the native does not work.

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.