local screenW,screenH = guiGetScreenSize()
local resW,resH = 1366,768
local x,y = (screenW/resW), (screenH/resH)
local font = dxCreateFont("fonts/font.ttf", 10)
local MaxFuel = 100
local fuel = getElementData(v, "fuel")
if (fuel) then
Hello! You can insert code blocks with the <> sign. Use it next time.
Your problem is that this code does not set any value. In order to set the "amount of fuel" you have to use setElementData to set the value for fuel. Also functions can get parameters/arguments from command calls. You can catch those arguments in the paramter list after the function's name.
-- Catch parameters of command call
-- On server-side
function funcName(player, command, value1, value2)
-- When you type /testCall it will call the funcName function, providing the calling player, the command that has been used for the call, and additional values typed in alongside the command. In command calls, additional values are seperated with spaces. For example: /testCall value1 value2
-- On client-side
function funcName(command, value1, value2)
-- The same playbook here, except that client-side calls do not provide the calling player, because it is obvious that the calling player is the client itself. The localPlayer.
Now your function should look somehow like this:
function setVehFuel(cmd, fuel)
local veh = getPedOccupiedVehicle(localPlayer); -- Gets the currently occupied vehicle of the player, returns false if the player is not in a vehicle.
if (veh) then -- Translates to if (veh ~= false/nil) then
setElementData(veh, "fuel", tonumber(fuel)); -- Sets the fuel element data of the vehicle to the value that the caller provided converted into a number from string.