Jump to content

House system


Antonio

Recommended Posts

I have problem with JasperNL and TurboCow house system,when i buy 2 house, then sell them then I want to buy new one then i got in chatbox "You cant have more than 2 house!".I think the problem is here:

addEventHandler ("HouseSystemSellHouse", getRootElement(), 
function(housenumber) 
  if ( housesCanBuy == 1 ) then 
  root = xmlLoadFile ("homes.xml") 
  local houseHeadRootNode = xmlFindChild (root,"houses",0) 
  local houseRootNode = xmlFindChild (houseHeadRootNode,"house",tonumber(housenumber))   
  local price = xmlNodeGetAttribute (houseRootNode,"sellprice") 
  local owner = xmlNodeGetAttribute (houseRootNode,"owner") 
  if not (isGuestAccount (getPlayerAccount(source))) then 
    if (owner == getAccountName(getPlayerAccount(source))) then 
    local playeraccount = getPlayerAccount ( source ) 
    setAccountData ( playeraccount, "house", "no" ) 
    setAccountData ( playeraccount, "price", "---" ) 
    setAccountData ( playeraccount, "number", "---" ) 
    setAccountData ( playeraccount, "sell", "---" ) 
    setAccountData ( playeraccount, "street", "---" ) 
    setAccountData ( playeraccount, "housex", "---" ) 
    setAccountData ( playeraccount, "housey", "---" ) 
    setAccountData ( playeraccount, "housez", "---" ) 
      givePlayerMoney (source,tonumber(price)) 
      xmlNodeSetAttribute (houseRootNode,"owner","") 
      xmlNodeSetAttribute (houseRootNode,"lockStatus","unlock") 
      outputChatBox ("You sold your house!",source,255,200,0,false) 
      xmlSaveFile (root)  
      for i,v in ipairs ( getElementsByType("pickup")) do 
      local number = getElementData ( v, "housenumber" ) 
      if ( number == housenumber ) then 
      setPickupType ( v, 3, 1273 ) 
      end 
      end 
    elseif not (owner == getAccountName(getPlayerAccount(source))) then 
      outputChatBox ("This is not your house!",source,255,200,0,false) 
    end 
  else 
    outputChatBox ("Please log in!",source,255,200,0,false) 
  end 
  xmlSaveFile(root) 
 elseif ( housesCanBuy == 2 ) then 
  local root = xmlLoadFile ("homes.xml") 
  local houseHeadRootNode = xmlFindChild (root,"houses",0) 
  local houseRootNode = xmlFindChild (houseHeadRootNode,"house",tonumber(housenumber))   
  local price = xmlNodeGetAttribute (houseRootNode,"sellprice") 
  local owner = xmlNodeGetAttribute (houseRootNode,"owner") 
  if not (isGuestAccount (getPlayerAccount(source))) then 
    if (owner == getAccountName(getPlayerAccount(source))) then 
    local playeraccount = getPlayerAccount ( source ) 
    local house1 = getAccountData ( playeraccount, "house" ) 
    if ( house1 ) then 
    local number = getAccountData ( playeraccount, "number") 
    if ( number == housenumber ) then 
    setAccountData ( playeraccount, "house", "no" ) 
    setAccountData ( playeraccount, "price", "---" ) 
    setAccountData ( playeraccount, "number", "---" ) 
    setAccountData ( playeraccount, "sell", "---" ) 
    setAccountData ( playeraccount, "street", "---" ) 
    setAccountData ( playeraccount, "housex", "---" ) 
    setAccountData ( playeraccount, "housey", "---" ) 
    setAccountData ( playeraccount, "housez", "---" ) 
      givePlayerMoney (source,tonumber(price)) 
      xmlNodeSetAttribute (houseRootNode,"owner","") 
      xmlNodeSetAttribute (houseRootNode,"lockStatus","unlock") 
      outputChatBox ("You sold your house!",source,255,200,0,false) 
  xmlSaveFile (root)  
      for i,v in ipairs ( getElementsByType("pickup")) do 
      local number = getElementData ( v, "housenumber" ) 
      if ( number == housenumber ) then 
      setPickupType ( v, 3, 1273 ) 
      end 
      end 
      else 
      local house2 = getAccountData ( playeraccount, "house2" ) 
    if ( house2 ) then 
    local number2 = getAccountData ( playeraccount, "number2") 
    if ( number2 == housenumber ) then 
    setAccountData ( playeraccount, "house2", "no" ) 
    setAccountData ( playeraccount, "price2", "---" ) 
    setAccountData ( playeraccount, "number2", "---" ) 
    setAccountData ( playeraccount, "sell2", "---" ) 
    setAccountData ( playeraccount, "street2", "---" ) 
    setAccountData ( playeraccount, "housex2", "---" ) 
    setAccountData ( playeraccount, "housey2", "---" ) 
    setAccountData ( playeraccount, "housez2", "---" ) 
      givePlayerMoney (source,tonumber(price)) 
      xmlNodeSetAttribute (houseRootNode,"owner","") 
      xmlNodeSetAttribute (houseRootNode,"lockStatus","unlock") 
      outputChatBox ("You sold your house!",source,255,200,0,false) 
    xmlSaveFile (root)  
      for i,v in ipairs ( getElementsByType("pickup")) do 
      local number = getElementData ( v, "housenumber" ) 
      if ( number == housenumber ) then 
      setPickupType ( v, 3, 1273 ) 
      end 
      end 
      end 
      end 
      end 
      end 
    elseif not (owner == getAccountName(getPlayerAccount(source))) then 
      outputChatBox ("This is not your house!",source,255,200,0,false) 
    end 
  else 
    outputChatBox ("Please log in!",source,255,200,0,false) 
  end 
end   
 xmlUnloadFile (root)   
  xmlSaveFile (root)  
end) 

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