Jump to content

Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean]


Recommended Posts

my debug is showing this (Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean]), whenever a player passes through the gate.

local gate = createObject(2933, 1334.8000488281, -1334.1999511719, 14 ,0, 0, 89.504455566406)  --13188
local marker = createMarker(1334.8000488281, -1334.1999511719, 14, "cylinder", 8, 0, 0, 0, 0)
 
function moveGate(thePlayer)
     if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)) , aclGetGroup("PMESP")) then
          moveObject(gate, 1500, 1334.8000488281, -1334.1999511719, 10)
     end
end
addEventHandler("onMarkerHit", marker, moveGate)
 
function move_back_gate()
     moveObject(gate, 2000, 1334.8000488281, -1334.1999511719, 14)
end
addEventHandler("onMarkerLeave", marker, move_back_gate)
What did I do wrong?
Link to comment
  • Scripting Moderators

The warning occurs because onMarkerHit can be triggered by other elements like vehicles, not just players. This means you're sometimes passing a non-player element to getPlayerAccount, which results in returning false instead of an account. You should check if thePlayer is actually a player element before doing anything:

function moveGate(thePlayer)
     if getElementType(thePlayer) == "player" then
          if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)) , aclGetGroup("PMESP")) then
               moveObject(gate, 1500, 1334.8000488281, -1334.1999511719, 10)
          end
     end
end
addEventHandler("onMarkerHit", marker, moveGate)

You should do the same in the move_back_gate function, otherwise, it will execute twice when a player enters with a vehicle, for example.

  • Like 1
Link to comment

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