Imortallity Posted January 20, 2019 Share Posted January 20, 2019 (edited) Bom galera, tenho um sistema aqui de assalto a banco e queria uma ajuda de vocês com os "peds" local ped = {} local function refreshPeds() for index, p in pairs(ped) do if(isElement(p)) then destroyElement(p) end end ped[1] = createPed(164, 1492.946, -1138.541, 24.102, 270) ped[2] = createPed(164, 1522.538, -1134.385, 24.102, 90) ped[3] = createPed(164, 1513.467, -1150.606, 24.102, 0) ped[4] = createPed(164, 1492.641, -1141.252, 35.855, 270) ped[5] = createPed(164, 1522.694, -1139.455, 35.855, 91.664123535156) ped[6] = createPed(164, 1512.153, -1150.555, 35.855, 0) setPedArmor(ped[6], 100) setElementInterior(ped[1], 0) setElementInterior(ped[2], 0) setElementInterior(ped[3], 0) setElementInterior(ped[4], 0) setElementInterior(ped[5], 0) setElementInterior(ped[6], 0) for i = 0, #ped, 0 do setElementDimension(ped[i], dim) end setTimer(function() giveWeapon(ped[1], 27, 500, true) giveWeapon(ped[2], 27, 500, true) giveWeapon(ped[3], 27, 500, true) giveWeapon(ped[4], 27, 500, true) giveWeapon(ped[5], 27, 500, true) giveWeapon(ped[6], 27, 500, true) end, 1000, 1) setElementData(ped[1], "bankguard", true) setElementData(ped[2], "bankguard", true) setElementData(ped[3], "bankguard", true) setElementData(ped[4], "bankguard", true) setElementData(ped[5], "bankguard", true) setElementData(ped[6], "bankguard", true) end Bom, como podem ver esta função cria peds, estes peds só atiram em um player caso o player atire nele, bom oque eu queria era saber se existe algum código para ligar todos estes peds para assim que um player atirar em um deles, os três abram fogo ao mesmo tempo sabe? agradeço desde já! Acrescentando ao tópico aqui, também queria saber se é possível adicionar movimento aos peds, pois atualmente eles ficam parados em um único local, obrigado. Edited January 20, 2019 by Imortallity Link to comment
#DaNiLiN Posted January 20, 2019 Share Posted January 20, 2019 (edited) function onPedRender() local ped = getElementsByType ( "ped" ) for theKey, thePed in ipairs(ped) do if getElementData(thePed, "bankguard") then local x ,y, z = getElementPosition(thePed) local sx, sy, sz = getElementPosition(localPlayer) local Dist = getDistanceBetweenPoints3D (x, y, z, sx, sy, sz) if(isLineOfSightClear(x, y, z, sx, sy, sz, true, false, false, false, false, false)) then setPedControlState(thePed, "fire", true) setPedAimTarget(thePed, sx, sy, sz) StartBot () else setPedControlState(thePed, "fire", false) end end end end addEventHandler("onClientPedDamage", root, onPedRender) function StartBot () if isEventHandlerAdded("onClientRender", getRootElement(), onPedRender) then return end addEventHandler("onClientRender", root, onPedRender) end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end Deve ajudar. Caso um ped for atingido todos os Bot irá revidar contra o jogador. Edited January 20, 2019 by danilin Erro Ortográfico 1 Link to comment
Imortallity Posted January 20, 2019 Author Share Posted January 20, 2019 Caaaaaara, valeu mano, me salvou legal!!!!!! 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