Jump to content

createBlipAttachedTo


Predator

Recommended Posts

Posted

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

Posted

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

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

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

If I helped you, please click the like button on the right ;) Thanks!

Posted

When trying Kenix's I get the error:

WARNING: customblips\admin.Lua:28: Bad argument @ 'destroyElement' 
 

When trying myonlake's I get the error:

SCRIPT ERROR: customblips\admin.Lua:4: '<' expected near 'createBlipAttachedTo' 
 
Posted (edited)
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

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

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

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
Kenix's doesn't give me any errors but neither my color is black..

Lol,i tested it and it colored.

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

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