Jump to content

Native Checkpoint question


khorio

Recommended Posts

Callout cs:
------------
private Vector3 CheckPointV3;
public static int CheckPointHandle { get; private set; }


CheckPointHandle = Common.CreateCheckpoint(45, CheckPointV3, CheckPointV3, 5f, Color.LightBlue);

Common.cs:
------------
public static int Handle { get; private set; }


public static int CreateCheckpoint(int CheckpointType ,Vector3 position, Vector3 directTo, float radius, Color color)
        {
            Handle = Rage.Native.NativeFunction.Natives.CREATE_CHECKPOINT(            
               (int)CheckpointType,
               position.X,
               position.Y,
               position.Z,
               directTo.X,
               directTo.Y,
               directTo.Z,
               radius,
               color.R,
               color.G,
               color.B,
               color.A,
               0); 
            return Handle;
        }
[26/05/2016 04:42:38.068] LSPD First Response: 
[26/05/2016 04:42:38.068] LSPD First Response: ==============================
[26/05/2016 04:42:38.068] LSPD First Response: UNHANDLED EXCEPTION DURING GAME FIBER TICK
[26/05/2016 04:42:38.068] LSPD First Response: ------------------------------
[26/05/2016 04:42:38.069] LSPD First Response: Origin: Game fiber "<UNNAMED THREAD>".
[26/05/2016 04:42:38.069] LSPD First Response: ------------------------------
[26/05/2016 04:42:38.069] LSPD First Response: Exception type: System.Reflection.AmbiguousMatchException
[26/05/2016 04:42:38.069] LSPD First Response: Exception message: Ambiguous match found.
[26/05/2016 04:42:38.070] LSPD First Response: ------------------------------
[26/05/2016 04:42:38.070] LSPD First Response: Inner exceptions:
[26/05/2016 04:42:38.070] LSPD First Response: ------------------------------
[26/05/2016 04:42:38.070] LSPD First Response: Stack trace:
[26/05/2016 04:42:38.071] LSPD First Response: at System.DefaultBinder.SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers)
[26/05/2016 04:42:38.071] at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
[26/05/2016 04:42:38.071] at System.Type.GetMethod(String name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
[26/05/2016 04:42:38.071] at Rage.Native.DynamicNativeFunction.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result)
[26/05/2016 04:42:38.071] at CallSite.Target(Closure , CallSite , Object , Int32 , Single , Single , Single , Single , Single , Single , Single , Byte , Byte , Byte , Byte , Int32 )
[26/05/2016 04:42:38.072] at CallSite.Target(Closure , CallSite , Object , Int32 , Single , Single , Single , Single , Single , Single , Single , Byte , Byte , Byte , Byte , Int32 )
[26/05/2016 04:42:38.072] at LSPDFR_Khallouts.Callouts.Common.CreateCheckpoint(Int32 CheckpointType, Vector3 position, Vector3 directTo, Single radius, Color color) in E:\_GTADEV\LSPDFR Khallouts\LSPDFR Khallouts\Callouts\Common.cs:line 288
[26/05/2016 04:42:38.072] at LSPDFR_Khallouts.Callouts.Terrorist__Activity.<runoperation>b__76_0() in E:\_GTADEV\LSPDFR Khallouts\LSPDFR Khallouts\Callouts\Terrorist_Activity.cs:line 384
[26/05/2016 04:42:38.072] at Rage.GameFiber.Main()
[26/05/2016 04:42:38.073] LSPD First Response: ==============================
[26/05/2016 04:42:38.073] LSPD First Response: 

 

Is there something inherently wrong with this call?

Link to comment
Share on other sites

2 hours ago, ainesophaur said:

NativeFunction.Natives.CREATE_CHECKPOINT

You need to use pascal case names when calling native functions using the dynamic "Natives" property.


Rage.Native.NativeFunction.Natives.CreateCheckpoint

Same error sadly

Link to comment
Share on other sites

 

You also need to set the return type if you want to get the handler. Without setting a return type of <unit> the native is going to return as a void function

NativeFunction.Natives.CreateCheckpoint<uint>(0, position.X, position.Y, position.Z, 0f, 0f, 0f, 5f, 255, 0, 0, 1000, 0);
Link to comment
Share on other sites

Here's a constructor of my Checkpoint class used in Transportation:

public Checkpoint(Vector3 Position, float Radius, System.Drawing.Color Color)
        {
            _fRadius = Radius;
            _vPosition = Position;

            handle = Rage.Native.NativeFunction.CallByName<uint>(
                        "CREATE_CHECKPOINT", 5, //5 is a type ID, check natives documentation @ http://www.dev-c.com/nativedb/
                        Position.X, Position.Y, Position.Z - 7.0f,
                        Position.X, Position.Y, Position.Z,
                        Radius, (int)Color.R, (int)Color.G, (int)Color.B,
                        100, 0);

            _bExists = true;
        }

 

 

Link to comment
Share on other sites

5 hours ago, ainesophaur said:

NativeFunction.Natives.CREATE_CHECKPOINT

You need to use pascal case names when calling native functions using the dynamic "Natives" property.


Rage.Native.NativeFunction.Natives.CreateCheckpoint

No, you don't have to use pascal case, if the provided name contains an underscore it will be treated as a complete native name and it will ignore casing. The only thing needed is to set the return type.
In the case of the OP the return type as uint won't work because his Handle property is an int, he either changes the return type to int or the Handle to uint.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...