Sr. Bruxo Posted April 23 Share Posted April 23 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 xLive Posted April 23 Scripting Moderators Share Posted April 23 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. 1 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