sckatchof Posted April 16, 2012 Share Posted April 16, 2012 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
Aibo Posted April 16, 2012 Share Posted April 16, 2012 where is this event triggered and what is in housenumber variable? Link to comment
drk Posted April 16, 2012 Share Posted April 16, 2012 Show how you trigger the event. Link to comment
sckatchof Posted April 16, 2012 Author Share Posted April 16, 2012 Show how you trigger the event. you mean that if (source == ButtonBuyHouse) then local housenumber = guiGetText (LabelHouseNumber) triggerServerEvent ("HouseSystemBuyHouse",localPlayer,housenumber) end Link to comment
Aibo Posted April 16, 2012 Share Posted April 16, 2012 guiGetText returns a string, try it with tonumber(housenumber) also "/debugscript 3" helps Link to comment
sckatchof Posted April 17, 2012 Author Share Posted April 17, 2012 guiGetText returns a string, try it with tonumber(housenumber)also "/debugscript 3" helps i add tonumber(housenumber) and still don't work and nothing it show in debugscript 3 Link to comment
sckatchof Posted April 17, 2012 Author Share Posted April 17, 2012 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
drk Posted April 17, 2012 Share Posted April 17, 2012 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
sckatchof Posted April 17, 2012 Author Share Posted April 17, 2012 don't work i have bad argument line 6 7 8 in server side and when i click buy house it outputChatBox ("This house is already Bought!",source, ... Link to comment
Kenix Posted April 17, 2012 Share Posted April 17, 2012 Check what return this line local nHouse = guiGetText ( housenumber ); Link to comment
drk Posted April 17, 2012 Share Posted April 17, 2012 Remove tonumber from xmlFindChild, it's already triggered as number. Anyway, wait for other person, I'm not going to post here because some retardeds will start saying some shits like Solidsnaka. Link to comment
sckatchof Posted April 17, 2012 Author Share Posted April 17, 2012 Check what return this line local nHouse = guiGetText ( housenumber ); Omg thnx kenix i forget something it's not "housenumer" it's" "LabelHouseNumber" and now when i buy the house it work but pickup don't change and owner on gui don't change . 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