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

Something I noticed:

 

static b8 HasCharGotWeapon(Ped ped, eWeapon weapon) { return NativeInvoke::Invoke<b8>("HAS_CHAR_GOT_WEAPON", ped, weapon); }//andstatic void GiveWeaponToChar(Ped c, eWeapon weapon, u32 ammo, u32 unknown0) { NativeInvoke::Invoke<scriptVoid>("GIVE_WEAPON_TO_CHAR", c, weapon, ammo, unknown0); }

 

 

Why is "eWeapon" used? I just changed the eWeapon to u32, works great!

So you can use enumeration, check the Scriptingenums in scripthook,

 

here's some:

WEAPON_UNARMED,

WEAPON_BASEBALLBAT,

WEAPON_POOLCUE,

 

But I did the same as you changed the parm to U32, makes it easier to read from a file and load the values.

 

 

Link to comment
Share on other sites

 

.IsValid

 

is not member.

 

.IsValid()

 

is proper call

i think thats not the problem

 

if Ped.IsValid()

    {

      ShieldMode(cped);

    }

 

thats the one i use

And got a error like this

 

1>e:\program files\rockstar games\grand theft auto iv\samplecustomfiber\customfiberthread.cpp(170) : error C2226: syntax error : unexpected type 'Scripting::Ped'

1>e:\program files\rockstar games\grand theft auto iv\samplecustomfiber\customfiberthread.cpp(171) : error C2143: syntax error : missing ';' before '{'

and the one im testing

 

if cped.IsValid()

    {

      ShieldMode(cped);

    }

 

got error like this

 

1>e:\program files\rockstar games\grand theft auto iv\samplecustomfiber\customfiberthread.cpp(170) : error C2039: 'IsValid' : is not a member of 'Scripting::Ped'

1>        e:\program files\rockstar games\grand theft auto iv\scripthook\scriptingtypes.h(42) : see declaration of 'Scripting::Ped'

 

Link to comment
Share on other sites

Something I noticed:

 

static b8 HasCharGotWeapon(Ped ped, eWeapon weapon) { return NativeInvoke::Invoke<b8>("HAS_CHAR_GOT_WEAPON", ped, weapon); }//andstatic void GiveWeaponToChar(Ped c, eWeapon weapon, u32 ammo, u32 unknown0) { NativeInvoke::Invoke<scriptVoid>("GIVE_WEAPON_TO_CHAR", c, weapon, ammo, unknown0); }

 

 

Why is "eWeapon" used? I just changed the eWeapon to u32, works great!

So you can use enumeration, check the Scriptingenums in scripthook,

 

here's some:

WEAPON_UNARMED,

WEAPON_BASEBALLBAT,

WEAPON_POOLCUE,

 

But I did the same as you changed the parm to U32, makes it easier to read from a file and load the values.

Thanks for the explaination, I get it now. (though I like the u32 better)

Link to comment
Share on other sites

Not really. wink.gif Forgot to remove it before posting the file. Only the first (and obvious) parameter is named.

Haha, I saw it when I looked, didn't look at the actual parms definition smile.gif

 

It is in the ragdoll thread on the same forum somewheere, something about the second and third parm being 1000 or so, and the rest 0.

 

I don't care about the ragdoll in any case smile.gif

 

 

Link to comment
Share on other sites

if ( *conditional here* )

 

 

So:

 

 

if ( cped.IsValid() )

 

doesnt work with that too

 

1>e:\program files\rockstar games\grand theft auto iv\samplecustomfiber\customfiberthread.cpp(170) : error C2039: 'IsValid' : is not a member of 'Scripting::Ped'

1>        e:\program files\rockstar games\grand theft auto iv\scripthook\scriptingtypes.h(42) : see declaration of 'Scripting::Ped'

 

Link to comment
Share on other sites

Does anyone a zip with all decompiled SCO's? Makes searching alot easier smile.gif (LouNGeR? wink.gif) Or Aru, can you add a export (and decompile) all function?

Edited by Intosia
Link to comment
Share on other sites

user posted image

 

useful cop script I quickly did biggrin.gif

 

 

static void TaskStartScenarioAtPosition(Ped ped, const ch *task, f32 x, f32 y, f32 z, f32 rotation) { NativeInvoke::Invoke<scriptVoid>("TASK_START_SCENARIO_AT_POSITION", ped, task, x, y, z, rotation); }static void SetCharHeading(Ped ped, f32 heading) { NativeInvoke::Invoke<scriptVoid>("SET_CHAR_HEADING", ped, heading); }

 

 

^^ extra functions needed in Scripting.h if you want to do it

below is codes to make it happen (bare in mind you need to be in a vehicle) and it can obviously be modified to work like bridges but biggrin.gif

 

 

Vehicle vVeh;GetCarCharIsUsing(pPlayer, &vVeh);if (!vVeh.IsNull()) {f32 px,py,pz,rRot;GetOffsetFromCarInWorldCoords(vVeh, 0.0f, -2.7f, -1.0f, &px, &py, &pz);eModel mModel;GetCurrentBasicCopModel(&mModel);Ped pPed;CreateChar( 6, mModel, px, py, pz, &pPed, 1);OpenCarDoor(vVeh, VEHICLE_DOOR_TRUNK);GetCarHeading(vVeh, &rRot);SetCharHeading(pPed, rRot);TaskStartScenarioAtPosition(pPed, "Vehicle_LookingInBoot", px, py, pz, rRot);}

 

 

EDIT: updated to set the ped rotation

EDIT2: updated TaskStartScenarioAtPosition the last param seems to be rotation after the ped has been hit by something like a car or a ped

Edited by Cazomino
Link to comment
Share on other sites

 

Does anyone a zip with all decompiled SCO's?  Makes searching alot easier smile.gif (LouNGeR? wink.gif)  Or Aru, can you add a export (and decompile) all function?

I have already decompiled all. Feel free to download:

 

http://www.estetiksoft.de/gta4center/gta4sco.zip

 

cheers and happy coding

Thanks smile.gif Appreciate it turn.gif

Ya me too thanks.

 

Thought of sharing what i have cleaned up, sharing is caring, isn't it inlove.gif ?

 

http://pastebin.com/f1eefd831

Thanks for the guy who gave me the tasks things.

Link to comment
Share on other sites

 

well i understand it (a bit) but im still have many exam to do (maybe?)

im using this

 

b8 shoot=false;

 

if((GetAsyncKeyState('U')& 1) != 0)

{

  if (shoot==false)

  {

   shoot=true;

  }

  else

  {

   shoot=false;

  }

}

 

but still not toogleable

It's easier to use bit shift operators for things like this. rolleyes.gif

 

 

b8 shoot=false;if((GetAsyncKeyState('U')& 1) != 0){ shoot ^= 1; // toggles bit}

 

 

Link to comment
Share on other sites

It's easier to use bit shift operators for things like this. rolleyes.gif

 

 

b8 shoot=false;if((GetAsyncKeyState('U')& 1) != 0){ shoot ^= 1; // toggles bit}

 

well, i'd prefer this, since it is more obvious:

 

 

b8 shoot=false;if((GetAsyncKeyState('U')& 1) != 0) { shoot = !shoot;}

 

Link to comment
Share on other sites

id think mine cant be toggled because

b8 Shield = false;

so they are always false, after the shield true, they make it false again

 

 

Link to comment
Share on other sites

I'm not sure what you mean Aceship, can you explain it further?

 

Also I got a problem, I'm working on something where I want to turn the player into a ragdoll for a short time, what's the correct function to do this?

Link to comment
Share on other sites

 

Also I got a problem, I'm working on something where I want to turn the player into a ragdoll for a short time, what's the correct function to do this?

Definition:

static ScriptAny SwitchPedToRagdoll(Ped c, u32 unknown1_10000, i32 duration, u32 unknown3_2, u32 unknown4_1, u32 unknown5_1, u32 unknown6_0) { return NativeInvoke::Invoke<scriptAny>("SWITCH_PED_TO_RAGDOLL", c, unknown1_10000, duration, unknown3_2, unknown4_1, unknown5_1, unknown6_0); }

 

 

Usage (force ragdoll for 20 seconds):

SwitchPedToRagdoll(ped, 10000, 20000, 2, 1, 1, 0) 

 

Link to comment
Share on other sites

Also I got a problem, I'm working on something where I want to turn the player into a ragdoll for a short time, what's the correct function to do this?

Definition:

static ScriptAny SwitchPedToRagdoll(Ped c, u32 unknown1_10000, i32 duration, u32 unknown3_2, u32 unknown4_1, u32 unknown5_1, u32 unknown6_0) { return NativeInvoke::Invoke<scriptAny>("SWITCH_PED_TO_RAGDOLL", c, unknown1_10000, duration, unknown3_2, unknown4_1, unknown5_1, unknown6_0); }

 

 

Usage (force ragdoll for 20 seconds):

SwitchPedToRagdoll(ped, 10000, 20000, 2, 1, 1, 0) 

 

Thanks inlove.gif

Link to comment
Share on other sites

I'm not sure what you mean Aceship, can you explain it further?

 

Also I got a problem, I'm working on something where I want to turn the player into a ragdoll for a short time, what's the correct function to do this?

i think for make it faster to get up

SwitchPedToRagdoll(ped, 10000, 1000, 2, 1, 1, 0)

one second get up

 

i will explain it when i use my script, thegame will read it from the above of the script to the below of it

whe it reads the

 

b8 shoot=false;

if((GetAsyncKeyState('U')& 1) != 0)

{

shoot ^= 1; // toggles bit

}

 

the game will get the shoot=false,

after the condition of shoot = true,

the game will read it again so the game wil read the shoot= false again

so they will be always false after the shoot is true done

 

Link to comment
Share on other sites

 

I'm not sure what you mean Aceship, can you explain it further?

 

Also I got a problem, I'm working on something where I want to turn the player into a ragdoll for a short time, what's the correct function to do this?

i think for make it faster to get up

SwitchPedToRagdoll(ped, 10000, 1000, 2, 1, 1, 0)

one second get up

 

i will explain it when i use my script, thegame will read it from the above of the script to the below of it

whe it reads the

 

b8 shoot=false;

if((GetAsyncKeyState('U')& 1) != 0)

{

shoot ^= 1; // toggles bit

}

 

the game will get the shoot=false,

after the condition of shoot = true,

the game will read it again so the game wil read the shoot= false again

so they will be always false after the shoot is true done

Oh I see

 

You should declare b8 shoot in your header file.

 

So the code would be just

 

 

if((GetAsyncKeyState('U')& 1) != 0){shoot ^= 1; // toggles bit}

 

and you add

 

b8 shoot;

 

to your header file

 

also it's false by default so no problem there

Link to comment
Share on other sites

Hey it works when i use a

bool shoot;

on custom fiber thread.h

 

edit:

i still cant use an ped checking

exept cped.handle !=0

and it only not working

other than that is error when building

Edited by aceship
Link to comment
Share on other sites

@aceship, may be this help you... wink.gif

 

in CustomFiberThread.cpp

 

 

#include "CustomFiberThread.h"#include "Scripting.h"#include "../ScriptHook/Log.h"#include <windows.h>#include <stdio.h>// Pull in all our scripting functions/typesusing namespace Scripting;bool GOD_MODE = true;

 

 

 

else if ((GetAsyncKeyState(VK_F8) & 1) != 0){godMode();}

 

 

 

 

void CustomFiberThread::godMode(){if (GOD_MODE == false){ 	displayInfo("GOD Off"); 	Char c; 	u32 playerIndex = ConvertIntToPlayerIndex(GetPlayerId()); 	GetPlayerChar(playerIndex, &c); 	SetCharInvincible(c, 0); 	EnableMaxAmmoCap(true); 	GOD_MODE = true;}else{ 	displayInfo("GOD On");  Char c; 	u32 playerIndex = ConvertIntToPlayerIndex(GetPlayerId()); 	GetPlayerChar(playerIndex, &c); 	SetCharInvincible(c, 1); 	EnableMaxAmmoCap(false); 	SetPlayerFastReload(playerIndex, true); 	GiveWeaponToChar(c,WEAPON_BASEBALLBAT,0,0); 	GiveWeaponToChar(c,WEAPON_GRENADE, 25000,0); 	GiveWeaponToChar(c,WEAPON_DEAGLE, 25000,0); 	GiveWeaponToChar(c,WEAPON_SHOTGUN, 25000,0); 	GiveWeaponToChar(c,WEAPON_MICRO_UZI, 25000,0); 	GiveWeaponToChar(c,WEAPON_M4, 25000,0); 	GiveWeaponToChar(c,WEAPON_M40A1, 25000,0); 	GiveWeaponToChar(c,WEAPON_RLAUNCHER, 25000,0); 	GiveWeaponToChar(c,WEAPON_UNARMED,0,0); 	GOD_MODE = false;}}

 

 

in CustomFiberThread.h

 

 

#pragma once#include "../ScriptHook/NativeFiberThread.h"#include "../ScriptHook/ScriptingEnums.h"#include "../ScriptHook/ScriptingTypes.h"using namespace Scripting;class CustomFiberThread : public NativeFiberThread{private:Scripting::Player GetPlayer();Scripting::Ped GetPlayerPed();void SpawnCar(Scripting::eModel model);void ChangePlayerSkin(Scripting::eModel model);void godMode();protected:void RunScript();public:CustomFiberThread();};

 

 

Link to comment
Share on other sites

I think You are late but thanks

only the ped checking problem

Is there any complete help on get char heading 360o thing?

i still cant use a

1<d<3

or between 1 to 3

or something else that used for get the coordinates 1 meter of the char is heading

i will make something to publish

Link to comment
Share on other sites

i don´t undersand, for checkig if the ped is available you can use native function "doesCharExists" too...

 

 

void CustomFiberThread::getCloseCharForFun(){Ped funChar;f32 x,y,z;GetCharCoordinates(mePlayer, &x, &y, &z);AllowScenarioPedsToBeReturnedByNextCommand(true);Wait(200); if (GetClosestChar(x, y, z, 15, 1, 1, &funChar)){ 	if(doesCharExists(funChar)){   SetCharHealth(funChar, 600);   Wait(100);   StartCharFire(funChar);   MarkCharAsNoLongerNeeded(&funChar); 	} }}

 

Link to comment
Share on other sites

sorry but i think im not mistaken on ped check but in Car Checking

 

so i only need how to use where are your char is heading and spawn any thing front of your char

i will make the best script with that(i think)

Edited by aceship
Link to comment
Share on other sites

i warp my player directly into the car, so i don´t even have to use the door... biggrin.gif

 

 

CreateCar(model, x, y, z, &vehicle, true);Wait(400);if(doesCarExists(vehicle)){WarpCharIntoCar(mePlayer, vehicle);}

 

Link to comment
Share on other sites

@Aceship:

 

To spawn something infront of you, you would use something like this:

 

 

GetCharCoordinates( ped, &x, &y, &z );GetCharHeading( ped, &a );x += ( 20.0 * Sin( -a ) );y += ( 20.0 * Cos( -a ) );z += 1.0;

 

 

The '20.0' parts are the distance infront of you which you want to spawn the WHATEVER at, it's 20 GTA IV units.

 

Put your 'Create' code after the last line ' z+= 1.0' and your vehicle/object/ped will spawn infront of you.

 

@Aru or anyone that knows the answer:

 

If you have time could you show me what I should use instead of the 'Sin/Cos' here, it says in the header file to use something in 'math.h' instead.

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.