WeeD1 Posted January 30, 2019 Share Posted January 30, 2019 Alguém sabe se existe alguma função semelhante ao setVehicleDamageProof para blindar o veículo? Tenho 2 mods com essa mesma função e eles estão entrando em conflito, pois ao entrar no servidor a pessoa já entra com o veículo blindado, porém após ela passar por uma certa área e sair dessa área que usa essa mesma função, acaba desativando a blindagem, e eu queria que continuasse. Obs: Um desses mods ele seta a blindagem apenas em um local especifico (Área verde), já o outro mod ele seta a blindagem em todo o servidor, porém são modos diferentes (Modo Passivo semelhante ao GTAV online) Link to comment
DNL291 Posted January 30, 2019 Share Posted January 30, 2019 Mas qual é exatamente o problema? Se é o conflito entre os 2 scripts com essa função é só você desativar/editar o outro. 1 Link to comment
Other Languages Moderators Lord Henry Posted January 30, 2019 Other Languages Moderators Share Posted January 30, 2019 (edited) Você poderia colocar um setElementData no veículo quando ele é blindado pelo modo passivo (sem ser por área verde). E dai no mod da área verde, vc configura pra ignorar os veículos que entram e saem com essa data. Dessa forma, os veículos que não foram blindados pela área, não serão desblindados por ela. 34 minutes ago, DNL291 said: Mas qual é exatamente o problema? Creio que seja mais ou menos esse: Jogador blinda o veículo com o modo Passivo. Jogador entra na área verde com o veículo blindado. (e a área tenta blindar o veículo de novo) Jogador sai da área verde ainda no modo Passivo. (e a área desblinda o veículo) Jogador fica no modo Passivo sem a blindagem. (Erro) Edited January 30, 2019 by Lord Henry 1 Link to comment
WeeD1 Posted January 30, 2019 Author Share Posted January 30, 2019 1 hour ago, Lord Henry said: Você poderia colocar um setElementData no veículo quando ele é blindado pelo modo passivo (sem ser por área verde). E dai no mod da área verde, vc configura pra ignorar os veículos que entram e saem com essa data. Dessa forma, os veículos que não foram blindados pela área, não serão desblindados por ela. Creio que seja mais ou menos esse: Jogador blinda o veículo com o modo Passivo. Jogador entra na área verde com o veículo blindado. (e a área tenta blindar o veículo de novo) Jogador sai da área verde ainda no modo Passivo. (e a área desblinda o veículo) Jogador fica no modo Passivo sem a blindagem. (Erro) Sim o problema é exatamente esse. Vou tentar resolver com o setElementData, obrigado pela ajuda. Link to comment
Tommy. Posted January 30, 2019 Share Posted January 30, 2019 (edited) Solução rápida: Crie uma tabela Ao entrar na área verificar se o carro está blindado, adiciona argumento na tabela Ao sair verifica o argumento que está na tabela Execução: dataVehicle = {} -- A tabela citada. local hillArea = createColRectangle(-2171.0678710938, 678.17950439453, 15, 15) local hillRadar = createRadarArea(-2183.5678710938, 705.67950439453, 40, -40, 0, 255, 0, 175) function hill_Enter(thePlayer, matchingDimension) if (getElementType(thePlayer) == "player") then -- Verifica se o elemento que "entrou" é um player. local gVeh = getPedOccupiedVehicle(thePlayer) -- Pega o veículo que o player está. if gVeh then -- Verifica se o player está em um veículo. if isVehicleDamageProof(gVeh) then -- Verifica se o veículo já está blindado. dataVehicle[gVeh] = true -- Se o veículo já estiver blindado ele seta um argumento na tabela. else setVehicleDamageProof(gVeh, true) -- Se o veículo não estiver blindado ele blinda. end end end end addEventHandler("onColShapeHit", hillArea, hill_Enter) function hill_Exit(thePlayer, matchingDimension) if (getElementType(thePlayer) == "player") then -- Verifica se o elemento que "saiu" é um player. local gVeh = getPedOccupiedVehicle(thePlayer) -- Pega o veículo que o player está. if gVeh then -- Verifica se o player está em um veículo. if dataVehicle[gVeh] then -- Verifica se quando o veículo entrou na área já estava blindado. dataVehicle[gVeh] = nil -- Se já estava blindado ele deleta o argumento do veículo da tabela e não tira a blindagem. else setVehicleDamageProof(gVeh, false) -- Se quando entrou não estava blindado então ele tira a blindagem quando sai. end end end end addEventHandler("onColShapeLeave", hillArea, hill_Exit) EDIT: Não testei.@Lord Henry @DNL291 se eu falei besteira ou fiz algo viajado me corrigem pf Edited January 30, 2019 by Tommy. Erros de código 1 Link to comment
WeeD1 Posted January 31, 2019 Author Share Posted January 31, 2019 15 hours ago, Tommy. said: Solução rápida: Crie uma tabela Ao entrar na área verificar se o carro está blindado, adiciona argumento na tabela Ao sair verifica o argumento que está na tabela Execução: dataVehicle = {} -- A tabela citada. local hillArea = createColRectangle(-2171.0678710938, 678.17950439453, 15, 15) local hillRadar = createRadarArea(-2183.5678710938, 705.67950439453, 40, -40, 0, 255, 0, 175) function hill_Enter(thePlayer, matchingDimension) if (getElementType(thePlayer) == "player") then -- Verifica se o elemento que "entrou" é um player. local gVeh = getPedOccupiedVehicle(thePlayer) -- Pega o veículo que o player está. if gVeh then -- Verifica se o player está em um veículo. if isVehicleDamageProof(gVeh) then -- Verifica se o veículo já está blindado. dataVehicle[gVeh] = true -- Se o veículo já estiver blindado ele seta um argumento na tabela. else setVehicleDamageProof(gVeh, true) -- Se o veículo não estiver blindado ele blinda. end end end end addEventHandler("onColShapeHit", hillArea, hill_Enter) function hill_Exit(thePlayer, matchingDimension) if (getElementType(thePlayer) == "player") then -- Verifica se o elemento que "saiu" é um player. local gVeh = getPedOccupiedVehicle(thePlayer) -- Pega o veículo que o player está. if gVeh then -- Verifica se o player está em um veículo. if dataVehicle[gVeh] then -- Verifica se quando o veículo entrou na área já estava blindado. dataVehicle[gVeh] = nil -- Se já estava blindado ele deleta o argumento do veículo da tabela e não tira a blindagem. else setVehicleDamageProof(gVeh, false) -- Se quando entrou não estava blindado então ele tira a blindagem quando sai. end end end end addEventHandler("onColShapeLeave", hillArea, hill_Exit) EDIT: Não testei. @Lord Henry @DNL291 se eu falei besteira ou fiz algo viajado me corrigem pf Testei aqui e funcionou isso também... Porém testei adaptar na área verde que eu uso de todas as formas, colando linha por linha já to algumas horas quebrando a cabeça com isso, mas até agora não consegui, talvez porque a área verde que eu uso, usa programação em OOP também. Teria como fazer isso por mim por favor? Obs: Testei colocar até em pastas separadas da área verde para testar, porém sem sucesso. greenzones = { {x = 60, y = -1973, z = -20, width = 301, depth = 225, height = 500, r = 0 , g = 200 , b = 0 , a = 100}, -- Praia } local AreaV = {} function IniciarAreaVerde() if greenzones and #greenzones ~= 0 then for _,v in ipairs (greenzones) do if v then if v.x and v.y and v.z and v.width and v.depth and v.height then local colShape = createColCuboid (v.x, v.y, v.z, v.width, v.depth, v.height) local rarea = createRadarArea (v.x, v.y, v.width, v.depth, v.r,v.g,v.b,v.a) setElementParent (rarea, colShape) colShape:setData("AreaProte", true) if colShape then AreaV[colShape] = true addEventHandler ("onElementDestroy", colShape, function() if AreaV[source] then AreaV[source] = nil end end ) addEventHandler ("onColShapeHit", colShape, function (h, d) if h and d and isElement(h) and getElementType (h) == "player" and getElementDimension( h ) == 0 and getElementInterior(h) == 0 then setElementData(h,"areaverde",true) end if h and d and isElement(h) and getElementType (h) == "vehicle" and getElementDimension( h ) == 0 and getElementInterior(h) == 0 then setVehicleDamageProof(h, true) end end ) addEventHandler ("onColShapeLeave", colShape, function (h, d) if h and d and isElement(h) and getElementType (h) == "player" and getElementDimension( h ) == 0 and getElementInterior(h) == 0 then setElementData(h,"areaverde",false) end if h and d and isElement(h) and getElementType (h) == "vehicle" and getElementDimension( h ) == 0 and getElementInterior(h) == 0 then setVehicleDamageProof(h, false) end end ) end end end end end end addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()), IniciarAreaVerde) Link to comment
Tommy. Posted January 31, 2019 Share Posted January 31, 2019 1 hour ago, WeeD1 said: Testei aqui e funcionou isso também... Porém testei adaptar na área verde que eu uso de todas as formas, colando linha por linha já to algumas horas quebrando a cabeça com isso, mas até agora não consegui, talvez porque a área verde que eu uso, usa programação em OOP também. Teria como fazer isso por mim por favor? Obs: Testei colocar até em pastas separadas da área verde para testar, porém sem sucesso. greenzones = { {x = 60, y = -1973, z = -20, width = 301, depth = 225, height = 500, r = 0 , g = 200 , b = 0 , a = 100}, -- Praia } local AreaV = {} function IniciarAreaVerde() if greenzones and #greenzones ~= 0 then for _,v in ipairs (greenzones) do if v then if v.x and v.y and v.z and v.width and v.depth and v.height then local colShape = createColCuboid (v.x, v.y, v.z, v.width, v.depth, v.height) local rarea = createRadarArea (v.x, v.y, v.width, v.depth, v.r,v.g,v.b,v.a) setElementParent (rarea, colShape) colShape:setData("AreaProte", true) if colShape then AreaV[colShape] = true addEventHandler ("onElementDestroy", colShape, function() if AreaV[source] then AreaV[source] = nil end end ) addEventHandler ("onColShapeHit", colShape, function (h, d) if h and d and isElement(h) and getElementType (h) == "player" and getElementDimension( h ) == 0 and getElementInterior(h) == 0 then setElementData(h,"areaverde",true) end if h and d and isElement(h) and getElementType (h) == "vehicle" and getElementDimension( h ) == 0 and getElementInterior(h) == 0 then setVehicleDamageProof(h, true) end end ) addEventHandler ("onColShapeLeave", colShape, function (h, d) if h and d and isElement(h) and getElementType (h) == "player" and getElementDimension( h ) == 0 and getElementInterior(h) == 0 then setElementData(h,"areaverde",false) end if h and d and isElement(h) and getElementType (h) == "vehicle" and getElementDimension( h ) == 0 and getElementInterior(h) == 0 then setVehicleDamageProof(h, false) end end ) end end end end end end addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()), IniciarAreaVerde) Quando eu chegar em casa dou uma olhada 1 Link to comment
Tommy. Posted February 1, 2019 Share Posted February 1, 2019 (edited) @WeeD1 Foi mal a demora, tinha esquecido, mas está ai: greenzones = { {x = 60, y = -1973, z = -20, width = 301, depth = 225, height = 500, r = 0 , g = 200 , b = 0 , a = 100}, -- Praia } dataVehicle = {} local AreaV = {} function IniciarAreaVerde() if greenzones and #greenzones ~= 0 then for _,v in ipairs (greenzones) do if v then if v.x and v.y and v.z and v.width and v.depth and v.height then local colShape = createColCuboid (v.x, v.y, v.z, v.width, v.depth, v.height) local rarea = createRadarArea (v.x, v.y, v.width, v.depth, v.r,v.g,v.b,v.a) setElementParent (rarea, colShape) colShape:setData("AreaProte", true) if colShape then AreaV[colShape] = true addEventHandler ("onElementDestroy", colShape, function() if AreaV[source] then AreaV[source] = nil end end ) addEventHandler ("onColShapeHit", colShape, function (h, d) if h and d and isElement(h) and getElementType (h) == "player" and getElementDimension( h ) == 0 and getElementInterior(h) == 0 then setElementData(h,"areaverde",true) end if h and d and isElement(h) and getElementType (h) == "vehicle" and getElementDimension( h ) == 0 and getElementInterior(h) == 0 then if isVehicleDamageProof(h) then dataVehicle[h] = true else setVehicleDamageProof(h, true) end end end ) addEventHandler ("onColShapeLeave", colShape, function (h, d) if h and d and isElement(h) and getElementType (h) == "player" and getElementDimension( h ) == 0 and getElementInterior(h) == 0 then setElementData(h,"areaverde",false) end if h and d and isElement(h) and getElementType (h) == "vehicle" and getElementDimension( h ) == 0 and getElementInterior(h) == 0 then if dataVehicle[h] then dataVehicle[h] = nil else setVehicleDamageProof(h, false) end end end ) end end end end end end addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()), IniciarAreaVerde) EDIT 1: Não testei Edited February 1, 2019 by Tommy. 1 Link to comment
WeeD1 Posted February 1, 2019 Author Share Posted February 1, 2019 Sem problemas, funcionou tudo certinho aqui, obrigado pela ajuda @Tommy. Link to comment
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