Jump to content

[REL] Housing System ( Updates )


CowTurbo

Recommended Posts

An edit of JasperNL=D House system

Rules:

1.Do not edit this script without asking!

2.Dont say you have make it! This script is maked by JasperNL=D and edited by mR|TurboCow!

Install:

To install this resource, go to your resources folder, usuly it is: C:/Program Files/MTA San Andreas/Server/Mods/Deathmatch/Resources

Download the file from community

!!!!!!!!!!Unzip it!!!!!!!!!!!! You must do it before make it work!!!

Put the folder to your resources folder

Refresh resources

Start script, go in server and make house, and have fun :D

Info:

This script is based by JasperNL=D Home system. Now it got much edits. Don't say i stole it, i have asked premission to edit it, and upload it to here.

Updates:

* New House GUI

* Lock/Unlock System

* 1 Pickup and 1 Marker ( Green/blue house pickup, Entering marker )

* House Making GUI

* Sell Price and Street have added

* Maybe was something more ..

How to make Home?

Login using your admin account

Press F5 or do /createhome ( Only for admins )

You getted house creting gui

Fill in all edits

Press Create! button

restart script

Buy a home! :D

If you got eny problems, ask in comments!

Please rate! =D

Forgoted to say, do /keyhouse to lock/unlock your home, or do /home to warp to your home :P

Press Mouse 2 when u are creating house to hide cursor/show cursor!

Good luck.

© mR|TurboCow

---------------------------

Change log 1.3.0

Added destroy house command

do /destroyHouse for that

Added houses reload, no need to restart script enymore!

---------------------------

Change log 1.3.2

Fixed Green/blue house bug. Added 3 interiors.

---------------------------

Change Log 1.4.0

Added (Un)lock button to house gui, no more /keyhouse using!

Added Some settings, see server.lua for them. Now you can chose marker type, marker color, size, and how much houses player can buy ( currently 1 or 2 )

Thx to sE|Villr for idea.

Link:https://community.multitheftauto.com/index.php?p=resources&s=details&id=1841

Edited by Guest
  • Like 1
Link to comment
  • 2 weeks later...
  • 1 month later...

can you make it the marker a arrow to join and exit? that would be nicee

cause here i tried and faild

enterMarkerType = "corona" -- Default ( corona ) 
enterMarkerSize = 0.5 -- Default ( 0.5 ) 
enterMarkerColor = 255, 100, 255 -- Default ( 255,100,255 ) 
housesCanBuy = 2 -- You can chose 1 or 2, if u but 3,4,5... or 0 then script wont gonna work, dont tell i havent warn you. Default ( 1 ) 
  
i chaned the corona to arrow and i get a underground arrow lol 
  

Link to comment
enterMarkerType = "arrow" -- Default ( corona ) 
enterMarkerSize = 1.2 -- Default ( 0.5 )
enterMarkerColor = 255, 100, 255 -- Default ( 255,100,255 )
housesCanBuy = 2 -- You can chose 1 or 2, if u but 3,4,5... or 0 then script wont gonna work, dont tell i havent warn you. Default ( 1 )
houseMarkerHigh = 0.6 -- The 0 point is placed as 'corona' marker normal place. You can move the arrow up(+)/down(-) with it. The arrow gots some sort of bug. If you set it more then 0.5 then it goes underground. Do no what cause it.
 
gResRoot = getResourceRootElement(getThisResource())
function loadAllHouses ()
  local root = xmlLoadFile ("homes.xml")
  local houseroot = xmlFindChild (root,"houses",0)
  if (houseroot) then
    allHouses = {}
    for i,v in ipairs (xmlNodeGetChildren(houseroot)) do
      local x = xmlNodeGetAttribute (v,"x")
      local y = xmlNodeGetAttribute (v,"y")
      local z = xmlNodeGetAttribute (v,"z")
      local lx = xmlNodeGetAttribute (v,"lx")
      local ly = xmlNodeGetAttribute (v,"ly")
      local lz = xmlNodeGetAttribute (v,"lz")
      local number = xmlNodeGetAttribute (v,"num")
      if not (xmlNodeGetAttribute (v,"owner") == "") then
        local marker = createMarker (tonumber(x),tonumber(y),tonumber(z),"corona",0.8,255,0,0,0)
        setElementData (marker,"housenumber",tonumber(number))
        local marker2 = createMarker (tonumber(lx),tonumber(ly),tonumber(lz+houseMarkerHigh),enterMarkerType,enterMarkerSize,enterMarkerColor,255)
        setElementData (marker2,"housenumber2",tonumber(number))
        pickup = createPickup (tonumber(x),tonumber(y),tonumber(z),3,1272,0)
        setElementData ( pickup, "housenumber", number )
      else
        local marker2 = createMarker (tonumber(lx),tonumber(ly),tonumber(lz+houseMarkerHigh),enterMarkerType,enterMarkerSize,enterMarkerColor,255)
        setElementData (marker2,"housenumber2",tonumber(number))
        local marker = createMarker (tonumber(x),tonumber(y),tonumber(z),"corona",0.8,0,255,0,0)
        setElementData (marker,"housenumber",tonumber(number))
        pickup = createPickup (tonumber(x),tonumber(y),tonumber(z),3,1273,0)
        setElementData ( pickup, "housenumber", number )
      end
    --  outputDebugString ("House " .. tostring(number) .. " loaded!")
    end
  end
end
addEventHandler("onResourceStart",gResRoot, loadAllHouses)
 
addEventHandler ("onMarkerHit",getRootElement(),
function(hitElement, dimension)
  if (getElementType (hitElement) == "player") and not (isPedInVehicle (hitElement)) then
    if (getElementData (source,"housenumber")) then
      local housenumber = getElementData (source,"housenumber")
      --outputChatBox (tostring(housenumber),hitElement,255,0,0,false)
      local root = xmlLoadFile ("homes.xml")
      local houseHeadRootNode = xmlFindChild (root,"houses",0)
      local houseRootNode = xmlFindChild (houseHeadRootNode,"house",tonumber(housenumber))
      if (tostring(xmlNodeGetAttribute (houseRootNode,"owner")) == "") then
        triggerClientEvent (hitElement,"viewHouseGUIwindow",hitElement,"For Sell!",tostring(xmlNodeGetAttribute (houseRootNode,"cost")),housenumber,tostring(xmlNodeGetAttribute (houseRootNode,"sellprice")),tostring(xmlNodeGetAttribute (houseRootNode,"street")))
        xmlUnloadFile (root)
      else
        triggerClientEvent (hitElement,"viewHouseGUIwindow",hitElement,tostring(xmlNodeGetAttribute (houseRootNode,"owner")),tostring(xmlNodeGetAttribute (houseRootNode,"cost")),housenumber,tostring(xmlNodeGetAttribute (houseRootNode,"sellprice")),tostring(xmlNodeGetAttribute (houseRootNode,"street")))
        xmlUnloadFile (root)
      end
    end
  end
end)
 
addEventHandler ("onMarkerHit",getRootElement(),
function(hitElement, dimension)
  if (getElementType (hitElement) == "player") and not (isPedInVehicle (hitElement)) then
    if (getElementData (source,"housenumber2")) then
      local housenumber = getElementData (source,"housenumber2")
      --outputChatBox (tostring(housenumber),hitElement,255,0,0,false)
        triggerEvent ("HouseSystemEnterHouse",hitElement,housenumber)
        xmlUnloadFile (root)
    end
  end
end)
 
addEvent("HouseSystemEnterHouse",true)
addEvent("HouseSystemBuyHouse",true)
addEvent("HouseSystemSellHouse",true)
addEvent("tryInterior",true)
addEvent("createhome",true)
 
 
addEventHandler ("HouseSystemBuyHouse", getRootElement(),
function(housenumber)
  if ( housesCanBuy == 1 ) then
  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")
  local sellPrice = xmlNodeGetAttribute (houseRootNode,"sellprice")
  local street = xmlNodeGetAttribute (houseRootNode,"street")
  local x,y,z = getElementPosition ( source )
  if not (isGuestAccount (getPlayerAccount(source))) then
    if (owner == "") and (getPlayerMoney (source) >= tonumber(price)) then
    local playeraccount = getPlayerAccount ( source )
        if ( playeraccount ) then
            local house = getAccountData ( playeraccount, "house" )
            if (house ~= "yes" ) then
            setAccountData ( playeraccount, "house", "yes" )
            setAccountData ( playeraccount, "price", price )
            setAccountData ( playeraccount, "number", housenumber )
            setAccountData ( playeraccount, "sell", sellPrice )
            setAccountData ( playeraccount, "street", street )
            setAccountData ( playeraccount, "housex", x )
            setAccountData ( playeraccount, "housey", y )
            setAccountData ( playeraccount, "housez", z )
            takePlayerMoney (source,tonumber(price))
            xmlNodeSetAttribute (houseRootNode,"owner",getAccountName(getPlayerAccount(source)))
            outputChatBox ("Congratulations, you are the new owner!",source,255,200,0,false)
            outputChatBox ("Price: ".. tostring(price) .. "$!",source,255,200,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)
            else
            outputChatBox ("You have house already!",source,255,0,0,false)
            end
        elseif not (owner == "") then
            outputChatBox ("Sorry, 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
        else
            outputChatBox ("You are too poor or house is bought!",source,255,0,0,false)
            end
        end
    xmlUnloadFile (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,"cost")
    local owner = xmlNodeGetAttribute (houseRootNode,"owner")
    local sellPrice = xmlNodeGetAttribute (houseRootNode,"sellprice")
    local street = xmlNodeGetAttribute (houseRootNode,"street")
    local x,y,z = getElementPosition ( source )
    if not (isGuestAccount (getPlayerAccount(source))) then
     if (owner == "") and (getPlayerMoney (source) >= tonumber(price)) then
    local playeraccount = getPlayerAccount ( source )
        if ( playeraccount ) then
            local house = getAccountData ( playeraccount, "house" )
            if (house ~= "yes" ) then
            setAccountData ( playeraccount, "house", "yes" )
            setAccountData ( playeraccount, "price", price )
            setAccountData ( playeraccount, "number", housenumber )
            setAccountData ( playeraccount, "sell", sellPrice )
            setAccountData ( playeraccount, "street", street )
            setAccountData ( playeraccount, "housex", x )
            setAccountData ( playeraccount, "housey", y )
            setAccountData ( playeraccount, "housez", z )
            takePlayerMoney (source,tonumber(price))
            xmlNodeSetAttribute (houseRootNode,"owner",getAccountName(getPlayerAccount(source)))
            outputChatBox ("Congratulations, you are the new owner!",source,255,200,0,false)
            outputChatBox ("Price: ".. tostring(price) .. "$!",source,255,200,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)
            else
            local house2 = getAccountData ( playeraccount, "house2" )
            if (house2 ~= "yes" ) then
            setAccountData ( playeraccount, "house2", "yes" )
            setAccountData ( playeraccount, "price2", price )
            setAccountData ( playeraccount, "number2", housenumber )
            setAccountData ( playeraccount, "sell2", sellPrice )
            setAccountData ( playeraccount, "street2", street )
            setAccountData ( playeraccount, "housex2", x )
            setAccountData ( playeraccount, "housey2", y )
            setAccountData ( playeraccount, "housez2", z )
            takePlayerMoney (source,tonumber(price))
            xmlNodeSetAttribute (houseRootNode,"owner",getAccountName(getPlayerAccount(source)))
            outputChatBox ("Congratulations, you are the new owner!",source,255,200,0,false)
            outputChatBox ("Price: ".. tostring(price) .. "$!",source,255,200,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)
            else
            outputChatBox ( "You cant buy more than 2 houses!", source, 255,0,0 )
            end
            end
        elseif not (owner == "") then
            outputChatBox ("Sorry, 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
        else
            outputChatBox ("You are too poor or house is bought!",source,255,0,0,false)
            end
        end
    xmlUnloadFile (root)  
    end
end)
 
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 ("Congratulations, you have sold the home!",source,255,200,0,false)
      outputChatBox ("Obtain: ".. tostring(price) .. "$!",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 isn't 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 =
Edited by Guest
Link to comment

WTF?! Why the text wasnt apper, i gonna edit it.

EDIT: Some admins? Why the text wont apper even when i press edit button there is text ?

EDIT2:http://www.mediafire.com/?wl9gyc41u1sdpd2

i have upload it for you, and heres the text down the code which i added to earlier post:

I added for you new option. You can chose enter marker high. This is for uping arrow more higher. Change the code from here with your server.lua ( was i'm right ? ) with that one ( if its not server.lua, then its the server side script :D replace with that one :D ) Good luck, and thx for choosing housing system :D

The marker is done for you ( size and high is chosen with my eyes, do no does it good for u ? )

Link to comment
  • 2 weeks later...
  • 2 weeks later...
I am a new player, how to Login using my admin account?? please help me

Wrong section! post that in "Scripting" category.

Well, nice resource, I liked it (it's like Dakilla's system :lol: anyway nice)

No, actually, Dakilla's house system is better, since they have big differences, one uses XML, and the other SQL.

Link to comment
This company is for real.. They make good stuff and I love the freeroam mode.

Thx.

mine have bugs ? tell me ? :P

Yes it does, but i'm lazy to check download it again.

Hmm, i havent found ...

CowTurbo, I have absolutely no idea where I can get your system. There is no link in this topic besides the one with "server.lua" file... I would like to look at this system, thank you in advance.

Im sorry, haven't noticed ur earlyer post, and yeah, i have deleted link by fault. Thx for saying,

Link: https://community.multitheftauto.com/index.php?p= ... ls&id=1841

Try out my other resources ;)

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