Jump to content

How to change a projectile's blip color?


Lord Henry

Recommended Posts

  • Moderators
Posted

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 Thanksspacer.png

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.

  • Moderators
Posted
20 hours ago, Mr.Loki said:

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 Thanksspacer.png

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.

Posted
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

 

  • Moderators
Posted (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 by Lord Henry

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

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.

Posted (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 by Mr.Loki
  • Moderators
Posted
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 Thanksspacer.png

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.

Posted
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. 

Posted (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 by Ayush Rathore

I am a paid scripter.

Contact: [email protected]

Instagram: https://www.instagram.com/ayush_kumar_rathore/

Give me a 'Thanks'  if I helped.

source.gif

  • Moderators
Posted
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 Thanksspacer.png

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.

Posted
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...