Jump to content

Its possible create race track route on Map?


julionib

Recommended Posts

Probably its possible, the question is how?

I tried this natives based on racesp sco file:

SET_IGNORE_NO_GPS_FLAG( 1 );    START_GPS_RACE_TRACK( 10 );    for ( I = 0; I < l_U877._fU824; I++ )    {        if (l_U877._fU620[i] == 3)        {            ADD_POINT_TO_GPS_RACE_TRACK( ref l_U877._fU16[i] );        }    }RENDER_RACE_TRACK( 1 );

based on races_cr script we can see that the parameter for ADD_POINT_TO_GPS_RACE_TRACK is the position:

l_U7862 = {-968.99070000, 1170.28300000, 16.87510000};...ADD_POINT_TO_GPS_RACE_TRACK( ref l_U7862 );

maybe im missing some detail or native call...

the idea is use in Death Race IV script:

Edited by julionib
Link to comment
Share on other sites

Why do they pass it as a reference ?? A think the answer to that question will maybe lead you in the right way.

Link to comment
Share on other sites

NTAuthority

Why do they pass it as a reference ?? A think the answer to that question will maybe lead you in the right way.

not passing it a pointer would've caused the game to crash already upon calling it, so I assume he's passing a pointer (to a vector3) indeed

SsZgxdL.png

Inactive in GTA/R* title modification indefinitely pursuant to a court order obtained by TTWO. Good job acting against modding!

Link to comment
Share on other sites

@NTAuthority

 

Wait a minute, a reference isn't a pointer. Have you tested that in C++ or C#?

 

@JulioNIB

 

What have you tried so far ?

Link to comment
Share on other sites

LordOfTheBongs

@NTAuthority

 

Wait a minute, a reference isn't a pointer. Have you tested that in C++ or C#?

 

@JulioNIB

 

What have you tried so far ?

 

in the rockstar scripting language used in the SCO scripts, when a parameter is passed to a native as a reference, in c++ and .net languages it is the same as passing a pointer (.net uses GTA.Native.Pointer) to save the result

Edited by LordOfTheBongs
Link to comment
Share on other sites

unbelievable, the pointer thing worked, why R*? why ^^

next time i test a native call i will us pointer if they use the REF in the parameter, some native work fine if we ignore this.

this is the final code:

        Native.Function.Call("SET_IGNORE_NO_GPS_FLAG", 1)        Native.Function.Call("START_GPS_RACE_TRACK", 10)        Native.Function.Call("RENDER_RACE_TRACK", 0)        Dim tmpPointer As Native.Pointer = New Native.Pointer(GetType(Vector3))        For Each r As TRace.TRacePoint In RE_editRace.LoadedRacePoints            r.blipPos = myNative.attachBlipToCoord(r.pos)            r.blipPos.Icon = BlipIcon.Misc_Destination            tmpPointer.SetValue(r.pos)            Native.Function.Call("ADD_POINT_TO_GPS_RACE_TRACK", tmpPointer)        Next        Native.Function.Call("RENDER_RACE_TRACK", 1)

i removed SET_IGNORE_NO_GPS_FLAG and still working, not sure what it does ^^
to clear the track we call Native.Function.Call("RENDER_RACE_TRACK", 0)

thx for the tips guys, never expected this as solution

Edited by julionib
Link to comment
Share on other sites

@JulioNIB

 

.NET references aren't the same as pointers, and an actual pointer (a correct memory offset, which, btw, was the most probable reason for the crash mentioned by NTAuthority) is what Rockstar's scripting language actually expects when the ref kwyword is use, and not a reference to CLR owned object as it is in .NET.

 

Take a read at this msdn blog post to better understand the difference: http://goo.gl/3Adw9

Link to comment
Share on other sites

the question is why this REF thing seems to be ignored in some native calls and in others it have this effect that is like dont call the method, thats the odd part

Link to comment
Share on other sites

I haven't really seen the ref keyword being used that much (it is my first time).

 

But can you try to set the pointer value to an actual Vector3 object (instead of the Blip vector3 property) I think that will not work and maybe cause a crash. an you confirm?

 

EDIT:

 

My bad, actual is what you are doing, then the problem must be that you are actually referencing the Vector3 class object and since Vector3 class isn't in GTA Scripting language, it doesn't work. A pointer works because it is just pointing to a memory offset, which happens to be in the allocation expected by the scripting engine.

Edited by pedro2555
Link to comment
Share on other sites

LordOfTheBongs

the question is why this REF thing seems to be ignored in some native calls and in others it have this effect that is like dont call the method, thats the odd part

 

which native?

Link to comment
Share on other sites

pedro2555: its working, my last code worked :)

LordOfTheBongs: cant remember a example now, but im almost 100% sure i already used a native that had "ref" in params usage but didnt needed a pointer as param to "work", maybe this is why i have memory corrupt errors (that dont crash game/script at least) sometimes ^^

Link to comment
Share on other sites

LordOfTheBongs

Perhaps the incorrect object u used was the same size as the pointer it expected so it did not interfere with other memory... for example, a pointer to a ped and a ped's handle i believe are just 32 bit integers so bad value used but memory would still be organized correctly... im just guessing

Edited by LordOfTheBongs
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
  • 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.