A script that enhances natives and creates a object for ex. PlayerPedId()
Have you always wanted to use FiveM natives as classes in Lua? Now you can.
local ped = PlayerPedId() -- this will now return a table with natives that are related to the player ped;
local vehicle = ped.getVehicle() -- will return the vehicle that the player is in, this will also return a vehicle object;
local coords = ped.getCoords() -- will return the coords of the player;
--[[
If you want to use the handle of the player ped you can use
PlayerPedId().handle. This will return the handle of the player ped.
]]----These natives do not have the same functionality as it is the server.
--And it does not have the same natives as the client.
local ped = GetPlayerPed(source);Because FiveM doesn't allow you to replace natives you will have to include this in every script you want to use it in.
In your fxmanifest.lua file you will have to include the following:
client_scripts {
'@EnhancedNatives/client/init.lua'
}
server_scripts {
'@EnhancedNatives/server/init.lua'
}Yes, it does. You can use the following natives for vehicles:
local ped = PlayerPedId();
--[[You could also do ped.getClosestVehicle() which will return the closest vehicle to the player.]]--
local vehicle = ped.getVehicle();
local coords = vehicle.getCoords();
local speed = vehicle.getSpeed();
local fuel = vehicle.getFuelLevel();
-- setters
vehicle.setFuelLevel(100);
vehicle.setHeading(90);
---@param vector3;
vehicle.setCoords(vector3(0, 0, 0));
---@param color1 number;
---@param color2 number;
vehiucle.setColor(color1, color2)You can create a pull request and I will review it as soon as possible. I would love to see what you can come up with, And I will be happy to merge it if it is good.
You can contact me on discord: skeexs#8788 | https://discord.gg/fruaAkwNfA