Jump to content

sistema de cinto de segurança rpg


Recommended Posts

function displayVehicleLoss(loss)
    local thePlayer = getVehicleOccupant(source)
    if(thePlayer) then -- Check there is a player in the vehicle
        outputChatBox("Seu veículo acabou de ter " .. tonumber(loss) .. " De Danos.", thePlayer) -- Display the message
    end
end

addEventHandler("onVehicleDamage", getRootElement(), displayVehicleLoss)
addEventHandler ( "onVehicleEnter", getRootElement(), addHelmetOnEnter )

Exemplo

quero Usar esti sistema para tirar Vida do condutor do veiculo sera que tem como 

mas que tenha um comando tipo /colocarcinto /tirarcinto para q nao perda vida quando bater 

Link to comment
function displayVehicleLoss(loss)
    local thePlayer = getVehicleOccupant(source)
    if(thePlayer) then -- Check there is a player in the vehicle
        outputChatBox("Seu veículo acabou de ter " .. tonumber(loss) .. " De Danos.", thePlayer) -- Display the message
		local playerhealth = getElementHealth(thePlayer)
		setElementHealth(theplayer, playerhealth - 10)
		outputChatBox("Você perdeu 10% de sua vida por bater o seu veiculo.", thePlayer)
		elseif getElementData(thePlayer, "seguro") then return end
    end
end

addEventHandler("onVehicleDamage", getRootElement(), displayVehicleLoss)

function cinto(thePlayer)
	if isPedInVehicle(thePlayer) then
		local veiculo = getPedOccupiedVehicle(thePlayer)
		if (getVehicleType(veiculo) == "Automobile") then
		setElementData ( thePlayer, "seguro", true )
		else return outputChatBox("Você não pode colocar o cinto de segurança fora do carro, ou em veiculos que não seja um carro.")
	end
end
addCommandHandler("colocarcinto")

Você pode completar esse código usando a função cinto como base na função para tirar cinto, o evento onVehicleExit para tirar o cinto do jogador no momento em que ele sair do veículo.

Fiz esse código bem na pressa mesmo usando as funções que o Shinigami falou, então nem testei. Quando for executar veja se dá algum erro no debug e me diga.

 

Edited by Citryon25
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...