OFF_Gunner Posted July 17, 2019 Share Posted July 17, 2019 I would like someone to help me with this script. I wanted to make a cmd that would give gas to the player without having to be in the stocking marker. I created the script but I do not know why it does not work. I'm new to scirpt and forum. >>>> script >>>>> https://www.mediafire.com/file/fzrbkj6zmba80x3/abasteceradm.Lua/file Link to comment
WorthlessCynomys Posted July 17, 2019 Share Posted July 17, 2019 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 function getVehicleFuel(v) local fuel = getElementData(v, "fuel") if (fuel) then return fuel end return 0 end addCommandHandler("fueladm",fuel) 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) end addCommandHandler("testCall", funcName) -- 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) end addCommandHandler("testCall", funcName) -- 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: -- Client-side 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. end end addCommandHandler("setFuel", setVehFuel); 1 Link to comment
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