kieran Posted June 20, 2017 Share Posted June 20, 2017 (edited) I am trying to make a script for admins so they can destroy vehicles with mouse click, just in case they can not enter vehicle as it might be close to walls either side, the problems I am having are one, the vehicle does not get removed, and 2, I get an error when I try it as admin. function AdminCarRemoval ( button, state, player ) if isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ( "admin" ) ) then if getElementType == "vehicle" then if button == "left" and state == "down" then destroyElement () end end end end addEventHandler( "onElementClicked", getRootElement( ), AdminCarRemoval ) ^Yes, I have set it server side^ Error: test\destroy_veh.lua:2: attempt to concatenate global 'accountname' (a nil value) Edited June 20, 2017 by kieran Link to comment
pa3ck Posted June 20, 2017 Share Posted June 20, 2017 The error kinda explains itself, where is accountname defined? You forgot the line local accountname = getAccountName(getPlayerAccount(player)) Link to comment
kieran Posted June 20, 2017 Author Share Posted June 20, 2017 17 minutes ago, pa3ck said: The error kinda explains itself, where is accountname defined? You forgot the line local accountname = getAccountName(getPlayerAccount(player)) It still says [2017-06-20 23:32:27] WARNING: test\destroy_veh.lua:3: Bad argument @ 'isObjectInACLGroup' [Expected acl-group at argument 2, got Booleani local accountname = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "admin" ) ) then --is now line 3. There's still however the small issue of actually deleting the element even without the admin part it does not see the element being clicked, just the mouse click itself... Link to comment
!#NssoR_) Posted June 20, 2017 Share Posted June 20, 2017 (edited) function AdminCarRemoval ( button, state, player ) if ( button == "left" and state == "down" ) then if ( isElement(source) ) and ( getElementType(source) == "vehicle" ) then if ( isGuestAccount(getPlayerAccount(player)) ) then return end if ( aclGetGroup ( "Admin" ) ) and ( isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(player)), aclGetGroup ( "Admin" ) ) ) then destroyElement (source) outputChatBox('Successfully destroyed the vehicle.',player,255,255,0,true) end end end end addEventHandler( "onElementClicked", getRootElement( ), AdminCarRemoval ) Make sure the first letter of the group name must be capital. ( usually its capital letter ) Edited June 20, 2017 by !#NssoR_) 1 Link to comment
kieran Posted June 20, 2017 Author Share Posted June 20, 2017 @!#NssoR_) Thanks so much, it works great now, you seem to always find my cries for help haha. 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