Jump to content

Interior selling token error


HuskLV

Recommended Posts

Hey. I make interior system with token, but i want make if interior is buying by token you can't sell him.

There script.

function sellProperty(thePlayer, commandName, bla)
	if bla then
		outputChatBox("Use /sell to sell another player.", thePlayer, 255, 0, 0)
		return
	end
	 
	local dbid, entrance, exit, interiorType, interiorElement = findProperty( thePlayer )
	if dbid > 0 then
		if interiorType == 2 then
			outputChatBox("You can't sell government interior.", thePlayer, 255, 0, 0)
		elseif interiorType ~= 3 and commandName == "unrent" then
			outputChatBox("You are not renting this interior.", thePlayer, 255, 0, 0)
		else
			local interiorStatus = getElementData(interiorElement, "status")
			if interiorStatus[INTERIOR_OWNER] == getElementData(thePlayer, "dbid") or ( getElementData(thePlayer, "factionleader") > 0 and interiorStatus[INTERIOR_FACTION] == getElementData(thePlayer, "faction")) then
				local interiorToken = mysql:query_fetch_assoc("SELECT `token` FROM `interiors` WHERE `owner`='"..getElementData(thePlayer, "dbid").."'")
				if interiorToken == 0 then
					publicSellProperty(thePlayer, dbid, true, true, false)
					cleanupProperty(dbid, true)
					exports.logs:dbLog(thePlayer, 37, { "in"..tostring(dbid) } , "SELLPROPERTY "..dbid)
					local addLog = mysql:query_free("INSERT INTO `interior_logs` (`intID`, `action`, `actor`) VALUES ('"..tostring(dbid).."', '"..commandName.."', '"..getElementData(thePlayer, "account:id").."')") or false
					if not addLog then
						outputDebugString("Failed to add interior logs.")
					end
				else
					outputChatBox("You can't sell interior, because this interior bought by token!", thePlayer, 255, 0, 0)
				end
			else
				outputChatBox("You are not interior owner.", thePlayer, 255, 0, 0)
			end
		end
	else 
		outputChatBox("You are not in interior.", thePlayer, 255, 0, 0)
	end
end
addCommandHandler("sellproperty", sellProperty, false, false)
addCommandHandler("unrent", sellProperty, false, false)

 

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