A
A
AndRussia2020-10-11 14:07:02
Lua
AndRussia, 2020-10-11 14:07:02

MtaLUA. Why doesn't it work?

Hello. Why does getPlayerAccount() return nil etc.?
I tried to write both getPlayerAccount(source) and getPlayerAccount(player) and getPlayerAccount(thePlayer) but all in vain. I do everything according to the lesson and it works there. I also checked with the mta wiki and everything is correct there. Why doesn't it work?

function quitPlayer()
  local acc = getPlayerAccount()
    if acc and not isGuestAccount(acc) then
        setAccountData(acc, 'money', getPlayerMoney(player))
        setAccountData(acc, 'health', getElementHealth (player))
    end
end
addEventHandler ( "onPlayerQuit", root, quitPlayer )

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MorganDusty, 2020-10-11
@MorganDusty

getPlayerAccount on server side only

Y
Yuri Chaikos, 2021-01-09
@Chaikos

The parentheses do not specify the element for which we will check the account
In the onPlayerQuit inventory, the player is source
Replace getPlayerAccount() with getPlayerAccount( source )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question