Jump to content
zloganrox08

Rage Native Functions

Recommended Posts

I've found a list of functions to use, but can find very little documentation on them. The functions I found are on http://www.dev-c.com/nativedb. I've seen one function call in someone's github code: 

// Make the peds attack the player
NativeFunction.CallByName<uint>("TASK_COMBAT_PED", Aggressor3, Game.LocalPlayer.Character, 0, 1);

When I do a similar function call, I either crash the game or it just doesn't work. 

//This crashes the game
NativeFunction.CallByName<uint>("_TASK_VEHICLE_FOLLOW", Backupdriver, BackupSwat, Game.LocalPlayer.Character, 20, (int)VehicleDrivingFlags.Emergency, 10);

//This doesn't do anything
NativeFunction.CallByName<uint>("TASK_SEEK_COVER_FROM_PED", Officer1, Hostile1, 100000, false);

I don't know what <uint> is. Typecasting the return? The return of both functions is void but it throws an error when I put void there.

 

Any pointing to documentation on how to use Rage Native functions or just telling me how to do them here would be much appreciated.

Share this post


Link to post
Share on other sites
1 hour ago, zloganrox08 said:

I've found a list of functions to use, but can find very little documentation on them. The functions I found are on http://www.dev-c.com/nativedb. I've seen one function call in someone's github code: 


// Make the peds attack the player
NativeFunction.CallByName<uint>("TASK_COMBAT_PED", Aggressor3, Game.LocalPlayer.Character, 0, 1);

When I do a similar function call, I either crash the game or it just doesn't work. 


//This crashes the game
NativeFunction.CallByName<uint>("_TASK_VEHICLE_FOLLOW", Backupdriver, BackupSwat, Game.LocalPlayer.Character, 20, (int)VehicleDrivingFlags.Emergency, 10);

//This doesn't do anything
NativeFunction.CallByName<uint>("TASK_SEEK_COVER_FROM_PED", Officer1, Hostile1, 100000, false);

I don't know what <uint> is. Typecasting the return? The return of both functions is void but it throws an error when I put void there.

 

Any pointing to documentation on how to use Rage Native functions or just telling me how to do them here would be much appreciated.

 

if it returns void, you may put <bool> in there.

Share this post


Link to post
Share on other sites
Posted (edited)

1. Please use NativeFunction.Natives when calling a native, CallByName or CallByHash are old methods which cause fps drops.

2. Native tutorial: https://pastebin.com/3FJM8tte

3. alot of the functions you are using are already in RPH

4. _TASK_VEHICLE_FOLLOW is a guessed name, you can tell because it has a '_' at the start so you're going to need to use the value behind it (xFC545A9F0626E3B6)

Edited by NoNameSet

Share this post


Link to post
Share on other sites
Quote

3. alot of the functions you are using are already in RPH

4. _TASK_VEHICLE_FOLLOW is a guessed name, you can tell because it has a '_' at the start so you're going to need to use the value behind it (xFC545A9F0626E3B6)

 

3: I have not found a function for following with vehicle. I searched the forums and most of them recommended using a while loop and use GoToOffsetFromEntity. 

 

4: What if there are two hashes behind it? example: TASK_SEEK_COVER_FROM_POS. the following is what is after it: 

0x75AC2B60386D89F2 0x83F18EE9

Share this post


Link to post
Share on other sites
5 hours ago, zloganrox08 said:

What if there are two hashes behind it? example: TASK_SEEK_COVER_FROM_POS. the following is what is after it: 


0x75AC2B60386D89F2 0x83F18EE9

The first hash is the one you use. But, that native isn't guessed (doesn't start with _ ), so you can just use the native directly with NativeFunction.Natives.TASK_SEEK_COVER_FROM_POS

 

Share this post


Link to post
Share on other sites

Im pretty sure RPH has something like ped.Tasks.ChaseWithVehicle or FollowWithVehicle if not use the task vehicle escort native which works well.

Share this post


Link to post
Share on other sites
Posted (edited)
public static void TaskVehicleEscort(this Ped ped, Vehicle vehicle, Vehicle targetVehicle, int vehicleEscortMode, float speed, int drivingStyle, float minDistance, float noRoadsDistance)
        {
            NativeFunction.Natives.TASK_VEHICLE_ESCORT(ped, vehicle, targetVehicle, vehicleEscortMode, speed, drivingStyle, minDistance, -1, noRoadsDistance);
}

escort modes:

public enum EVehicleEscortMode : int
{
    Behind= -1,
    Ahead = 0,
    Left = 1,
    Right = 2,
    Back_Left = 3,
    Back_Right = 4
}

or for _TASK_VEHICLE_FOLLOW

public static void TaskVehicleFollow(this Ped ped, Vehicle vehicle, Entity targetEntity, float speed, int vehicleDrivingFlag/*use RPH vehicle driving flags enum*/, int minDistance)
        {
            NativeFunction.Natives.xFC545A9F0626E3B6(ped, vehicle, targetEntity, speed, vehicleDrivingFlag, minDistance);
        }

 

Edited by NoNameSet

Share this post


Link to post
Share on other sites

I know ya'll don't like snippets of code, but here is the code that I have:

 

                Game.LogTrivial("Trying to get cop to do something");
                NativeFunction.Natives.TASK_SEEK_COVR_FROM_POS<bool>(Officer1, -111f, 6462f, 32f, -1, false);
                Game.LogTrivial("It worked.. for now");

And here is the log file where it crashes. (Player has just arrived is printed by me earlier)

 

Quote

[4/20/2018 7:28:25 AM.516] LSPD First Response: Player has just arrived.
[4/20/2018 7:28:38 AM.453] setting up new cop: null
[4/20/2018 7:28:38 AM.454] [TRACE] New ped recognized as cop
[4/20/2018 7:28:38 AM.454] setting up new cop: null
[4/20/2018 7:28:38 AM.454] [TRACE] New ped recognized as cop
[4/20/2018 7:28:38 AM.454] setting up new cop: null
[4/20/2018 7:28:38 AM.455] [TRACE] New ped recognized as cop
[4/20/2018 7:28:39 AM.466] setting up new cop: null
[4/20/2018 7:28:39 AM.467] [TRACE] New ped recognized as cop
[4/20/2018 7:28:53 AM.651] LSPD First Response: Trying to get cop to do something
[4/20/2018 7:28:53 AM.676] LSPD First Response: 
[4/20/2018 7:28:53 AM.677] LSPD First Response: ==============================
[4/20/2018 7:28:53 AM.677] LSPD First Response: UNHANDLED EXCEPTION DURING GAME FIBER TICK
[4/20/2018 7:28:53 AM.677] LSPD First Response: ------------------------------
[4/20/2018 7:28:53 AM.677] LSPD First Response: Origin: Game fiber "CalloutManager".
[4/20/2018 7:28:53 AM.678] LSPD First Response: ------------------------------
[4/20/2018 7:28:53 AM.678] LSPD First Response: Exception type: System.AccessViolationException
[4/20/2018 7:28:53 AM.678] LSPD First Response: Exception message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
[4/20/2018 7:28:53 AM.678] LSPD First Response: ------------------------------
[4/20/2018 7:28:53 AM.678] LSPD First Response: Inner exceptions:
[4/20/2018 7:28:53 AM.678] LSPD First Response: ------------------------------
[4/20/2018 7:28:53 AM.679] LSPD First Response: Stack trace:
[4/20/2018 7:28:53 AM.679] LSPD First Response: at Rage.Native.NativeFunction.CallByAddress(IntPtr address, Type returnType, NativeArgument[] arguments)
[4/20/2018 7:28:53 AM.679] at Rage.Native.DynamicNativeFunction.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result)
[4/20/2018 7:28:53 AM.679] at CallSite.Target(Closure , CallSite , Object , Ped , Single , Single , Single , Int32 , Boolean )
[4/20/2018 7:28:53 AM.679] at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid7[T0,T1,T2,T3,T4,T5,T6](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
[4/20/2018 7:28:53 AM.679] at LoganPlugin.Callouts.BankRobbery.Process() in V:\GTA V Dev\PluginsRound2\LoganPlugin\LoganPlugin\Callouts\BankRobbery.cs:line 274
[4/20/2018 7:28:53 AM.680] at ?????????????????????????????????????????.?????????????????????????????????????????() in E:\GTA V\LSPD First Response\LSPD First Response\Mod\Callouts\CalloutManager.cs:line 197
[4/20/2018 7:28:53 AM.680] at Rage.GameFiber.Main()
[4/20/2018 7:28:53 AM.680] LSPD First Response: ==============================
[4/20/2018 7:28:53 AM.680] LSPD First Response: 
 

 

BTW, callout manager keeps showing up, but I deleted it. I put something in callout manager's thing but they haven't responded

Share this post


Link to post
Share on other sites
Posted (edited)
36 minutes ago, zloganrox08 said:

I know ya'll don't like snippets of code, but here is the code that I have:

 


                Game.LogTrivial("Trying to get cop to do something");
                NativeFunction.Natives.TASK_SEEK_COVR_FROM_POS<bool>(Officer1, -111f, 6462f, 32f, -1, false);
                Game.LogTrivial("It worked.. for now");

maybe spell COVER properly

and the native is clearly not a bool, it's a void

void TASK_SEEK_COVER_FROM_POS

and RPH has three functions for cover...

Capture.PNG.ca883c86bbfe58853fd840baf21cba40.PNG

Edited by NoNameSet

Share this post


Link to post
Share on other sites
Posted (edited)
Quote

maybe spell COVER properly

Thanks for pointing it out

 

 

Quote

and the native is clearly not a bool, it's a void

 

On 4/18/2018 at 11:05 PM, Pazzi said:

 

if it returns void, you may put <bool> in there.

Also, image.png.f34405a639bb93a2fc3f2c89f40e8ea5.png

 

 

10 hours ago, NoNameSet said:

void TASK_SEEK_COVER_FROM_POS

and RPH has three functions for cover...

Capture.PNG.ca883c86bbfe58853fd840baf21cba40.PNG

 

One of those three is EXIT cover... kinda the opposite of what I wanted.

The other two didn't work for me, so I'm trying this as an alternative.

 

Edited by zloganrox08
Added Picture

Share this post


Link to post
Share on other sites

@NoNameSet you can have any return type you want on a native if you don't intend to use the result, but there's no reason to have a return type if you don't need one. Just call it like NativeFunction.Natives.NATIVE_NAME(whatever). 

 

@zloganrox08 The reason your peds aren't taking cover is probably because they're cop peds. LSPDFR resets ped tasks constantly. I've tried to get cops into cover before and it just doesn't work because LSPDFR is interfering. 

Share this post


Link to post
Share on other sites
8 hours ago, PNWParksFan said:

you can have any return type you want on a native if you don't intend to use the resul

Doesn't that crash lspdfr as well or is that only for the result when not being used correctly

Share this post


Link to post
Share on other sites
15 minutes ago, NoNameSet said:

Doesn't that crash lspdfr as well or is that only for the result when not being used correctly

No. If you have a void native, you can set the return type as anything because you're not going to use it anyway. Though like Parks said, it's better to just do NativeFunction.Natives.NativeNameHere(blahblah) and omit the return type altogether.

Share this post


Link to post
Share on other sites
On ‎4‎/‎21‎/‎2018 at 4:12 AM, NoNameSet said:

I can't tell if you're joking or if you're serious

 

 

I was not joking. This forum is not for joker. :smile:

Share this post


Link to post
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

×