Fudge Posted August 9, 2010 Share Posted August 9, 2010 Hello, i been trying to get this admin only teleport to work. I'm a noob in scripting but heres what i tried but it wont work door = createMarker (-699,973,12, "cylinder", 3,255, 0, 0) function fun(hitElement) if getElementType(hitElement)="player" then name=getPlayerName(hitElement) if isObjectInACLGroup("user.". .name, aclGetGroup ("Admin"))then setElementPosition(,x,y,z) elseif outputChatBox(hitElement, "Fag, this is for Admins only") end end end addEventHandler("onMarkerHit", door,fun) i know the cordinates are x y z, ill change that later, my problem is is that it wont even create a marker Link to comment
Remp Posted August 9, 2010 Share Posted August 9, 2010 there are lots of syntax errors in the code, i imagine your marker isnt being created because your script isnt actually loading (its just erroring) if you indent your code its much easier to see the problems: door = createMarker (-699,973,12, "cylinder", 3,255, 0, 0) function fun(hitElement) if getElementType(hitElement)="player" then -- "=" is used to assign values, you should be using "==" to compare values name = getPlayerName(hitElement) if isObjectInACLGroup("user.". .name, aclGetGroup ("Admin"))then -- there should not be a space between the 2 full stops setElementPosition(,x,y,z) -- you are not giving an element argument here (and as you said, x,y,z dont exist) elseif -- 'elseif' is used when you want to do another comparison, use 'else' when you want to just default outputChatBox(hitElement, ":O, this is for Admins only") -- the text should be the first argument, not the second end end end addEventHandler("onMarkerHit", door,fun) Most of these could be fixed with a quick look at the wiki page for each function (or in some cases a quick google for the lua syntax) Fix the errors i pointed out and see how it goes then Link to comment
Fudge Posted August 9, 2010 Author Share Posted August 9, 2010 Thank you for the revisions. Everything works fine now. Next time i will make sure to check my syntax. Once again, thank you alot Link to comment
The_Ex Posted August 9, 2010 Share Posted August 9, 2010 isObjectInACLGroup("user.". .name, aclGetGroup ("Admin")) This isn't really for admins, if you change your nickname, it just won't work. Better use https://wiki.multitheftauto.com/wiki/Has ... rmissionTo and check for function which is only available to admins like ban or make your own ACL list. Link to comment
DutchCaffeine Posted August 9, 2010 Share Posted August 9, 2010 isObjectInACLGroup("user.". .name, aclGetGroup ("Admin")) This isn't really for admins, if you change your nickname, it just won't work. Better use https://wiki.multitheftauto.com/wiki/Has ... rmissionTo and check for function which is only available to admins like ban or make your own ACL list. Or you could use: pAccount = getPlayerAccount(player); -- Or the source in player events. if isGuestAccount(pAcccount) then -- You are not loged in return; -- Return allways stops the script while running. Even if you are out side of a function. end if isObjectInACLGroup("user." .. getAccountName(pAccount), aclGetGroup("Admin")) then -- You got access return true; else -- You aint got the rights. return false; end Link to comment
eAi Posted August 9, 2010 Share Posted August 9, 2010 hasObjectPermissionTo is definitely the right and proper way to do it. isObjectInACLGroup is marginally easier, but less flexible. hasObjectPermissionTo would allow you to let other users use the teleport if you wanted, without having to modify your code at all. You could just create another group and add the users to it, then create another ACL for that group that gives them access to the teleporter. 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