Jump to content

Script de Handling não funciona. AJUDA


Recommended Posts

Posted

Olá, eu tava dando uma olhada no setVehicleHandling, e ví que tem um exemplo para alterar o handling de um carro atravez da ID dele etc. Eu tentei fazer com que assim que o carro fosse spawnado, ele iria ficar com aquela handling (no meu caso, servidor de drift/corrida). Bom, quando fiz o teste, o handling não foi ativado. Alguém poderia me ajudar??


s-side

local predefinedHandling = {
    [527] = { 
            ["driveType"] = "rwd",
            ["engineAcceleration"] = 500,
            ["dragCoeff"] = 1.5,
            ["maxVelocity"] = 300,
            ["tractionMultiplier"] = 0.7,
            ["tractionLoss"] = 0.8,
            ["collisionDamageMultiplier"] = 0.4,
            ["engineInertia"] = -175,
            ["steeringLock"] = 75,
            ["numberOfGears"] = 4,
            ["suspensionForceLevel"] = 0.8,
            ["suspensionDamping"] = 0.8,
            ["suspensionUpperLimit"] = 0.33,
            ["suspensionFrontRearBias"] = 0.3,
            ["mass"] = 1800,
            ["turnMass"] = 3000,
            ["centerOfMass"] = { [1]=0, [2]=-0.2, [3]=-0.5 }, 
    },
}

for i,v in pairs (predefinedHandling) do
    if i then
        for handling, value in pairs (v) do
            if not setModelHandling (i, handling, value) then
                outputDebugString ("* Predefined handling '"..tostring(handling).."' for vehicle model '"..tostring(i).."' could not be set to '"..tostring(value).."'")
            end
        end
    end
end

for _,v in ipairs (getElementsByType("vehicle")) do
    if v and predefinedHandling[getElementModel(v)] then
        for k,vl in pairs (predefinedHandling[getElementModel(v)]) do
            setVehicleHandling (v, k, vl)
        end
    end
end

function resetHandling()
    for model in pairs (predefinedHandling) do
        if model then
            for k in pairs(getOriginalHandling(model)) do
                setModelHandling(model, k, nil)
            end
        end
    end

    for _,v in ipairs (getElementsByType("vehicle")) do
        if v then
            local model = getElementModel(v)
            if predefinedHandling[model] then
                for k,h in pairs(getOriginalHandling(model)) do
                    setVehicleHandling(v, k, h)
                end
            end
        end
    end
end
addEventHandler("onResourceStop", resourceRoot, resetHandling)

 

  • Moderators
Posted

Não vai funcionar para veículos que forem criados depois do resource iniciar.

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! spacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

Posted

Tente isso:

local inUse = {}
local handling = {
	[527] = function (veh)
		-- cole aqui o código gerado em https://www.bento.me.uk/phs/mtahc/hndl2lua.html
	end,
	[411] = function (veh)
		-- cole aqui o código gerado em https://www.bento.me.uk/phs/mtahc/hndl2lua.html
	end,
}


addEventHandler ( "onPlayerVehicleEnter", root,
	function(veh,seat)
		if seat ~= 0 then return end
		if inUse[veh] then return end
		if not handling[getElementModel(veh)] then return end
		handling[getElementModel(veh)](veh)
		inUse[veh] = true
	end
)

addEventHandler ( "onVehicleExplode", root,
	function()
		if inUse[source] then inUse[source] = nil end
	end
)

addEventHandler ( "onElementDestroy", root,
	function()
		if getElementType(source) == "vehicle" then
			if inUse[source] then inUse[source] = nil end
		end
	end
)

Não sei se o seu caso é converter os handlings que veem em alguns mods de veículos, se for, basta converter nesse ferramenta: https://sites.google.com/view/potholestudios/gaming/multi-theft-auto/handling-to-lua-converter e então substituir o comentário pelo código gerado...

(Não testei o script)

Posted
On 23/06/2018 at 16:24, MaligNos said:

Tente isso:


local inUse = {}
local handling = {
	[527] = function (veh)
		-- cole aqui o código gerado em https://www.bento.me.uk/phs/mtahc/hndl2lua.html
	end,
	[411] = function (veh)
		-- cole aqui o código gerado em https://www.bento.me.uk/phs/mtahc/hndl2lua.html
	end,
}


addEventHandler ( "onPlayerVehicleEnter", root,
	function(veh,seat)
		if seat ~= 0 then return end
		if inUse[veh] then return end
		if not handling[getElementModel(veh)] then return end
		handling[getElementModel(veh)](veh)
		inUse[veh] = true
	end
)

addEventHandler ( "onVehicleExplode", root,
	function()
		if inUse[source] then inUse[source] = nil end
	end
)

addEventHandler ( "onElementDestroy", root,
	function()
		if getElementType(source) == "vehicle" then
			if inUse[source] then inUse[source] = nil end
		end
	end
)

Não sei se o seu caso é converter os handlings que veem em alguns mods de veículos, se for, basta converter nesse ferramenta: https://sites.google.com/view/potholestudios/gaming/multi-theft-auto/handling-to-lua-converter e então substituir o comentário pelo código gerado...

(Não testei o script)

Quero colocar hand de drift pra alguns carros..Vou dar uma olhada ! Valeu !!

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...