carlos eduardo Posted January 11, 2018 Posted January 11, 2018 Ola Eu estou aqui com esse erro: Bad argument @ 'getElementData' [Expected element at argument 1, got nil] Queria saber como eu arrumaria isso. Codigo: ----------------------------------Função começo trabalho---------------------------------- function trabalho (source, player) if isElementWithinMarker(source, MarkerTrab)then if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) veh[source] = nil end x,y,z = getElementPosition(source, player) trabalho = true veh[source] = createVehicle(408, 2150.14453125, -1977.4909667969, 13.546875) warpPedIntoVehicle (source, veh[source]) setElementData( source, "Emprego", "Lixeiro" ) outputChatBox ( "#007ff7Você agora esta empregado", getRootElement(), 255, 0, 0, true ) setElementVisibleTo(MarkerTrab1, source, true) setElementVisibleTo(BlipTrab1, source, true) end end addEventHandler("onMarkerHit", MarkerTrab, trabalho) ------------------------------------------------------------------------------------------- ----------------------------------------1Mark---------------------------------------------- function congelar1( hitElement, mesmaDimensao, source ) if getElementType(hitElement) == "vehicle" and mesmaDimensao then -- O Elemento que atingir a marca deve ser veículo if getElementData(source, "Lixeiro" , "Emprego") then setElementFrozen( hitElement, true ) -- true: Congelado | false: Descongelado setTimer( function(veh) setElementFrozen( veh, false ) end, 10000, 1, hitElement ) outputChatBox ( "#0077ff====================", getRootElement(), 255, 0, 0, true ) outputChatBox ( "#00ff77Aguardando pegar o lixo", getRootElement(), 255, 0, 0, true ) outputChatBox ( "#0077ff====================", getRootElement(), 255, 0, 0, true ) destroyElement (MarkerTrab1) destroyElement (BlipTrab1) else outputChatBox ( "#0077ffVocê não é um lixeiro", getRootElement(), 255, 0, 0, true ) end end -- fechando a condição end -- fechando a função addEventHandler("onMarkerHit", MarkerTrab1, congelar1)
DNL291 Posted January 12, 2018 Posted January 12, 2018 Então carlos eduardo, Você já tinha me enviado uma MP sobre esse mesmo problema, e eu tinha feito um código adicionando o element-data, não sei se chegou a mensagem pra você, mas vou postar o código aqui. Client: ---------------------------------Criadores-------------------------------- ---Feito Por ~#Nops'^ e com a ajuda de DNL291--- -------------------------------------------------------------------------- addEventHandler( "onClientResourceStart", resourceRoot, function() ----------------------------------Marcas---------------------------------- MarkerTrab = createMarker (2182.1667480469, -1984.1248779297, 12.551010131836, "cylinder",2.0 , 255, 255, 0, 255) -------------------------------------------------------------------------- ----------------------------------Blips---------------------------------- BlipTrab = createBlipAttachedTo( MarkerTrab, 56 ) -------------------------------------------------------------------------- addEventHandler( "onClientMarkerHit", resourceRoot, onMarkerHitHandler ) end ) ------------------------------------------------------------------------------------------- ----------------------------------1Marcação------------------------------------------------ function onMarkerHitHandler( hitElement, mesmaDimensao ) if source == MarkerTrab1 then -- Primeira rota if getElementType(hitElement) == "vehicle" and getVehicleOccupant(hitElement) == localPlayer and mesmaDimensao then if getElementData( localPlayer, "Emprego" ) ~= "lixeiro" then return end; setElementFrozen( localPlayer, true ) -- true: Congelado | false: Descongelado setTimer( function(p) setElementFrozen( p, false ) end, 10000, 1, localPlayer ) outputChatBox ( "#0077ff====================", 255, 0, 0, true ) outputChatBox ( "#00ff77Aguardando pegar o lixo", 255, 0, 0, true ) outputChatBox ( "#0077ff====================", 255, 0, 0, true ) destroyElement (source) destroyElement (BlipTrab1) -- Criar segunda rota setTimer( function() MarkerTrab2 = createMarker (2182.1667480469, -1984.1248779297, 12.551010131836, "cylinder",2.0 , 255, 255, 0, 255) BlipTrab2 = createBlipAttachedTo( MarkerTrab2, 41 ) end, 1000, 1 ) end elseif source == MarkerTrab then -- Entrar no emprego if hitElement == localPlayer and mesmaDimensao then if getElementData( localPlayer, "Emprego" ) == "lixeiro" then return outputChatBox( "Você já está trabalhando nessa profissão!", 230,0,0 ) end triggerServerEvent( "server:criarVeiculo", localPlayer, 403 ) outputChatBox ( "#00ff77====================", 255, 0, 0, true ) outputChatBox ( "#0077ffVocê esta trabalhando de lixeiro, siga as marcas até o final para pegar seu $", 255, 0, 0, true ) outputChatBox ( "#00ff77====================", 255, 0, 0, true ) MarkerTrab1 = createMarker (2218.8298339844, -1784.7091064453, 12.234619140625, "cylinder",2.0 , 255, 255, 0, 255) BlipTrab1 = createBlipAttachedTo( MarkerTrab1, 41 ) end end end ------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- Server: local veh = { } function criarVeiculo( ID ) if ( isElement(veh[source]) ) then destroyElement(veh[source]) end veh[source] = createVehicle(tonumber(ID), getElementPosition(source)) warpPedIntoVehicle(source, veh[source]) setElementData( source, "Emprego", "lixeiro" ) end addEvent( "server:criarVeiculo", true ) addEventHandler( "server:criarVeiculo", root, criarVeiculo )
carlos eduardo Posted January 12, 2018 Author Posted January 12, 2018 é q eu tou iniciando o script e n da erro nem nada e tbm n aparece mark nem nada
DNL291 Posted January 12, 2018 Posted January 12, 2018 O código que postei não funciona? Não vejo nada errado no código. E acabei de testar, a marca de entrar no emprego funciona e dá o veículo. Se não tiver funcionando com você, mostre o seu meta.xml.
carlos eduardo Posted January 12, 2018 Author Posted January 12, 2018 <meta> <info author="Nop & DNL291" version="1.0.0" Name="trabalholixeiro" description="um breve trabalho de lixeiro para seu server" type="script" /> <script src="trabalho.lua" type="server" /> <script src="server.lua" type="server" /> </meta> acho q intendi agora, eu tinha posto errado na linha 3, ao invés de por client eu puis server.
DNL291 Posted January 12, 2018 Posted January 12, 2018 4 minutes ago, carlos eduardo said: acho q intendi agora, eu tinha posto errado na linha 3, ao invés de por client eu puis server. Deve ter sido isso, e quando usa funções no lado errado, o debug mostra erro.
carlos eduardo Posted January 12, 2018 Author Posted January 12, 2018 ---------------------------------Criadores-------------------------------- ---Feito Por ~#Nops'^ e com a ajuda de DNL291--- -------------------------------------------------------------------------- addEventHandler( "onClientResourceStart", resourceRoot, function() ----------------------------------Marcas---------------------------------- MarkerTrab = createMarker (2182.1667480469, -1984.1248779297, 12.551010131836, "cylinder",2.0 , 255, 255, 0, 255) MarkerTrab2 = createMarker (2182.1667480469, -1984.1248779297, 12.551010131836, "cylinder",2.0 , 255, 255, 0, 255) -------------------------------------------------------------------------- ----------------------------------Blips---------------------------------- BlipTrab = createBlipAttachedTo( MarkerTrab, 56 ) BlipTrab2 = createBlipAttachedTo( MarkerTrab, 56 ) -------------------------------------------------------------------------- addEventHandler( "onClientMarkerHit", resourceRoot, onMarkerHitHandler ) end ) ------------------------------------------------------------------------------------------- ----------------------------------1Marcação------------------------------------------------ function onMarkerHitHandler( hitElement, mesmaDimensao ) if source == MarkerTrab1 then -- Primeira rota if getElementType(hitElement) == "vehicle" and getVehicleOccupant(hitElement) == localPlayer and mesmaDimensao then if getElementData( localPlayer, "Emprego" ) ~= "lixeiro" then return end; setElementFrozen( localPlayer, true ) -- true: Congelado | false: Descongelado setTimer( function(p) setElementFrozen( p, false ) end, 10000, 1, localPlayer ) outputChatBox ( "#0077ff====================", 255, 0, 0, true ) outputChatBox ( "#00ff77Aguardando pegar o lixo", 255, 0, 0, true ) outputChatBox ( "#0077ff====================", 255, 0, 0, true ) destroyElement (source) destroyElement (BlipTrab1) -- Criar segunda rota setTimer( function() MarkerTrab2 = createMarker (2182.1667480469, -1984.1248779297, 12.551010131836, "cylinder",2.0 , 255, 255, 0, 255) BlipTrab2 = createBlipAttachedTo( MarkerTrab2, 41 ) end, 1000, 1 ) end elseif source == MarkerTrab then -- Entrar no emprego if hitElement == localPlayer and mesmaDimensao then if getElementData( localPlayer, "Emprego" ) == "lixeiro" then return outputChatBox( "Você já está trabalhando nessa profissão!", 230,0,0 ) end triggerServerEvent( "server:criarVeiculo", localPlayer, 403 ) outputChatBox ( "#00ff77====================", 255, 0, 0, true ) outputChatBox ( "#0077ffVocê esta trabalhando de lixeiro, siga as marcas até o final para pegar seu $", 255, 0, 0, true ) outputChatBox ( "#00ff77====================", 255, 0, 0, true ) --------------------------aqui seria o marker do ponto de parada??---------------------------------------------------------------- MarkerTrab1 = createMarker (2218.8298339844, -1784.7091064453, 12.234619140625, "cylinder",2.0 , 255, 255, 0, 255) BlipTrab1 = createBlipAttachedTo( MarkerTrab1, 41 ) ---------------------------------------------------------------------------------------------------------------------------------- end end end ------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- não esta dando nenhum erro, só que ao eu passar no primeiro ponto de parada e n da nada, não freeza nem nada 1 minute ago, carlos eduardo said: ---------------------------------Criadores-------------------------------- ---Feito Por ~#Nops'^ e com a ajuda de DNL291--- -------------------------------------------------------------------------- addEventHandler( "onClientResourceStart", resourceRoot, function() ----------------------------------Marcas---------------------------------- MarkerTrab = createMarker (2182.1667480469, -1984.1248779297, 12.551010131836, "cylinder",2.0 , 255, 255, 0, 255) MarkerTrab2 = createMarker (2182.1667480469, -1984.1248779297, 12.551010131836, "cylinder",2.0 , 255, 255, 0, 255) -------------------------------------------------------------------------- ----------------------------------Blips---------------------------------- BlipTrab = createBlipAttachedTo( MarkerTrab, 56 ) BlipTrab2 = createBlipAttachedTo( MarkerTrab, 56 ) -------------------------------------------------------------------------- addEventHandler( "onClientMarkerHit", resourceRoot, onMarkerHitHandler ) end ) ------------------------------------------------------------------------------------------- ----------------------------------1Marcação------------------------------------------------ function onMarkerHitHandler( hitElement, mesmaDimensao ) if source == MarkerTrab1 then -- Primeira rota if getElementType(hitElement) == "vehicle" and getVehicleOccupant(hitElement) == localPlayer and mesmaDimensao then if getElementData( localPlayer, "Emprego" ) ~= "lixeiro" then return end; setElementFrozen( localPlayer, true ) -- true: Congelado | false: Descongelado setTimer( function(p) setElementFrozen( p, false ) end, 10000, 1, localPlayer ) outputChatBox ( "#0077ff====================", 255, 0, 0, true ) outputChatBox ( "#00ff77Aguardando pegar o lixo", 255, 0, 0, true ) outputChatBox ( "#0077ff====================", 255, 0, 0, true ) destroyElement (source) destroyElement (BlipTrab1) -- Criar segunda rota setTimer( function() MarkerTrab2 = createMarker (2182.1667480469, -1984.1248779297, 12.551010131836, "cylinder",2.0 , 255, 255, 0, 255) BlipTrab2 = createBlipAttachedTo( MarkerTrab2, 41 ) end, 1000, 1 ) end elseif source == MarkerTrab then -- Entrar no emprego if hitElement == localPlayer and mesmaDimensao then if getElementData( localPlayer, "Emprego" ) == "lixeiro" then return outputChatBox( "Você já está trabalhando nessa profissão!", 230,0,0 ) end triggerServerEvent( "server:criarVeiculo", localPlayer, 403 ) outputChatBox ( "#00ff77====================", 255, 0, 0, true ) outputChatBox ( "#0077ffVocê esta trabalhando de lixeiro, siga as marcas até o final para pegar seu $", 255, 0, 0, true ) outputChatBox ( "#00ff77====================", 255, 0, 0, true ) --------------------------aqui seria o marker do ponto de parada??---------------------------------------------------------------- MarkerTrab1 = createMarker (2218.8298339844, -1784.7091064453, 12.234619140625, "cylinder",2.0 , 255, 255, 0, 255) BlipTrab1 = createBlipAttachedTo( MarkerTrab1, 41 ) ---------------------------------------------------------------------------------------------------------------------------------- end end end ------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- não esta dando nenhum erro, só que ao eu passar no primeiro ponto de parada e n da nada, não freeza nem nada e eu ainda vou fazer quando sair do caminhão sair desse ElementData para n bugar
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now