Jump to content

Alguem me ajuda a resolver essse bug ta certin eu acho mas no servidor n aparece me ajuda


Recommended Posts

Posted (edited)
Markertrab = createMarker(2275.962890625, -1766.6162109375, 13.546875 -1, "cylinder",2.0 ,1, 255, 0, 255)

veh[ThePlayer] = ()
function Trab(ThePlayer)
if isElementWithinMarker(ThePlayer, Markertrab) then
if veh[ThePlayer] and isElement( veh[ThePlayer] ) then destroyElement ( veh[ThePlayer] )
veh(ThePlayer) = nil
end
x,y,z = getElementPosition(ThePlayer)
Trabalho = true
veh[ThePlayer] = createVehicle(431,2266.1005859375, -1751.3544921875, 13.3828125) 
setPedSkin ( ThePlayer, 431 )
outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true )
outputChatBox("#ff00ffLeve O Véiculo Até o Blip Em Seu Radar!!!",ThePlayer,0,0,0,true )
outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true )
end
end
addEventHandler( "onMarkerHit", Markertrab, Trab )

 

Edited by jhxp
  • MTA Team
Posted

Please use code tag <> and mark your code as Lua next time.

Also make sure to post in the correct section.

One of the [VCP] leaders // honorary member of the =PCP= gang.

 

Do not PM me your MTA:SA Client / Server support questions, Lua scripting questions, unban requests or server toplist concerns - please ask them here: MTA:SA Support subforum, here: Scripting subforum, here: Ban appeals or here: Servers instead.

For other inquiries - please expect delays in replies when messaging me.

  • Moderators
Posted
Markertrab = createMarker(2275.962890625, -1766.6162109375, 13.546875 -1, "cylinder",2.0 ,1, 255, 0, 255)
veh[ThePlayer] = () -- ERRO, uma tabela é declarada com {} e não com parênteses.

function Trab(ThePlayer)
	if isElementWithinMarker(ThePlayer, Markertrab) then
		if veh[ThePlayer] and isElement( veh[ThePlayer] ) then
			destroyElement ( veh[ThePlayer] )
			veh(ThePlayer) = nil
		end
		x,y,z = getElementPosition(ThePlayer) -- Essas variáveis provavelmente devem ser locais.
		Trabalho = true -- Qual a utilidade disso?
		veh[ThePlayer] = createVehicle(431,2266.1005859375, -1751.3544921875, 13.3828125) 
		setPedSkin ( ThePlayer, 431 )
		outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true ) -- Declare as cores nos parâmetros RGB em vez de código #hex.
		outputChatBox("#ff00ffLeve O Veiculo Até o Blip Em Seu Radar!!!",ThePlayer,0,0,0,true )
		outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true )
	end
end
addEventHandler( "onMarkerHit", Markertrab, Trab )

Comentei o que vi de problemas no código. Corrija-os.

  • Like 1

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

Como ficou seu código?

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

Fiz o código mostrando os erros e outro com a correção, leia as linhas comentadas por favor:

Markertrab = createMarker(2275.962890625, -1766.6162109375, 13.546875 -1, "cylinder",2.0 ,1, 255, 0, 255)
-- use variáveis localmente sempre que puder

veh[ThePlayer] = () -- "ThePlayer" será nulo e depois de "=" deve ser {}
function Trab(ThePlayer)
-- faltou verificar se o elemento que colidiu com a marker é mesmo um jogador

if isElementWithinMarker(ThePlayer, Markertrab) then -- função inútil, a função já será chamada no evento "onMarkerHit"

if veh[ThePlayer] and isElement( veh[ThePlayer] ) then destroyElement ( veh[ThePlayer] )

veh(ThePlayer) = nil -- forma errada de indexar a tabela; deve ser veh[ThePlayer] como está na linha acima
-- além disso, você não vai precisar setar nil aqui já que será definido logo abaixo um valor nesse endereço
end
x,y,z = getElementPosition(ThePlayer)

Trabalho = true -- troque com um: setElementData(ThePlayer, "Trabalho", true, false)

veh[ThePlayer] = createVehicle(431,2266.1005859375, -1751.3544921875, 13.3828125)

setPedSkin ( ThePlayer, 431 ) -- você está setando o mesmo ID do veículo como skin, esse id de skin não existe
-- além disso, setPedSkin é uma função obsoleta, deve ser setElementModel

outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true )
outputChatBox("#ff00ffLeve O Véiculo Até o Blip Em Seu Radar!!!",ThePlayer,0,0,0,true )
outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true )
end
end
addEventHandler( "onMarkerHit", Markertrab, Trab )

Corrigido:


local Markertrab = createMarker(2275.962890625, -1766.6162109375, 13.546875 -1, "cylinder",2.0 ,1, 255, 0, 255)

local veh = {}
function Trab(ThePlayer, md)
	if getElementType(ThePlayer) == "player" and isPedInVehicle(ThePlayer) ~= true and md then
		if veh[ThePlayer] and isElement( veh[ThePlayer] ) then destroyElement ( veh[ThePlayer] ) end
		
		local x,y,z = getElementPosition(ThePlayer)
		setElementData(ThePlayer, "Trabalho", true, false)

		veh[ThePlayer] = createVehicle(431, x, y, z + 1)

		--setElementModel ( ThePlayer, um_id_de_skin_valido_aqui )

		outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true )
		outputChatBox("#ff00ffLeve O Véiculo Até o Blip Em Seu Radar!!!",ThePlayer,0,0,0,true )
		outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true )
	end
end
addEventHandler( "onMarkerHit", Markertrab, Trab )

Lembre-se antes de testar, ative o debug mode: /debugscript 3

Se não funcionar e não mostrar erros no debug, mostre aqui o seu arquivo meta.xml.

Please do not PM me with scripting related question nor support, use the forums instead.

  • 2 weeks later...
Posted (edited)


local Markertrab = createMarker(2275.962890625, -1766.6162109375, 13.546875 -1, "cylinder",2.0 ,1, 255, 0, 255)

local veh = {}
function Trab(ThePlayer, md)
    if getElementType(ThePlayer) == "player" and isPedInVehicle(ThePlayer) ~= true and md then
        if veh[ThePlayer] and isElement( veh[ThePlayer] ) then destroyElement ( veh[ThePlayer] ) end
        
        local x,y,z = getElementPosition(ThePlayer)
        setElementData(ThePlayer, "Trabalho", true, false)

        veh[ThePlayer] = createVehicle(431, x, y, z + 1)

          setElementModel ( ThePlayer, 146 )

        outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true )
        outputChatBox("#ff00ffLeve O Véiculo Até o Blip Em Seu Radar!!!",ThePlayer,0,0,0,true )
        outputChatBox("#00ff00=========================================",ThePlayer,0,0,0,true )
    end
end
addEventHandler( "onMarkerHit", Markertrab, Trab )

 

 

<meta>
    <script src="ggg.lua" type="server"/>

</meta>

https://imgur.com/a/PH5pDSm

Edited by mahteus1

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