Jump to content

about the syntax from createBlipAttachedTo


IIYAMA

Recommended Posts

  • Moderators
blip createBlipAttachedTo ( element elementToAttachTo, [int icon=0, int size=2, int r=255, int g=0, int b=0,  
int a=255, int ordering=0, float visibleDistance=99999.0, visibleTo = getRootElement()] ) 

The last argument is about the visibility from the blip, I can fill in 1 element or the root. Is it possible to fill in more elements(players)?

https://wiki.multitheftauto.com/wiki/Cr ... AttachedTo

support tables?

Link to comment

You can make wrappers of blip functions, here's an example of how would createBlipAttachedTo seem like:

_createBlipAttachedTo = createBlipAttachedTo 
function createBlipAttachedTo ( ... ) 
    if ( type ( arg [ #arg ] ) ~= 'table' ) then 
        return _createBlipAttachedTo ( ... ) 
    end 
    local pElement = createElement ( "blip" ) 
    local blipArray = {} 
     
    for i,v in ipairs ( arg [ #arg ] ) do 
        local newArg = arg 
        newArg [ #newArg ] = nil 
         
        blipArray [ #blipArray + 1 ] = createBlipAttachedTo ( unpack ( newArg ), v ) 
    end 
     
    setElementData ( pElement, "blips", blipArray ) 
    return pElement 
end 

The con is that you have to modify other functions that has a blip element as parameter.

Edited by Guest
Link to comment
  • Moderators

Some of the arguments I don't understand.

Like:

... 
arg -- doesn't this have to be defined?(probably it is already defined with ... but I don't understand that) 
  

Right now I am making for every player a blip and create 1 element that contains all elements?

Isn't it better to use setElementVisibleTo to reduce the amount of elements?

Link to comment
Some of the arguments I don't understand.

Like:

... 
arg -- doesn't this have to be defined?(probably it is already defined with ... but I don't understand that) 
  

arg is a Lua pre-defined variable, it has the same meaning of '...' which is a table of variables.

Right now I am making for every player a blip and create 1 element that contains all elements?

Isn't it better to use setElementVisibleTo to reduce the amount of elements?

Indeed, I didn't think about the most efficient way to do it, I firstly had that idea and this code is supposed to give you an idea of how you could do it.

Link to comment

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