Jump to content

help please


sckatchof

Recommended Posts

hello my friends i have post this problem again cause nobody can help me , my problem when i buy a house it output outputChatBox ("You have buy this house ...) and Nothing it change in xml file and owner stay blank and pick up don't change to 1273 .

Server side :

addEvent("HouseSystemBuyHouse",true) 
addEventHandler ("HouseSystemBuyHouse", getRootElement(), 
function(housenumber) 
  local root = xmlLoadFile ("homes.xml") 
  local houseHeadRootNode = xmlFindChild (root,"houses",0) 
  local houseRootNode = xmlFindChild (houseHeadRootNode,"house",tonumber(housenumber))   
  local price = xmlNodeGetAttribute (houseRootNode,"cost") 
  local owner = xmlNodeGetAttribute (houseRootNode,"owner") 
  if not (isGuestAccount (getPlayerAccount(source))) then 
    if (owner == "") and (getPlayerMoney (source) >= tonumber(price)) then 
      takePlayerMoney (source,tonumber(price)) 
      xmlNodeSetAttribute (houseRootNode,"owner",getAccountName(getPlayerAccount(source))) 
      outputChatBox ("You have buy this house for : ".. tostring(price) .. "$",source,255,255,255,false) 
         for i,v in ipairs ( getElementsByType("pickup")) do 
            local number = getElementData ( v, "housenumber" ) 
            if ( number == housenumber ) then 
            setPickupType ( v, 3, 1273 ) 
            end 
            end 
        xmlSaveFile (root) 
    elseif not (owner == "") then 
      outputChatBox ("This house is already Bought!",source,255,0,0,false) 
    elseif (getPlayerMoney (source) < tonumber(price)) then 
      outputChatBox ("You don't have enough money.",source,255,0,0,false) 
    end 
  end 
  triggerClientEvent (source,"hideHouseGuiWindow",source) 
  xmlUnloadFile (root)   
end) 

Link to comment

client :

  elseif (source == ButtonBuyHouse) then 
    local housenumber = guiGetText (tonumber(housenumber)) 
    triggerServerEvent ("HouseSystemBuyHouse",localPlayer,housenumber) 

server side :

addEvent("HouseSystemBuyHouse",true) 
addEventHandler ("HouseSystemBuyHouse", getRootElement(), 
function(housenumber) 
  local root = xmlLoadFile ("homes.xml") 
  local houseHeadRootNode = xmlFindChild (root,"houses",0) 
  local houseRootNode = xmlFindChild (houseHeadRootNode,"house",tonumber(housenumber))   
  local price = xmlNodeGetAttribute (houseRootNode,"cost") 
  local owner = xmlNodeGetAttribute (houseRootNode,"owner") 
  if not (isGuestAccount (getPlayerAccount(source))) then 
    if (owner == "") and (getPlayerMoney (source) >= tonumber(price)) then 
      takePlayerMoney (source,tonumber(price)) 
      xmlNodeSetAttribute (houseRootNode,"owner",getAccountName(getPlayerAccount(source))) 
      outputChatBox ("Congratulations, you are the new owner!",source,255,0,0,false) 
      outputChatBox ("Price: ".. tostring(price) .. "$!",source,255,0,0,false) 
      for i,v in ipairs ( getElementsByType("pickup")) do 
            local number = getElementData ( v, "housenumber" ) 
            if ( number == housenumber ) then 
            setPickupType ( v, 3, 1272 ) 
            end 
            end 
      xmlSaveFile (root) 
    elseif not (owner == "") then 
      outputChatBox ("This house is already Bought!",source,255,0,0,false) 
    elseif (getPlayerMoney (source) < tonumber(price)) then 
      outputChatBox ("Sorry, you are too poor!",source,255,0,0,false) 
    end 
  end 
  xmlUnloadFile (root)   
end 
) 

Link to comment
elseif ( source == ButtonBuyHouse ) then 
    local nHouse = guiGetText ( housenumber ); 
    triggerServerEvent ( 'HouseSystemBuyHouse', localPlayer, tonumber ( nHouse ) ); 
end 

server side :

addEvent("HouseSystemBuyHouse",true) 
addEventHandler ("HouseSystemBuyHouse", getRootElement(), 
function(housenumber) 
  local root = xmlLoadFile ("homes.xml") 
  local houseHeadRootNode = xmlFindChild (root,"houses",0) 
  local houseRootNode = xmlFindChild (houseHeadRootNode,"house",tonumber(housenumber))   
  local price = xmlNodeGetAttribute (houseRootNode,"cost") 
  local owner = xmlNodeGetAttribute (houseRootNode,"owner") 
  if not (isGuestAccount (getPlayerAccount(source))) then 
    if (owner == "") and (getPlayerMoney (source) >= tonumber(price)) then 
      takePlayerMoney (source,tonumber(price)) 
      xmlNodeSetAttribute (houseRootNode,"owner",getAccountName(getPlayerAccount(source))) 
      outputChatBox ("Congratulations, you are the new owner!",source,255,0,0,false) 
      outputChatBox ("Price: ".. tostring(price) .. "$!",source,255,0,0,false) 
      for i,v in ipairs ( getElementsByType("pickup")) do 
            local number = getElementData ( v, "housenumber" ) 
            if ( number == housenumber ) then 
            setPickupType ( v, 3, 1272 ) 
            end 
            end 
      xmlSaveFile (root) 
    elseif not (owner == "") then 
      outputChatBox ("This house is already Bought!",source,255,0,0,false) 
    elseif (getPlayerMoney (source) < tonumber(price)) then 
      outputChatBox ("Sorry, you are too poor!",source,255,0,0,false) 
    end 
  end 
  xmlUnloadFile (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...