Jump to content

Problema com bind


Recommended Posts

Posted

Estou fazendo um sistema que ao passar pelo marker e apertar "e", spawnaria um veiculo, porem esta spawnando 2 veiculos (quando aperta e quando solta a tecla), mas queria que spawnasse apenas quando apertasse.

O código esta assim: 

local g1 = createMarker (1517.796, -694.59, 92.00, "cylinder", 3.0, 184,0,0, 150)

addEventHandler ("onClientMarkerHit", g1, function()
addEventHandler ("onClientKey", root, function (button, press)
if isElementWithinMarker (localPlayer, g1) then
	if button == "e" then
        createVehicle ( 402, 1517.172, -690.4, 94.75, 0, 0, 100)
    end 
end 
end )
end )

 

Posted
local g1 = createMarker (1517.796, -694.59, 92.00, "cylinder", 3.0, 184,0,0, 150)

addEventHandler ("onClientKey", root, function (btn, press)
    if isElementWithinMarker (localPlayer, g1) and press then
        if btn == "e" then 
            createVehicle (402, 1517.172, -690.4, 94.75, 0, 0, 100)
        end
    end
end)
  • pressOrRelease: This refers to whether they were pressing or releasing the key, true when pressing, false when releasing.

É necessário verificar se a tecla esta pressionada ou solta.

Posted
3 minutes ago, Jonas^ said:

local g1 = createMarker (1517.796, -694.59, 92.00, "cylinder", 3.0, 184,0,0, 150)

addEventHandler ("onClientKey", root, function (btn, press)
    if isElementWithinMarker (localPlayer, g1) and press then
        if btn == "e" then 
            createVehicle (402, 1517.172, -690.4, 94.75, 0, 0, 100)
        end
    end
end)
  • pressOrRelease: This refers to whether they were pressing or releasing the key, true when pressing, false when releasing.

É necessário verificar se a tecla esta pressionada ou solta.

Obrigado! Porem ele esta spawnando o veiculo mas não estou conseguindo entrar. É bug do meu mta ou do codigo?

  • Moderators
Posted

O script é client-side?

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.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
1 minute ago, Lord Henry said:

O script é client-side?

sim

 

Just now, Jonas^ said:

Sim, onClientKey é somente client-side.

--

@PlaKS Acho que seja bug no seu MTA.

ok, obrigado

  • Moderators
Posted (edited)

Veículos criados client-side servem somente para visualização. Não são utilizáveis pelos jogadores.

Quote

Note: Vehicles (and other elements) created client-side are only seen by the client that created them, aren't synced and players cannot enter them. They are essentially for display only.

 

Edited by Lord Henry

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.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.

  • Moderators
Posted

Só usar um triggerServerEvent na hora de criar o veículo.

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.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.

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