C# native function calls

Hey there!

Im a newbe in C# and to learn it, i started to convert my Lua-Scripts into C#.
I started with my vehicle HUD, where i have a problem and totaly stuck:

I found the method “World.GetStreetName()” to get the name of the street for given Vector3 coords.
Unfortunately it gives me only the name of the current street and not the name of a crossing street like the native function “GET_STREET_NAME_AT_COORD”.

local streetA, streetB = Citizen.InvokeNative(0x2EB41072B4C1E4C0, coords.x, coords.y, coords.z, Citizen.PointerValueInt(), Citizen.PointerValueInt())
private static Tuple<string, string> getStreetNameFromCoords(Vector3 coords)
        {
            Tuple<int, int> streetHash = Function.Call<Tuple<int, int>>(Hash.GET_STREET_NAME_AT_COORD, coords.X, coords.Y, coords.Z);
            
            string streetName1 = Function.Call<string>(Hash.GET_STREET_NAME_FROM_HASH_KEY, streetHash.Item1);
            if (streetHash.Item2 != 0)
            {
                string streetName2 = Function.Call<string>(Hash.GET_STREET_NAME_FROM_HASH_KEY, streetHash.Item2);
                return new Tuple<string, string>(streetName1, streetName2);
            }

            return new Tuple<string, string>(streetName1, streetName1);
        }

I tried to use the native function, but totaly failed because i don’t understand how to use it if the return is “void”.
Stupid code, i know, but atleast i tried.
Is there some sort of documentation/tutorial/examples?

I’m not at a computer so, I’m completely speculating in this answers (and it’ll probably be wrong).

Can’t you send references to Function.Calls?

For example, couldn’t you do

int street, crossing;
Function.Call( HASH_HERE, param1, param2, param3, &street, &crossing);

string something = Function.Cal <string>(HASH_HERE, street)

Thats what i also found here.
But this needs to run in an unsafe context, what seems to be not supported.

Use OutputArgument.

You mean like this?

int streetHash1 = 0;
int streetHash2 = 0;
Function.Call(Hash.GET_STREET_NAME_FROM_HASH_KEY, coords.X, coords.Y, coords.Z, out streetHash1, out streetHash2);

With this i get the following error:

Argument 5 may not be passed with the ‘out’ keyword
Argument 6 may not be passed with the ‘out’ keyword

No, more like this:

var hash1Ptr = new OutputArgument();
Function.Call(Hash.BLAH, blah, hash1Ptr);
int hash1 = hash1Ptr.GetResult<int>();
private static Tuple<string, string> getStreetNameFromCoords(Vector3 coords)
{
     var streetHash1Pointer = new OutputArgument();
     var streetHash2Pointer = new OutputArgument();
     Function.Call(Hash.GET_STREET_NAME_FROM_HASH_KEY, coords.X, coords.Y, coords.Z, streetHash1Pointer, streetHash2Pointer);
     int streetHash1 = streetHash1Pointer.GetResult<int>();
     int streetHash2 = streetHash2Pointer.GetResult<int>();

     //return new Tuple<string, string>(streetHash1.ToString(), streetHash2.ToString());

     string streetName1 = Function.Call<string>(Hash.GET_STREET_NAME_FROM_HASH_KEY, streetHash1);
     if (streetHash2 != 0 && streetHash2 != streetHash1)
     {
         string streetName2 = Function.Call<string>(Hash.GET_STREET_NAME_FROM_HASH_KEY, streetHash2);
         return new Tuple<string, string>(streetName1, streetName2);
     }

      return new Tuple<string, string>(streetName1, streetName1);
}

With this i get on each tick (same pos) a different value at “streetHash1Pointer” and “streetHash2Pointer” (e.g. pic top left corner).
The “GET_STREET_NAME_FROM_HASH_KEY” function dosen’t return with this values either.

Pic1
Pic2