Moderators Lord Henry Posted April 13, 2017 Moderators Posted April 13, 2017 Hello. I have a script that create a missile that follows the player when he enters the specified collision shape using createProjectile. The projectile elements have a white blip by default and I need to change it to Red. Is there a way to do it? Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! 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.
Mr.Loki Posted April 13, 2017 Posted April 13, 2017 Try this: getAttachedElements setBlipColor Ahmed Ly 1 [REL]Cinema Experience Beta 2.0 [TUT]Object offsets with OOP. [TUT] Adding a Discord bot to your server. Discord: Loki#7355
Moderators Lord Henry Posted April 14, 2017 Author Moderators Posted April 14, 2017 20 hours ago, Mr.Loki said: Try this: getAttachedElements setBlipColor getAttachedElements doesn't work, because it returns a table, not the element. Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! 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.
Fist Posted April 14, 2017 Posted April 14, 2017 1 hour ago, Lord Henry said: getAttachedElements doesn't work, because it returns a table, not the element. If you didn't read carefuly enough function name is getAttachedElements not getAttachedElement. Just loop through that table it will get ALL attached elements, 'cause there can be more than 1 attached element to an element. Just in case if you have other elements attached to the projectile then just add check variable if element is the blip and then set blip color. for i,v in ipairs(getAttachedElements(yourProjectileElementHere) do setBlipColor(v,255,0,0,255); end
Mr.Loki Posted April 14, 2017 Posted April 14, 2017 2 hours ago, Lord Henry said: getAttachedElements doesn't work, because it returns a table, not the element. A table containing the element [REL]Cinema Experience Beta 2.0 [TUT]Object offsets with OOP. [TUT] Adding a Discord bot to your server. Discord: Loki#7355
Gordon_G Posted April 14, 2017 Posted April 14, 2017 (edited) In order to reduce lag, you should use for i,v in pairs(getAttachedElements(yourProjectileElementHere) do setBlipColor(v,255,0,0,255); end instead of for i,v in ipairs(getAttachedElements(yourProjectileElementHere) do setBlipColor(v,255,0,0,255); end 'Cause you don't need to order the execution. Edited April 14, 2017 by Gordon_G Gordon#6977
Moderators Lord Henry Posted April 15, 2017 Author Moderators Posted April 15, 2017 (edited) 9 hours ago, Fist said: If you didn't read carefuly enough function name is getAttachedElements not getAttachedElement. Just loop through that table it will get ALL attached elements, 'cause there can be more than 1 attached element to an element. Just in case if you have other elements attached to the projectile then just add check variable if element is the blip and then set blip color. for i,v in ipairs(getAttachedElements(yourProjectileElementHere) do setBlipColor(v,255,0,0,255); end When I use this, the Projectile is not spawned anymore. ------------------------------------------------------------------------------- Hey guys, test using this, client-side: function attackIntruderA51 () local a51MissileA = createProjectile (localPlayer, 20, 15.49994, 1719.1, 25.5, 5, localPlayer, 0, 0, 0, 0, 0, 1) local a51MissileB = createProjectile (localPlayer, 20, 237.7, 1696.8, 25.5, 5, localPlayer, 0, 0, 0, 0, 0, 1) end addCommandHandler ("attack", localPlayer, attackIntruderA51) Edited April 15, 2017 by Lord Henry Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! 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.
Mr.Loki Posted April 15, 2017 Posted April 15, 2017 (edited) addCommandHandler only has 2 main args please use /debugscript 3 to debug your code and show errors I just tried the function myself and it seems that the blip isn't attached to the projectile so, i just made a little hack. Not perfect but it works. function attackIntruderA51 () local t={} -- store the projectiles in a table so you can simply loops it and easily add more projectiles. t[#t+1] = createProjectile (localPlayer, 20, 15.49994, 1719.1, 25.5, 5, localPlayer, 0, 0, 0, 0, 0, 1) t[#t+1] = createProjectile (localPlayer, 20, 237.7, 1696.8, 25.5, 5, localPlayer, 0, 0, 0, 0, 0, 1) for _,projectile in pairs (t) do local blip = createBlipAttachedTo( projectile, 0, 1, 255, 0, 0, 255, 1 ) setElementParent( blip, projectile ) -- parent the blip to the projectile so it gets destroyed when the projectile explodes. end end addCommandHandler ("attack", attackIntruderA51) Edited April 15, 2017 by Mr.Loki [REL]Cinema Experience Beta 2.0 [TUT]Object offsets with OOP. [TUT] Adding a Discord bot to your server. Discord: Loki#7355
Moderators Lord Henry Posted April 16, 2017 Author Moderators Posted April 16, 2017 On 14/04/2017 at 23:30, Mr.Loki said: addCommandHandler only has 2 main args please use /debugscript 3 to debug your code and show errors I just tried the function myself and it seems that the blip isn't attached to the projectile so, i just made a little hack. Not perfect but it works. function attackIntruderA51 () local t={} -- store the projectiles in a table so you can simply loops it and easily add more projectiles. t[#t+1] = createProjectile (localPlayer, 20, 15.49994, 1719.1, 25.5, 5, localPlayer, 0, 0, 0, 0, 0, 1) t[#t+1] = createProjectile (localPlayer, 20, 237.7, 1696.8, 25.5, 5, localPlayer, 0, 0, 0, 0, 0, 1) for _,projectile in pairs (t) do local blip = createBlipAttachedTo( projectile, 0, 1, 255, 0, 0, 255, 1 ) setElementParent( blip, projectile ) -- parent the blip to the projectile so it gets destroyed when the projectile explodes. end end addCommandHandler ("attack", attackIntruderA51) I'm already doing this. But sometimes the original Projectile's blip keep upon the custom blip, even if I put the ordering arg to 32767. Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! 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.
Mr.Loki Posted April 16, 2017 Posted April 16, 2017 Damn... then i have no idea how lol [REL]Cinema Experience Beta 2.0 [TUT]Object offsets with OOP. [TUT] Adding a Discord bot to your server. Discord: Loki#7355
Fist Posted April 16, 2017 Posted April 16, 2017 10 hours ago, Lord Henry said: I'm already doing this. But sometimes the original Projectile's blip keep upon the custom blip, even if I put the ordering arg to 32767. you could destroy original blip with destroyElement and then create your own.
Ayush Rathore Posted April 17, 2017 Posted April 17, 2017 (edited) On 4/13/2017 at 06:26, Lord Henry said: Hello. I have a script that create a missile that follows the player when he enters the specified collision shape using createProjectile. The projectile elements have a white blip by default and I need to change it to Red. Is there a way to do it? function attackIntruderA51 () local t={} t[#t+1] = createProjectile (localPlayer, 20, 15.49994, 1719.1, 25.5, 5, localPlayer, 0, 0, 0, 0, 0, 1) t[#t+1] = createProjectile (localPlayer, 20, 237.7, 1696.8, 25.5, 5, localPlayer, 0, 0, 0, 0, 0, 1) for _,projectile in pairs (t) do for i,v in pairs(getAttachedElements(projectile)) do if (getElementType(v)=='blip') then setBlipColor(v,255,0,0,255); end end end end addCommandHandler ("attack", attackIntruderA51) Use this it might fulfill your need Edited April 17, 2017 by Ayush Rathore v36u 1 I am a paid scripter. Contact: [email protected] Instagram: https://www.instagram.com/ayush_kumar_rathore/ Give me a 'Thanks' if I helped.
Moderators Lord Henry Posted April 17, 2017 Author Moderators Posted April 17, 2017 14 hours ago, Fist said: you could destroy original blip with destroyElement and then create your own. I can't access the original blip. If I could, I would just change the original blip's color. Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! 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.
Mr.Loki Posted April 17, 2017 Posted April 17, 2017 7 hours ago, Ayush Rathore said: function attackIntruderA51 () local t={} t[#t+1] = createProjectile (localPlayer, 20, 15.49994, 1719.1, 25.5, 5, localPlayer, 0, 0, 0, 0, 0, 1) t[#t+1] = createProjectile (localPlayer, 20, 237.7, 1696.8, 25.5, 5, localPlayer, 0, 0, 0, 0, 0, 1) for _,projectile in pairs (t) do for i,v in pairs(getAttachedElements(projectile)) do if (getElementType(v)=='blip') then setBlipColor(v,255,0,0,255); end end end end addCommandHandler ("attack", attackIntruderA51) Use this it might fulfill your need We tried this already does not work [REL]Cinema Experience Beta 2.0 [TUT]Object offsets with OOP. [TUT] Adding a Discord bot to your server. Discord: Loki#7355
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