Predator Posted February 15, 2012 Share Posted February 15, 2012 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
Kenix Posted February 15, 2012 Share Posted February 15, 2012 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
myonlake Posted February 15, 2012 Share Posted February 15, 2012 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
Predator Posted February 15, 2012 Author Share Posted February 15, 2012 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' Link to comment
Kenix Posted February 15, 2012 Share Posted February 15, 2012 (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 February 15, 2012 by Guest Link to comment
Castillo Posted February 15, 2012 Share Posted February 15, 2012 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
Kenix Posted February 15, 2012 Share Posted February 15, 2012 Same myonlake,index's can't be local in table. This is syntax error. Link to comment
Predator Posted February 15, 2012 Author Share Posted February 15, 2012 Castillo's works.. Kenix's doesn't give me any errors but neither my color is black.. Thank you all for your help. Link to comment
Kenix Posted February 15, 2012 Share Posted February 15, 2012 Kenix's doesn't give me any errors but neither my color is black.. Lol,i tested it and it colored. Link to comment
Predator Posted February 15, 2012 Author Share Posted February 15, 2012 Dunno what's its problem but my color is random with yours.. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now