Jump to content

[AJUDA] isElementWithinMarker dando erro


Recommended Posts

Posted

Um amigo meu pediu para fazer um script de trabalho simples para ele blz desde de quando comecei a fazer trabalho sempre usava o mesmo codigo e nunca dava erro agora não sei porque está dando erro.

Erro : Bad argument @ 'isElementWithinMarker' [Expected element at argument 1]

server-side
 

Marker_Inicio = createMarker(2494.508, -1750.817, 13.481 -1, "cylinder", 2, 255, 255, 255, 120)
Blip_Inicio = createBlipAttachedTo(Marker_Inicio, 42)
Marker_Fim = createMarker(2478.646, -1728.972, 13.383 -1, "cylinder", 2, 255, 255, 255, 120)
Blip_Fim = createBlipAttachedTo(Marker_Fim, 19)

veh = {}
function Inicio (source)
	if isElementWithinMarker(source, Marker_Inicio) then
		if veh[source] and isElement(veh[source]) then destroyElement( veh[source] )
			veh[source] = nil
		end
		veh[source] = createVehicle(422, 2481.013, -1747.164, 13.547, -0, 0, 2.78)
		warpPedIntoVehicle(source, veh[source])
	end
end
addEventHandler("onMarkerHit", Marker_Inicio, Inicio)

function Fim (source)
	if veh[source] and isElement(veh[source]) then destroyElement( veh[source] )
		veh[source] = nil
	end
end
addEventHandler("onMarkerHit", Marker_Fim, Fim)

 

Posted (edited)

Qual a utilidade da função isElementWithinMarker sendo a já tem o evento onMarkerHit?

Tire essa função pois ela parece desnecessária e use um nome mais adequado para o parâmetro em vez de source.

Edited by DNL291
  • Thanks 1

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

Posted (edited)
15 minutes ago, DNL291 said:

Qual a utilidade da função isElementWithinMarker sendo a já tem o evento onMarkerHit?

Tire essa função pois ela parece desnecessária e use um nome mais adequado para o parâmetro em vez de source.

Quando tiro da erro no primeiro argumento no warpPedIntoVehicle.

É porque eu aprendi assim e eu acabo me acostumando

Ja tentei thePlayer e player e sempre dando erro desse argumentos.

Edited by +[T]rakin
Posted

Nunca é tarde pra perder os maus costumes. Sobre o erro em warpPedIntoVehicle, tente assim que deve funcionar:


local Marker_Inicio = createMarker(2494.508, -1750.817, 13.481 -1, "cylinder", 2, 255, 255, 255, 120)
local Blip_Inicio = createBlipAttachedTo(Marker_Inicio, 42)
local Marker_Fim = createMarker(2478.646, -1728.972, 13.383 -1, "cylinder", 2, 255, 255, 255, 120)
local Blip_Fim = createBlipAttachedTo(Marker_Fim, 19)

local veh = {}
function Inicio (thePlayer)
	if getElementType(thePlayer) == "player" and not (isPedInVehicle(thePlayer) then
		if veh[thePlayer] and isElement(veh[thePlayer]) then destroyElement( veh[thePlayer] )
			veh[thePlayer] = nil
		end
		veh[thePlayer] = createVehicle(422, 2481.013, -1747.164, 13.547, -0, 0, 2.78)
		warpPedIntoVehicle(thePlayer, veh[thePlayer])
	end
end
addEventHandler("onMarkerHit", Marker_Inicio, Inicio)

function Fim (thePlayer)
	if veh[thePlayer] and isElement(veh[thePlayer]) then destroyElement( veh[thePlayer] )
		veh[thePlayer] = nil
	end
end
addEventHandler("onMarkerHit", Marker_Fim, Fim)

 

  • Thanks 1

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

Posted

Pegou perfeito mas provavelmente algum jogador vai passa com o carro no trabalho no Marker_Inicio e se isso acontece vai está dando erro no primeiro arguento do getElementType

  • Moderators
Posted

Não vai. Pois dará false naquela condição e o script vai ignorar.

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

Posted

getElementType aceita qualquer elemento no argumento ao contrário da warpPedIntoVehicle que só aceita o ped, então não vai dar erro.

Mas se você mudar a ordem deixando primeiro a verificação isPedInVehicle certamente dará aquele mesmo erro que na função warpPedIntoVehicle.

  • Like 1

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

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