Search the Community
Showing results for tags 'Natives'.
-
Hey folks! I am currently trying to get the original events as I need a specific event that is not provided by Rage. I have tried using javascript to read the events using the three natives: - GET_NUMBER_OF_EVENTS - GET_EVENT_AT_INDEX - GET_EVENT_DATA Reading the events and outputting the eventId works fine, but I can't read the eventdata. I thought maybe it was just JavaScript and wrote a script in C# for it. Unfortunately I have the same problem there: GET_EVENT_DATA always returns FALSE and the passed variable 'eventData' does not change. The Script: using System; using System.Collections.Generic; using RAGE; namespace ClientEvents { public class Main : RAGE.Events.Script { public Main() { RAGE.Events.Tick += this.OnTick; } public void OnTick(List<Events.TickNametagData> nametags) { int eventGroup = 0; for (int eventIndex = 0; eventIndex < RAGE.Game.Invoker.Invoke<int>(RAGE.Game.Natives.GetNumberOfEvents, eventGroup); eventIndex++) { int eventId = RAGE.Game.Invoker.Invoke<int>(RAGE.Game.Natives.GetEventAtIndex, eventGroup, eventIndex); int[] eventData = new int[32]; Chat.Output($"Event {eventId} was fired."); if (!RAGE.Game.Invoker.Invoke<bool>(RAGE.Game.Natives.GetEventData, eventGroup, eventIndex, eventData, 32)) { Chat.Output("Failed to retrieve EventData"); } } } } }
-
For those you want to use the natives functions here's a file that will help you. Link : https://github.com/Mcfloy/natives To use it simply add it on your folder and type : const NATIVES = require('folder/natives'); Only JS for now, I'll probably do a TS one based on the work of CocaColaBear or Pet-Platoon. (A little example to show you how to get infinite ammo) var weaponHash = NATIVES.WEAPON.GET_SELECTED_PED_WEAPON(player.handle); mp.game.graphics.notify(`Result: ${weaponHash}`); NATIVES.WEAPON.SET_PED_INFINITE_AMMO(player.handle, true, weaponHash);
