Jump to content

createBlipAttachedTo


Predator

Recommended Posts

Hi all,

I'm trying to make a script that when an Admin spawns his blip color gets black, and when he dies/quits it(the blip) destroys..

My script:

addEventHandler ( "onPlayerSpawn", getRootElement(),createBlipAttachedTo ) 
function createBlipAttachedTo 
local account = getPlayerAccount(source) 
 if (not account or isGuestAccount(account)) then return end 
 local accountName = getAccountName(account) 
 if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) ) then 
        if isElement ( playerBlips[source] ) then 
            destroyElement ( playerBlips[source] ) 
        end 
        playerBlips[source] = createBlip ( 0, 2, 0, 0, 0, 255, 0, 99999.0, 0 ) 
        attachElements ( playerBlips[source], source ) 
    end 
end 
addEventHandler ( "onPlayerQuit", getRootElement(), 
    function() 
        destroyElement ( playerBlips[source] ) 
        playerBlips[source] = nil 
    end 
addEventHandler ( "onPlayerWasted", getRootElement(), 
    function() 
        destroyElement ( playerBlips[source] ) 
        playerBlips[source] = nil 
    end 

But it doesn't work..

Error:

SCRIPT ERROR: customblips\Admin.lua:3: '<' expected near 'if' 

Anyone can help?

Thanks in advance

Link to comment

Server

local playerBlips = { } 
  
function attachBlip( ) 
    local account = getPlayerAccount( source ) 
    if not account or isGuestAccount( account ) then  
        return  
    end 
    local accountName = getAccountName( account ) 
    if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) then 
        if isElement ( playerBlips[ source ] ) then 
            destroyElement ( playerBlips[source] ) 
        end 
        playerBlips[ source ] = createBlip ( 0, 2, 0, 0, 0, 255, 0, 99999.0, 0 ) 
        attachElements ( playerBlips[ source ], source ) 
    end 
end 
addEventHandler ( "onPlayerSpawn", root,attachBlip ) 
  
addEventHandler ( "onPlayerQuit", root, 
    function() 
        destroyElement ( playerBlips[source] ) 
        playerBlips[ source ] = nil 
    end 
) 
     
addEventHandler ( "onPlayerWasted", root, 
    function() 
        destroyElement ( playerBlips[ source ] ) 
        playerBlips[ source ] = nil 
    end 
)    

Read http://www.lua.org/manual/5.1/

And it https://wiki.multitheftauto.com/wiki/Scr ... troduction

Link to comment
local playerBlips = {} 
  
addEventHandler("onPlayerSpawn", getRootElement(), 
    function createBlipAttachedTo() 
        local account = getPlayerAccount(source) 
        if (not account or isGuestAccount(account)) then return end 
        local accountName = getAccountName(account) 
        if isObjectInACLGroup("user." .. accountName, aclGetGroup("Admin")) then 
            if isElement(playerBlips[source]) then 
                destroyElement(playerBlips[source]) 
            end 
            local playerBlips[source] = createBlipAttachedTo(source, 0, 2, 0, 0, 0, 255, 0, 99999.0, 0) 
        end 
    end 
) 
  
addEventHandler("onPlayerQuit", getRootElement(), 
    function() 
        destroyElement(playerBlips[source]) 
        playerBlips[source] = nil 
    end 
) 
  
addEventHandler("onPlayerWasted", getRootElement(), 
    function() 
        destroyElement(playerBlips[source]) 
        playerBlips[source] = nil 
    end 
) 

Link to comment
local playerBlips = { } 
  
function attachBlip( ) 
    local account = getPlayerAccount( source ) 
    if not account or isGuestAccount( account ) then  
        return  
    end 
    local accountName = getAccountName( account ) 
    if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) then 
        if isElement ( playerBlips[ source ] ) then 
            destroyElement ( playerBlips[source] ) 
        end 
        playerBlips[source] = createBlipAttachedTo(source, 0, 2, 0, 0, 0, 255, 0, 99999.0, 0) 
    end 
end 
addEventHandler ( "onPlayerSpawn", root,attachBlip ) 
  
addEventHandler ( "onPlayerQuit", root, 
    function() 
        if isElement( playerBlips[source] ) then 
            destroyElement ( playerBlips[source] ) 
        end  
        playerBlips[ source ] = nil 
    end 
) 
     
addEventHandler ( "onPlayerWasted", root, 
    function( ) 
        if isElement( playerBlips[source] ) then 
            destroyElement ( playerBlips[ source ] ) 
        end  
        playerBlips[ source ] = nil 
    end 
)    

Edited by Guest
Link to comment
local playerBlips = {} 
  
addEventHandler("onPlayerSpawn", getRootElement(), 
    function () 
        local account = getPlayerAccount(source) 
        if (not account or isGuestAccount(account)) then return end 
        local accountName = getAccountName(account) 
        if isObjectInACLGroup("user." .. accountName, aclGetGroup("Admin")) then 
            if isElement(playerBlips[source]) then 
                destroyElement(playerBlips[source]) 
            end 
            playerBlips[source] = createBlipAttachedTo(source, 0, 2, 0, 0, 0, 255, 0, 99999.0, 0) 
        end 
    end 
) 
  
addEventHandler("onPlayerQuit", getRootElement(), 
    function() 
        if isElement(playerBlips[source]) then destroyElement(playerBlips[source]) end 
        playerBlips[source] = nil 
    end 
) 
  
addEventHandler("onPlayerWasted", getRootElement(), 
    function() 
        if isElement(playerBlips[source]) then destroyElement(playerBlips[source]) end 
        playerBlips[source] = nil 
    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...