formel117 Posted January 18, 2014 Share Posted January 18, 2014 Hey guys. I'm wondering if it is possible to call native functions that have out variables. I need to use this function: static void GetNetworkIdFromVehicle(Vehicle veh, u32 *networkID) { NativeInvoke::Invoke<NATIVE_GET_NETWORK_ID_FROM_VEHICLE, ScriptVoid>(veh, networkID); } Which has the output networkID, how would I go about calling this function using GTA.Native.Call and getting the output? Thanks. Link to comment Share on other sites More sharing options...
InfamousSabre Posted January 19, 2014 Share Posted January 19, 2014 GTA.Native.Function.Call<bool>("DOES_CHAR_HAVE_WEAPON", Game.LocalPlayer.Character, Weapon.AK47.GetHashCode()) (So many things wrong with that line, but its just an example) the returned type goes inbetween the < and > If you are learning how to use scripthook, i suggest you find other mods that are .cs files (since they can be opened so easily) and see how they were made. Also, read the Scripthook.net documentation. Its very helpful. Link to comment Share on other sites More sharing options...
formel117 Posted January 19, 2014 Author Share Posted January 19, 2014 The returntype works fine if the native function has one yes, but some functions like the one in my previous code tag doesn't. Instead it has an "out" variable that the result will be sent to, but I do not know how to get that result in Scripthook.NET. In C++ it would be simple: u32 networkIdResult;GetNetworkIdFromVehicle(vehicle, &networkIdResult); //this is a void, no return type But in Scripthook.NET it's complicated and I can't figure out how to do it. Link to comment Share on other sites More sharing options...
InfamousSabre Posted January 19, 2014 Share Posted January 19, 2014 (edited) ah right. seems i didnt pay much attention to the actual function lollook at this code and you will see int Screen = 0;GTA.Native.Pointer ViewportId = new GTA.Native.Pointer(typeof(int));GTA.Native.Function.Call("GET_GAME_VIEWPORT_ID", ViewportId);Screen = ViewportId; this code gets the viewport's ID as ViewportID and stores it as Screen Edited January 19, 2014 by InfamousSabre Michael Wojtanis 1 Link to comment Share on other sites More sharing options...
formel117 Posted January 20, 2014 Author Share Posted January 20, 2014 Thanks, this solves a lot of issues. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now