DRW Posted September 3, 2015 Posted September 3, 2015 Hello, I'm making a script that creates a blip per every ped at a maximum range of 50 units, so I use a table to get all the peds and exclude the ones which don't accomplish the distance that I ask for. So I made this along with onClientRender. for i,peds in ipairs (getElementsByType("ped")) do local x,y,z = getElementPosition(peds) local wx,wy,wz = getElementPosition (localPlayer) if getDistanceBetweenPoints3D (wx,wy,wz,x,y,z)<50 then bl = createBlipAttachedTo (peds,0,1) end end Obviously this is the worst way to do it since onClientRender will create a blip per frame no matter if the ped has a blip attached to it or not. Also, if I define the blip with a name, when I destroy it, all of em get destroyed, I'm still not familiarized with tables and all those things, also I want to do this with players, but since I don't even have someone to test with, I'm doing it with peds. What can I do? PD: Please, don't give me examples of setBlipVisibleDistance because I don't want players to see the attached blips around the F11 map. Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
JR10 Posted September 3, 2015 Posted September 3, 2015 How about onClientElementStreamIn? It might not be the same distance you want, I'm honestly not sure but it might work for you. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
DRW Posted September 3, 2015 Author Posted September 3, 2015 How about onClientElementStreamIn? It might not be the same distance you want, I'm honestly not sure but it might work for you. Thank you for trying to help me, but I solved it another way: local x,y,z = getElementPosition(localPlayer) el = createColSphere (x,y,z,100) attachElements (el,localPlayer) addEventHandler ("onClientElementColShapeHit",getRootElement(),function(shape) if shape==el then if getElementType (source)=="player" then blep = createBlipAttachedTo (source,1,1) setElementData(blep,"distblip",true) end end end) addEventHandler ("onClientRender",getRootElement(),function() for i,blips in ipairs (getElementsByType("blip"))do local ix,iy,iz = getElementPosition (blips) local xe,ye,ze = getElementPosition(localPlayer) local dist= getDistanceBetweenPoints3D (xe,ye,ze,ix,iy,iz) if dist>100 then if getElementData (blips,"distblip") then destroyElement (blips) end end end end) Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
JR10 Posted September 3, 2015 Posted September 3, 2015 Using getDistanceBetweenPoints3D on render is pretty bad. Just use onClientColShapeLeave. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
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