Noneatme

[REL]A Dynamic MySQL based housesystem

Recommended Posts

How much times does it take rental? Month, week, day ?

And please make them able to sell their houses for an amount they can specify

Regards, Tomaat

Several days

Cant you do, When player entered a house, take playername, and house id and compare name to ownername, when is same he can use the f5 panel in the dimension (aka, the same as the house id) and when he leaves house, then disable the f5 panel, maybe by using the command /out the same as disable panel command?

Good luck, I do not do it because you can do it too, and other players do not want this. Im Sorry

- None

Well im a noob at scripting, so i cant :P i dont really need it, i like it how it is now ^^ it was just an idea how to let it work

And can i change the "Several days" somewhere?

btw, i love your housesystem

Regards, Tomaat

Share this post


Link to post

i am having trouble starting the script plz help :(

Share this post


Link to post

I don't have that dbs_housesystem.sql file in the folder. And when i try to start the resource, it says:

dbConnect failed; unkown database 'dbs_housesystem2'

[HOUSESYSTEM]MySQL handler 1 not accepted! Trying secondary handler...

dbConnect failed; unkown database 'dbs_housesystem'

[HOUSESYSTEM]MySQL handler 1 not accepted! Shutting down...

Share this post


Link to post

I created the databases in phpmyadmin with XAMPP. but I have this problems :/ :

  
[2012-09-19 19:53:43] start: Requested by #CACACAKrl#00fbffooZ(ElMota) 
[2012-09-19 19:53:43] Starting casas 
[2012-09-19 19:53:43] [HOUSESYSTEM]MySQL handler 1 accepted! 
[2012-09-19 19:53:43] WARNING: casas\server.lua:543: (null) failed; Table 'dbs_housesystem2.houses' doesn't exist 
[2012-09-19 19:53:43] ERROR: casas\server.lua:564: Houses Table not Found\empty! 
[2012-09-19 19:55:03] WARNING: casas\server.lua:686: (null) failed; Table 'dbs_housesystem2.houses' doesn't exist 
[2012-09-19 19:55:03] ERROR: casas\server.lua:697: House 1 could not create! 

Share this post


Link to post
I created the databases in phpmyadmin with XAMPP. but I have this problems :/ :

  
[2012-09-19 19:53:43] start: Requested by #CACACAKrl#00fbffooZ(ElMota) 
[2012-09-19 19:53:43] Starting casas 
[2012-09-19 19:53:43] [HOUSESYSTEM]MySQL handler 1 accepted! 
[2012-09-19 19:53:43] WARNING: casas\server.lua:543: (null) failed; Table 'dbs_housesystem2.houses' doesn't exist 
[2012-09-19 19:53:43] ERROR: casas\server.lua:564: Houses Table not Found\empty! 
[2012-09-19 19:55:03] WARNING: casas\server.lua:686: (null) failed; Table 'dbs_housesystem2.houses' doesn't exist 
[2012-09-19 19:55:03] ERROR: casas\server.lua:697: House 1 could not create! 

create a houses table in your database, or execute the sql tables supplied with the script

-Tomaat

Share this post


Link to post

BUG: if you change the name of another player who owns the house can then sell the house.

Share this post


Link to post

I create a MySQL database in my web server but dont work

How can I execute SQL files ?

Share this post


Link to post

Yep I failed something.

A user uploaded a new version of the database in this topic.

Share this post


Link to post
Yep I failed something.

A user uploaded a new version of the database in this topic.

I can't find it. :?

Share this post


Link to post

Great job Noneatme but its a little bit hard for newbies to install this script as it requires a LUA and MYSQl experiance and also MYSQl data base :/.

Share this post


Link to post

Looks pretty solid. Full featured, and it uses SQL which is a much more efficient way to store data than XML.

The grammar issues are a bit distracting though, but since you acknowledge that yourself I hope you take this as more helpful than critical:

- The dollar sign ($) always comes before the numbers ($10,000 rather than 10,000$)

- Some words are combined that don't need to be ("Rental price", "House menu")

- In "This House is locked/unlocked", house doesn't need to be capitalized

Other than that it seems pretty good, certainly an improvement over other interior systems that are available on the community.

Share this post


Link to post

Hey Guys,

I only just started server modding yesterday and tried this out, While I got it to work I noticed that there is no house exits and also found others have the same issue.

I've done a fix on this and so here it is;

Backup your original copies to be safe (Just in-case but this should work)

housesystem_mysql :: server.lua - Copy and replace you current script;

  
-- MySQL Housesystem created & released by Noneatme(MuLTi), Do not remove credits! --
-- All Rights go to Noneatme --
 
--[[ Total time token:
    - 3 hour
    - 1.5 hour
    ________
    4.5 hours
]]
 
------------------------
-- CONNECTION HANDLER --
------------------------
 
-- Here you can change some settings --
-- FIRST CONNECTION --
 
 
local mysqlhost1 = "hostname"
local mysqluser1 = "dbusername"
local mysqlpassword1 = "dbpass"
local mysqldatabase1 = "dbtable"
 
-- SECOND CONNECTION, OPTIONAL IF CONNECTION 1 DON'T WORK
local mysqlhost2 = "hostname"
local mysqluser2 = "dbusername"
local mysqlpassword2 = "dbpass"
local mysqldatabase2 = "dbtable"
 
local dbpTime = 500 -- How many Miliseconds will use the dbPoll function for waiting for a result
 
local max_player_houses = 3 -- Define the buyable houses per player
local sellhouse_value = 80 -- The ammount in percent that you get back if you sell a house
local open_key = "F6" -- Define the key for the infomenue and the housepanel
 
-- I don't know whats the right time for that --
 
-----------------------------------------------------------------
-- IF YOU CAN'T WRITE IN LUA, DO NOT EDIT ANYTHING ABOVE HERE! --
-----------------------------------------------------------------
 
-- EVENTS --
 
addEvent("onHouseSystemHouseCreate", true)
addEvent("onHouseSystemHouseLock", true)
addEvent("onHouseSystemHouseDeposit", true)
addEvent("onHouseSystemHouseWithdraw", true)
addEvent("onHouseSystemWeaponDeposit", true)
addEvent("onHouseSystemWeaponWithdraw", true)
addEvent("onHouseSystemRentableSwitch", true)
addEvent("onHouseSystemRentalprice", true)
addEvent("onHouseSystemTenandRemove", true)
addEvent("onHouseSystemInfoBuy", true)
addEvent("onHouseSystemInfoRent", true)
addEvent("onHouseSystemInfoEnter", true)
addEvent("onHouseSystemHouseExit", true)
 
local handler -- local only, we don't need a global handler
 
local saveableValues = {
    ["MONEY"] = "MONEY",
    ["WEAP1"] = "WEAP1",
    ["WEAP2"] = "WEAP2",
    ["WEAP3"] = "WEAP3",
    ["LOCKED"] = "LOCKED",
    ["OWNER"] = "OWNER",
    ["RENTABLE"] = "RENTABLE",
    ["RENTALPRICE"] = "RENTALPRICE",
    ["RENT1"] = "RENT1",
    ["RENT2"] = "RENT2",
    ["RENT3"] = "RENT3",
    ["RENT4"] = "RENT4",
    ["RENT5"] = "RENT5",
}
 
 
local created = false -- DONT EDIT
local houseid = 0 -- Define the Houseid,
 
local house = {} -- The House array
local houseData = {} -- The House Data arry
local houseInt = {} -- The House Interior array
local houseIntData = {} -- The House Interior Data Array
 
local buildStartTick
local buildEndTick
 
local rentTimer
 
-- STARTUP EVENT HANDLER --
 
addEventHandler("onResourceStart", getResourceRootElement(), function()
    handler = dbConnect("mysql", "dbname="..mysqldatabase1..";host="..mysqlhost1, mysqluser1, mysqlpassword1, "autoreconnect=1")
 
    -- If the Handler 1 dont work
    if not(handler) then   
        outputServerLog("[HOUSESYSTEM]MySQL handler 1 not accepted! Trying secondary handler...")   
        handler = dbConnect("mysql", "dbname="..mysqldatabase2..";host="..mysqlhost2, mysqluser2, mysqlpassword2, "autoreconnect=1")
        if not(handler) then
            outputServerLog("[HOUSESYSTEM]MySQL handler 2 not accepted! Shutting down...")
            cancelEvent()
        else
            outputServerLog("[HOUSESYSTEM]MySQL handler 2 accepted!")
            housesys_startup()
        end
    else
        outputServerLog("[HOUSESYSTEM]MySQL handler 1 accepted!")
        housesys_startup()
    end
end)
 
-- SHUTDOWN EVENT HANDLER --
addEventHandler("onResourceStop", getResourceRootElement(), function()
    -- Free the arrays --
    for index, houses in pairs(house) do
        houses = nil
    end
    for index, houseDatas in pairs(houseData) do
        houseDatas = nil
    end
    for index, houseInts in pairs(houseInt) do
        houseInts = nil
    end
    for index, houseIntDatas in pairs(houseIntData) do
        houseIntDatas = nil
    end
   
    houseid = 0
    created = false
end)
 
--------------
-- COMMANDS --
--------------
 
-- /unrent --
 
addCommandHandler("unrent", function(thePlayer)
    if(getElementData(thePlayer, "house:lastvisit")) and (getElementData(thePlayer, "house:lastvisit") ~= false)  then
        local id = tonumber(getElementData(thePlayer, "house:lastvisit"))
        if(isPlayerRentedHouse(thePlayer, id) == false) then
            outputChatBox("You are not tenad of this house!", thePlayer, 255, 0, 0)
            return
        end
        local sucess = removeHouseTenand(id, thePlayer)
        if(sucess == true) then
            outputChatBox("You have sucessfull terminate the tenancy!", thePlayer, 0, 255, 0)
        else
            outputChatBox("An error occurred!", thePlayer, 255, 0, 0)
        end
    end
end)
 
-- /rent --
 
addCommandHandler("rent", function(thePlayer)
    if(getElementData(thePlayer, "house:lastvisit")) and (getElementData(thePlayer, "house:lastvisit") ~= false)  then
        local id = tonumber(getElementData(thePlayer, "house:lastvisit"))
        if(houseData[id]["OWNER"] == getPlayerName(thePlayer)) then
            outputChatBox("You can't rent here! It's your house!", thePlayer, 255, 0, 0)
            return
        end
        if(tonumber(houseData[id]["RENTABLE"]) ~= 1) then
            outputChatBox("This house is not rentable!", thePlayer, 255, 0, 0)
            return
        end
        if(getPlayerRentedHouse(thePlayer) ~= false) then
            outputChatBox("You are allready a tenand in a house! Use /unrent first.", thePlayer, 255, 0, 0)
            return
        end
        local sucess = addHouseTenand(thePlayer, id)
        if(sucess == true) then
            outputChatBox("You are now tenand this house!", thePlayer, 0, 255, 0)
        else
            outputChatBox("You can't rent this house!", thePlayer, 255, 0, 0)
        end
    end
end)
 
-- /createhouse --
 
addCommandHandler("createhouse", function(thePlayer)
    if(hasObjectPermissionTo ( thePlayer, "function.kickPlayer", false ) ) then
        if(getElementInterior(thePlayer) ~= 0) then
            outputChatBox("You are not outside!", thePlayer, 255, 0, 0)
            return
        end
        if(isPedInVehicle(thePlayer) == true) then
            outputChatBox("Please exit your vehicle.", thePlayer, 255, 0, 0)
            return
        end
        -- INSERT SECURITY OPTIONS LIKE ADMINLEVEL HERE( if(adminlevel > shit) then ...)
        triggerClientEvent(thePlayer, "onClientHouseSystemGUIStart", thePlayer)
    else
        outputChatBox("You are not an admin!", thePlayer, 255, 0, 0)
    end
end)
 
-- /in --
 
addCommandHandler("in", function(thePlayer)
    if(getElementData(thePlayer, "house:lastvisit")) and (getElementData(thePlayer, "house:lastvisit") ~= false)  then
        local house = getElementData(thePlayer, "house:lastvisit")
        if(house) then
            local id = tonumber(house)
            if(tonumber(houseData[id]["LOCKED"]) == 0) or (houseData[id]["OWNER"] == getPlayerName(thePlayer)) or (isPlayerRentedHouse(thePlayer, id) == true) then
                local int, intx, inty, intz, dim = houseIntData[id]["INT"], houseIntData[id]["X"], houseIntData[id]["Y"], houseIntData[id]["Z"], id
                setElementData(thePlayer, "house:in", true)
                setInPosition(thePlayer, intx, inty, intz, int, false, dim)
                unbindKey(thePlayer, open_key, "down", togglePlayerInfomenue, id)
                setElementData(thePlayer, "house:lastvisitINT", id)
                if(houseData[id]["OWNER"] == getPlayerName(thePlayer)) or (isPlayerRentedHouse(thePlayer, id) == true) then
                    bindKey(thePlayer, open_key, "down", togglePlayerHousemenue, id)
                end
            else
                outputChatBox("You don't have the housekey for this House!", thePlayer, 255, 0, 0)
            end
        end
    end
end)
 
-- /out --
 
addCommandHandler("out", function(thePlayer)
    if(getElementData(thePlayer, "house:lastvisitINT")) and (getElementData(thePlayer, "house:lastvisitINT") ~= false)  then
        local house = getElementData(thePlayer, "house:lastvisitINT")
        if(house) then
            local id = tonumber(house)
            local x, y, z = houseData[id]["X"], houseData[id]["Y"], houseData[id]["Z"]
            setElementData(thePlayer, "house:in", false)
            setInPosition(thePlayer, x, y, z, 0, false, 0)
        end
    end
end)
 
-- /buyhouse --
 
addCommandHandler("buyhouse", function(thePlayer)
    if(getElementData(thePlayer, "house:lastvisit")) and (getElementData(thePlayer, "house:lastvisit") ~= false)  then
        local house = getElementData(thePlayer, "house:lastvisit")
        if(house) then
            local id = house
            local owner = houseData[id]["OWNER"]
            if(owner ~= "no-one") then
                outputChatBox("You can't buy this house!", thePlayer, 255, 0, 0)
            else
                local houses = 0
                for index, col in pairs(getElementsByType("colshape")) do
                    if(getElementData(col, "house") == true) and (houseData[getElementData(col, "ID")]["OWNER"] == getPlayerName(thePlayer)) then

Share this post


Link to post

The 2 scripts I added includes it onto the interface unless the player is not the house owner, the player will exit on collision with the arrow.

Share this post


Link to post

Could someone change that record was on the account, and not on the nickname?

Share this post


Link to post

can u add button for get out from house please.. some players dont know do /out

Share this post


Link to post

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.