mjau Posted February 8, 2012 Share Posted February 8, 2012 Hi i got a small problem with a XML file if i want to get a specified line/house out of the code below how? im asking this cuz i wanna make so when a player hits the pikup for the house it shows price owner housename etc <houseData> <house markerPosX="-1302.248046875" markerPosY="-111.3232421875" markerPosZ="14.1484375" houseName="nab" owner="nil"></house> <house markerPosX="-1303.59375" markerPosY="-111.072265625" markerPosZ="14.1484375" houseName="blabla" owner="nil"></house> <house markerPosX="-1308.1611328125" markerPosY="-109.3642578125" markerPosZ="14.1484375" houseName="heytrololo" owner="nil"></house> <house markerPosX="-1307.861328125" markerPosY="-112.10546875" markerPosZ="14.1484375" houseName="blahhh" owner="nil"></house> <house markerPosX="-1305.9541015625" markerPosY="-114.6572265625" markerPosZ="14.1484375" houseName="cake:D" owner="nil"></house> </houseData> So if i hit thepickup created for the house named cake:D it shows its prices etc Link to comment
Fentas Posted February 8, 2012 Share Posted February 8, 2012 Having an unique ID for every house is good idea, but using XML for a house system is not that good. Loading very big XML files with more than 1000+ houses and that much data may cause server lag problems (tested). I suggest you using other ways to store the houses. P.S : You can use setElementData to give an unique ID for every house when you load the houses. Link to comment
Kenix Posted February 8, 2012 Share Posted February 8, 2012 Use your xml to map You can use getElementsByType And you can use your house data/markers and etc. I always use this in gm , because you can create something in map editor and easy change it. In gm you just get data in map. Link to comment
mjau Posted February 8, 2012 Author Share Posted February 8, 2012 Eh expalin further please and anyway i need to get the exact house that belongs to that pickup(if u want i can pm u my code ...) Link to comment
Kenix Posted February 8, 2012 Share Posted February 8, 2012 it created marker( get house elements in map file ). local marker local function onHit ( element,dim ) if getElementType( element ) == 'player' and not isPedInVehicle( element ) then -- your code end end local function onLeave ( element,dim ) if getElementType( element ) == 'player' and not isPedInVehicle( element ) then -- your code end end addEventHandler( 'onResourceStart',resourceRoot, function( ) local markers = getElementsByType 'house' if #markers > 0 then for _,v in pairs( markers ) do marker = createMarker( getElementData( 'markerPosX' ), getElementData( 'markerPosY' ), getElementData( 'markerPosZ' ) ) setElementData( marker,'houseName',getElementData( v,'houseName' ) ) setElementData( marker,'owner',getElementData( v,'owner' ) ) addEventHandler( 'onMarkerHit',marker,onHit ) addEventHandler( 'onMarkerLeave',marker,onLeave ) end end end ) Also you can create edf for easy change you houses in map editor. ( Just change marker pos and etc ). For owner , houseName and etc better use SQL/MySQL. 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