Jump to content

Help me Fix MTA Scripts


daffabahy

Recommended Posts

Posted

addEvent("onPlayerDayZRegister", true) 
addEventHandler("onPlayerDayZRegister", getRootElement(), playerRegister) 
function saveAccounts() 
  local account = getPlayerAccount(source) 
  if account then 
    for i, data in ipairs(playerDataTable) do 
      setAccountData(account, data[1], getElementData(source, data[1])) 
    end 
    local x, y, z = getElementPosition(source) 
    setAccountData(account, "last_x", x) 
    setAccountData(account, "last_y", y) 
    setAccountData(account, "last_z", z) 
    destroyElement(getElementData(source, "playerCol")) 
  end 
  setElementData(source, "logedin", false) 
end 
  

i have small problem, i cant fix that, can you help me ?

[12:57:45] WARNING: [DayZ-MTA]/DayZ/login.lua:404: Bad argument @ 'destroyElemen 
t' [Expected element at argument 1, got boolean] 

Posted

Seems like 'getElementData(source, "playerCol")' is false.

You can perform a check beforehand like:

local pCol = getElementData(source, "playerCol")) 
if (pCol and isElement(pCol)) then 
    destroyElement(pCol) 
end 

Posted
Seems like 'getElementData(source, "playerCol")' is false.

You can perform a check beforehand like:

local pCol = getElementData(source, "playerCol")) 
if (pCol and isElement(pCol)) then 
    destroyElement(pCol) 
end 

Does not work, pls help me

Posted
  
    destroyElement(getElementData(source, "playerCol")) 
  

Get Element Data returns :

"This function returns a variable containing the requested element data, or false if the element or the element data does not exist. When getting data corresponding to a XML attribute, this is always a string."

It doesn't return an element , and also it is returning false; so when you use destroyElement boolean "false" is supplied not the element.

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