Jump to content

Errors in the GTIHousing system


ismai1kd

Recommended Posts

Those errors are showing that the resource cannot connect to the database.
Obvisouly it's set to connect to localhost (127.0.0.1) but if you don't have MySQL server hosted on this address (which probably is the case) then this is the reason of those errors.

Edited by SpecT
Link to comment

Thank You So Much I Got The Database Done But How To Fix The Red Error

----------------------------------------->>
-- Grand Theft International (GTi)
-- Author: JT Pennington (JTPenn)
-- Date: 09 Nov 2014
-- Resource: GTIhousing/housing.slua
-- Version: 1.0
----------------------------------------->>

local activeID = {}	-- Current House ID

-- Show Housing Panel
---------------------->>

addEventHandler("onPickupHit", resourceRoot, function(player)
	if (isPedInVehicle(player)) then return end
	exports.GTIhud:drawNote("HouseMsg", "Press Z to view house info", player, 30, 160, 115, 5000)
	if (not isKeyBound(player, "z", "up", showHousingPanel)) then
		bindKey(player, "z", "up", showHousingPanel)
	end
	activeID[player] = source
end)

function showHousingPanel(player)
	if (not activeID[player] or not isElement(activeID[player])) then return end
	unbindKey(player, "z", "up", showHousingPanel)
	exports.GTIhud:drawNote("HouseMsg", nil, player)
	
	local x,y = getElementPosition(player)
	local px,py = getElementPosition(activeID[player])
	if (isPedInVehicle(player) or getDistanceBetweenPoints2D(x,y,px,py) >= 2) then activeID[player] = nil return end
	
		-- Home GUI Information
	local house = {}
	house["id"] 		= getElementData(activeID[player], "id")
	local id 			= house["id"]
	house["interior"] 	= getHouseData(id, "interior")
	local name 			= getHouseData(id, "name") or false
	house["address"] 	= (name and name.."\n" or "")..getHouseData(id, "address") ---------38. line
	local owner			= getHouseData(id, "owner")
	if (owner) then
		local player = getAccountPlayer(getAccount(owner))
		local _owner = exports.GTIaccounts:GAD(getAccount(owner),"lastname") or owner
		house["owner"] 	= (player and getPlayerName(player) or _owner).." ("..owner..")"
	else
		house["owner"]	= "Unowned"
	end
	house["value"] 		= getHouseData(id, "value")
	
		-- Home Ownership
	house["isOwner"] 	= doesPlayerOwnHouse(player, id)
	house["forSale"] 	= isHouseForSale(id)
	house["saleCost"]	= getHouseSaleCost(id)
	house["boughtFor"] 	= getHouseData(id, "bought_for")
		-- Home Rental
	house["forRent"] 	= isHouseForRent(id)
	house["renter"] 	= getHouseRenter(id)
	house["rent"] 		= getHouseRentCost(id)
		-- Admin Functions
	house["locked"]		= isHouseLocked(id)
	house["access"]		= canPlayerAccessHouse(player, id)

	triggerClientEvent(player, "GTIhousing.showHousingPanel", resourceRoot, house, activeID[player])
end

addEvent("GTIhousing.closePanel", true)
addEventHandler("GTIhousing.closePanel", root, function()
	activeID[client] = nil
end)

-- Enter House
--------------->>

addEvent("GTIhousing.enterHouse", true)
addEventHandler("GTIhousing.enterHouse", root, function(id)
	if (isHouseLocked(id) and not canPlayerAccessHouse(client, id)) then
		exports.GTIhud:dm("This house is locked. You cannot enter it.", client, 255, 125, 0)
		return
	end
	if (exports.GTIgangTerritories:canPlayerTurf(client)) then 
		exports.GTIhud:dm("You cannot enter houses while a turfer.", client, 255, 125, 0)
		return
	end
	
	local int = getHouseInterior(id)
	warpIntoHouseInterior(client, int, id)
	activeID[client] = nil
end)

-- Buy House
------------->>

addEvent("GTIhousing.buyHouse", true)
addEventHandler("GTIhousing.buyHouse", root, function(house)
	local bought = buyHouse(client, house)
	if (not bought) then return end
	triggerClientEvent("GTIhousing.closePanel", resourceRoot, house)
	activeID[client] = nil
end)

-- Sell House
-------------->>

addEvent("GTIhousing.sellHouse", true)
addEventHandler("GTIhousing.sellHouse", root, function(house, toPublic, value)
	if (toPublic) then
		sellHouse(client, house, value)
	else
		sellHouse(client, house)
	end
end)

addEvent("GTIhousing.revokeSale", true)
addEventHandler("GTIhousing.revokeSale", root, function(house)
	revokeSale(client, house)
	triggerClientEvent("GTIhousing.closePanel", resourceRoot, house)
end)

 

Link to comment

I suspect that it has something to do with the database. Something must be missing or wrong with the database structure.
I don't see anything wrong on this line.

PS: I just checked the code from the other files in the GTIhousing and those getHouseData and setHouseData have operations with the database.
As you can see the first orange errors are about the failure of connecting to the database.

The resources have operations to create the DB tables if they don't exist but at first you NEED to create the database and change the details in database.slua

On line 18 in database.slua you should change your details for the database:

local db = dbConnect("mysql", "dbname=gti;host=127.0.0.1", "username", "password")


If you host it on your PC (maybe Windows?) you will need XAMPP to host a MySQL server on your machine and setup all the stuff in phpMyAdmin.
Or if it's hosted on server you should create a database in the control panel of the hosting site you use and then again set it up with phpMyAdmin.

Edited by SpecT
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...