Jump to content

Blips


Mefisto_PL

Recommended Posts

Posted (edited)

Hello, I have home-system by JasperNL=D and I want to add blips on map(F11 and radar), but my blips is not working :C. I want to add this blips and that showed on radar blips to 500 meters. It's my code:

local pos = { guiGetScreenSize() } 
local enabled = true 
gResRoot = getResourceRootElement(getThisResource()) 
  
function getMarkerByHousenumber (housenumber) 
  for i,v in ipairs (getElementsByType("marker")) do 
    if (getElementData (v,"housenumber") == tonumber(housenumber)) then 
      return v 
    end 
  end 
end 
  
bindKey( 'i', 'both', function( key, keyState ) 
    if keyState == 'down' then 
        for k, v in ipairs ( getElementsByType( "marker", getResourceRootElement() ) ) do 
            if (getElementData(v,"housenumber")) then 
                createBlipAttachedTo( v, 31, 2, 255,0,0,255,100,500 ); 
            else 
                createBlipAttachedTo( v, 32, 2, 255,0,0,255,100,500 ); 
            end 
        end 
    else 
        for k, v in ipairs( getElementsByType( "marker", getResourceRootElement() ) ) do 
            for k, elem in ipairs( getAttachedElements( v ) ) do 
                if (getElementType(elem)=="blip") then 
                    destroyElement(elem) 
                end 
            end 
        end 
    end 
  
end) 

Edited by Guest
Posted (edited)
local pos = { guiGetScreenSize() } 
local enabled = true 
gResRoot = resourceRoot 
  
function getMarkerByHousenumber (housenumber) 
    for i,v in ipairs (getElementsByType("marker")) do 
        if (getElementData (v,"housenumber") == tonumber(housenumber)) then 
            return v 
        end 
    end 
end 
  
bindKey( 'i', 'both', function( key, keyState ) 
    if (keyState == 'down') then 
        for k, v in ipairs ( getElementsByType( "marker", gResRoot ) ) do 
            if (getElementData(v,"housenumber")) then 
                createBlipAttachedTo( v, 31, 2, 255,0,0,255,100,500 ); 
            end 
        end 
    else 
        for k, v in ipairs( getElementsByType( "marker", gResRoot ) ) do 
            for k, elem in ipairs( getAttachedElements( v ) ) do 
                if (getElementType(elem)=="blip") then 
                    destroyElement(elem) 
                end 
            end 
        end 
    end 
end) 

Try that, not sure if it'll work though.

Edited by Guest

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Why is there a guiGetScreenSize in the script?

local enabled = true 
  
function getMarkerByHousenumber (housenumber) 
    for i,v in ipairs (getElementsByType("marker")) do 
        if (getElementData (v,"housenumber") == tonumber(housenumber)) then 
            return v 
        end 
    end 
end 
  
bindKey( 'i', 'both', function( key, keyState ) 
    if (keyState == 'down') then 
        for k, v in ipairs ( getElementsByType( "marker", resourceRoot) do 
            if (getElementData(v,"housenumber")) then 
                createBlipAttachedTo( v, 31, 2, 255,0,0,255,100,500 ); 
            end 
        end 
    else 
        for k, v in ipairs( getElementsByType( "marker", resourceRoot) do 
            for k, elem in ipairs( getAttachedElements( v ) ) do 
                if (getElementType(elem)=="blip") then 
                    destroyElement(elem) 
                end 
            end 
        end 
    end 
end) 

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

Posted

It should be client side, else everyone'll see the blips when someone presses 'I'.

P.S: bindKey has 'player' argument on server-side.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Put that script in gui.lua?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

What do you mean? we can't help you if you don't provide more information.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You mean the script has an error and the whole gui.lua script isn't working? if so, do /debugscript 3 and tell us the errors.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted (edited)

"WARNING: Loading script failed: home-system\gui.lua:99: ')' expected near 'do' "

99 Line is:

        for k, v in ipairs ( getElementsByType( "marker", resourceRoot) do 

When I hit marker:

"ERROR: Server Triggered clientside event viewHouseGUIwindow, but event is not added clientside"

Edited by Guest
Posted
function getMarkerByHousenumber (housenumber) 
    for i,v in ipairs (getElementsByType("marker")) do 
        if (getElementData (v,"housenumber") == tonumber(housenumber)) then 
            return v 
        end 
    end 
end 
  
bindKey( 'i', 'both', function( key, keyState ) 
    if (keyState == 'down') then 
        for k, v in ipairs ( getElementsByType( "marker", resourceRoot) ) do 
            if (getElementData(v,"housenumber")) then 
                createBlipAttachedTo( v, 31, 2, 255,0,0,255,100,500 ); 
            end 
        end 
    else 
        for k, v in ipairs( getElementsByType( "marker", resourceRoot) ) do 
            for k, elem in ipairs( getAttachedElements( v ) ) do 
                if (getElementType(elem)=="blip") then 
                    destroyElement(elem) 
                end 
            end 
        end 
    end 
end) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You should set a element data to the markers, like 'owner' and then check it client side.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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