Jump to content

help me


FiGo

Recommended Posts

-- client

addEventHandler( "onClientKey", root, function(button,press) 
    if button == "1" and press then 
    	triggerServerEvent("changeVehicleMode", localPlayer, "sportmod")
    elseif button == "2" and press then
    	triggerServerEvent("changeVehicleMode", localPlayer, "business")
    end
end )

-- server

function setVehicleVelocity(mode)
	local veh = getPedOccupiedVehicle(client)
	if (not veh) or getPedOccupiedVehicleSeat((client) ~= 0 ) then return end
	if (mode == "sportmod") then
		setVehicleHandling(veh, "maxVelocity", 320)
		setVehicleHandling(veh, "engineAcceleration", 20)
		setVehicleHandling(veh, "driveType", "awd")
		setVehicleHandling(veh, "handlingFlags", 0x1008000)
		outputChatBox("Sport Mod Enabled", client, 255, 255, 0, true)
	elseif (mode == "business") then
		setVehicleHandling(veh, "maxVelocity", 180)
		setVehicleHandling(veh, "engineAcceleration", 20)
		setVehicleHandling(veh, "driveType", "awd")
		setVehicleHandling(veh, "handlingFlags", 0x1008000)
		outputChatBox("Business Mod Enabled", client, 255, 255, 0, true)
	end
end


addEvent("changeVehicleMode", true)
addEventHandler("changeVehicleMode", root, setVehicleVelocity)

Have a good night

Link to comment

timer = {}
function incHp(veh)
timer[veh] =
setTimer(setElementHealth(veh), 10, 10, veh, getElementHealth(veh)+5)
end
addEventHandler("onVehicleEnter", root, incHp)

function stopincHP(veh)
if(isTimer(timer[veh] ))then
killTimer(timer[veh])
end
end
addEventHandler("onPlayerVehicleExit", root, stopincHP)

 

what's wrong with that function

Link to comment
timer = {}

function incHp(veh)
  timer[veh] =
  setTimer(setElementHealth(veh), 10, 10, veh, getElementHealth(veh)+5)
end
addEventHandler("onVehicleEnter", root, incHp)

function stopincHP(veh)
  if(isTimer(timer[veh] ))then
      killTimer(timer[veh])
  end
end
addEventHandler("onPlayerVehicleExit", root, stopincHP)

 

I just put it in the "code".

1) You're using "onVehicleEnter" which returned as 1st "thePed", not vehicle. You need "onPlayerVehicleEnter".
2) About setTimer. You have to reference a function or create a function inside.

What exactly do you want to do?

Link to comment
2 minutes ago, FiGo said:

i want to make in the timer that when a specified car is hit it auto fix by 5 % health until it reaches the 100 %

As I understand you correctly? You want to fix the vehicle when the vehicle cloose to broke.

You can use that in client-side and vehicles will never break.

addEventHandler("onClientVehicleDamage", getRootElement(), function() cancelEvent() end)

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...