opnaiC Posted July 5, 2016 Share Posted July 5, 2016 function teleport(thePlayer,cmd,target) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then x,y,z = getElementPosition (target) local player = getPlayerFromName( target ) if (player) then setElementPosition (thePlayer, x,y,z) end end end addCommandHandler( "tp", teleport, false, false) What is wrong ? Link to comment
Walid Posted July 5, 2016 Share Posted July 5, 2016 Try this untested i'm using the phone function teleport(thePlayer,cmd,target) local account = getPlayerAccount(thePlayer) if account and not isGuestAccount(account) then local accName = getAccountName (account) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then if target then local player = getPlayerFromName(target) if (player) then local position = Vector3 (getElementPosition(player)) setElementPosition (thePlayer,position.x,position.y,position.z) end end end end end addCommandHandler( "tp", teleport) Link to comment
FelipeMallmann Posted July 5, 2016 Share Posted July 5, 2016 Before trying to get x,y,z from the target, you must check if the target exists and if it is a player function teleport(thePlayer,cmd,target) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then if (target) then local targetPlayer = getPlayerFromName(target) if (targetPlayer) then x,y,z = getElementPosition (targetPlayer) setElementPosition (thePlayer, x,y,z) else outputChatBox("this target is not a player") end else outputChatBox("target needed", thePlayer) end else outputChatBox("you are not adm", thePlayer) end end addCommandHandler( "tp", teleport) 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