Jump to content

Help me out with this error please


Dentos

Recommended Posts

So im trying run this script and i keep geting this error

ERROR: [Addons]/gangblipq/playerblips.lua:20: bad argument #1 'ipairs (table expected,got boolea)

this the script

local pBlips = { } 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for index, player in ipairs(getElementsByType("player")) do 
            addTeamBlip(player) 
        end 
    end 
) 
  
function addTeamBlip(player) 
    if ( pBlips[player] ) then return false end -- Adding a prevention of duplicate blips 
    local pAccount = getPlayerAccount(player) 
    local theGang = ( isGuestAccount(pAccount) and false ) or exports["gang_system"]:getAccountGang(pAccount) 
    if ( theGang ) then 
        local r, g, b = getPlayerNametagColor( player ) 
        local theBlip = createBlipAttachedTo( player, 0, 2, r, g, b ) 
        -- Change visibility to only the team members 
        setElementVisibleTo( theBlip, root, false ) 
        for index, value in ipairs ( exports["gang_system"]:getGangMembers(theGang) ) do 
            setElementVisibleTo( theBlip, value, true ) 
        end 
        pBlips[player] = theBlip 
    end 
end 
  
function destroyBlip(element) 
    local theElement = source or element 
    if ( theElement ) then 
        destroyElement(pBlips[theElement]) 
        pBlips[theElement] = nil -- Just in-case... 
    end 
end 
  
-- Events 
addEventHandler ( "onPlayerSpawn", root, addTeamBlip ) -- onPlayerSpawn will now add a teamBlip 
addEventHandler ( "onPlayerQuit", root, destroyBlip ) 
addEventHandler ( "onPlayerWasted", root, destroyBlip ) 

'

Link to comment
function getPlayersByGang ( gang ) 
    local players = { } 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        if ( getElementData ( player, "gang" ) == gang ) then 
            table.insert ( players, player ) 
        end 
    end 
  
    return players 
end 

Use that function instead of:

exports["gang_system"]:getGangMembers(theGang) 

Link to comment

Ok so I replaced but its not working and not geting any errors now not sure if I replaced it right sorry kinda new at all this

local pBlips = { } 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for index, player in ipairs(getElementsByType("player")) do 
            addTeamBlip(player) 
        end 
    end 
) 
  
function addTeamBlip(player) 
    if ( pBlips[player] ) then return false end -- Adding a prevention of duplicate blips 
    local pAccount = getPlayerAccount(player) 
    local theGang = ( isGuestAccount(pAccount) and false ) or exports["gang_system"]:getAccountGang(pAccount) 
    if ( theGang ) then 
        local r, g, b = getPlayerNametagColor( player ) 
        local theBlip = createBlipAttachedTo( player, 0, 2, r, g, b ) 
        -- Change visibility to only the team members 
        setElementVisibleTo( theBlip, root, false ) 
        for index, value in ipairs  
  
  
function getPlayersByGang ( gang ) 
    local players = { } 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        if ( getElementData ( player, "gang" ) == gang ) then 
            table.insert ( players, player ) 
        end 
    end 
  
    return players 
end 
  
  
         do 
            setElementVisibleTo( theBlip, value, true ) 
        end 
        pBlips[player] = theBlip 
    end 
end 
  
function destroyBlip(element) 
    local theElement = source or element 
    if ( theElement ) then 
        destroyElement(pBlips[theElement]) 
        pBlips[theElement] = nil -- Just in-case... 
    end 
end 
  
-- Events 
addEventHandler ( "onPlayerSpawn", root, addTeamBlip ) -- onPlayerSpawn will now add a teamBlip 
addEventHandler ( "onPlayerQuit", root, destroyBlip ) 
addEventHandler ( "onPlayerWasted", root, destroyBlip ) 

Link to comment

like this ? still not working very sorry for my silly mistakes i feel so noob xD lua just not my forte sorry again and thanks a bunch for you time

local pBlips = { } 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for index, player in ipairs(getElementsByType("player")) do 
            addTeamBlip(player) 
        end 
    end 
) 
  
function getPlayersByGang ( gang ) 
    local players = { } 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        if ( getElementData ( player, "gang" ) == gang ) then 
            table.insert ( players, player ) 
        end 
    end 
  
    return players 
end 
  
function destroyBlip(element) 
    local theElement = source or element 
    if ( theElement ) then 
        destroyElement(pBlips[theElement]) 
        pBlips[theElement] = nil -- Just in-case... 
    end 
end 
  
-- Events 
addEventHandler ( "onPlayerSpawn", root, addTeamBlip ) -- onPlayerSpawn will now add a teamBlip 
addEventHandler ( "onPlayerQuit", root, destroyBlip ) 
addEventHandler ( "onPlayerWasted", root, destroyBlip ) 

Link to comment
local pBlips = { } 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for index, player in ipairs(getElementsByType("player")) do 
            addTeamBlip(player) 
        end 
    end 
) 
  
function addTeamBlip(player) 
    if ( pBlips[player] ) then return false end -- Adding a prevention of duplicate blips 
    local theGang = getElementData ( player, "gang" ) 
    if ( theGang and theGang ~= "None" ) then 
        local r, g, b = getPlayerNametagColor( player ) 
        local theBlip = createBlipAttachedTo( player, 0, 2, r, g, b ) 
        -- Change visibility to only the team members 
        setElementVisibleTo( theBlip, root, false ) 
        for index, value in ipairs ( getPlayersByGang ( theGang ) ) do -- THIS 
            setElementVisibleTo( theBlip, value, true ) 
        end 
        pBlips[player] = theBlip 
    end 
end 
  
function destroyBlip(element) 
    local theElement = source or element 
    if ( theElement ) then 
        destroyElement(pBlips[theElement]) 
        pBlips[theElement] = nil -- Just in-case... 
    end 
end 
  
-- Events 
addEventHandler ( "onPlayerSpawn", root, addTeamBlip ) -- onPlayerSpawn will now add a teamBlip 
addEventHandler ( "onPlayerQuit", root, destroyBlip ) 
addEventHandler ( "onPlayerWasted", root, destroyBlip ) 
  
function getPlayersByGang ( gang ) 
    local players = { } 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        if ( getElementData ( player, "gang" ) == gang ) then 
            table.insert ( players, player ) 
        end 
    end 
  
    return players 
end 

Link to comment

Now I have this other little problem when i reconnect it wont show you on map anymore

I tried adding addEventHandler ( "onPlayerJoin", root, addTeamBlip ) but didnt work I have to restart script everytime i reconnect for it to work

heres what i added

local pBlips = { } 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for index, player in ipairs(getElementsByType("player")) do 
            addTeamBlip(player) 
        end 
    end 
) 
  
function addTeamBlip(player) 
    if ( pBlips[player] ) then return false end -- Adding a prevention of duplicate blips 
    local theGang = getElementData ( player, "gang" ) 
    if ( theGang and theGang ~= "None" ) then 
       local r, g, b = getPlayerNametagColor( player ) 
       local theBlip = createBlipAttachedTo( player, 0, 2, 0, 255, 0 ) 
        -- Change visibility to only the team members 
        setElementVisibleTo( theBlip, root, false ) 
        for index, value in ipairs ( getPlayersByGang ( theGang ) ) do -- THIS 
            setElementVisibleTo( theBlip, value, true ) 
        end 
        pBlips[player] = theBlip 
    end 
end 
  
function destroyBlip(element) 
    local theElement = source or element 
    if ( theElement ) then 
        destroyElement(pBlips[theElement]) 
        pBlips[theElement] = nil -- Just in-case... 
    end 
end 
  
-- Events 
addEventHandler ( "onPlayerJoin", root, addTeamBlip )     --ADDED THIS! 
addEventHandler ( "onPlayerSpawn", root, addTeamBlip ) -- onPlayerSpawn will now add a teamBlip 
addEventHandler ( "onPlayerQuit", root, destroyBlip ) 
addEventHandler ( "onPlayerWasted", root, destroyBlip ) 
  
  
function getPlayersByGang ( gang ) 
    local players = { } 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        if ( getElementData ( player, "gang" ) == gang ) then 
            table.insert ( players, player ) 
        end 
    end 
  
    return players 
end 

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