Jump to content

[AJUDA] SISTEMA CASAS


Recommended Posts

Olá galera, fiz o download do sistema de casas da versão do @Lord Henry aqui, no entanto to com uma duvida, queria que em vez de aparecer nas informações da casa o nome do dono como login (getAccountName), aparecesse o nickname do jogador (getPlayerName), 

Exemplo: Login da Conta: Teste123, Nick no jogo: Forum123

- Dessa forma, no script atual, aparece:

Proprietário: Teste123

Preço: xxxx

- Preciso que apareça:

Proprietário: Forum123

Preço: xxxx

local sqly = { Query = executeSQLQuery };

addEventHandler( 'onResourceStart', resourceRoot, function()
	sqly.Query( "CREATE TABLE IF NOT EXISTS housevip_data (\
		ID INTEGER, en_X REAL, en_Y REAL, en_Z REAL,\
		en_tX REAL, en_tY REAL, en_tZ REAL,\
		ex_X REAL, ex_Y REAL, ex_Z REAL,\
		ex_tX REAL, ex_tY REAL, ex_tZ REAL,\
		int INTEGER, dim INTEGER, cost INTEGER,\
		owner TEXT, subowner TEXT, user1 TEXT, user2 TEXT,\
		user3 TEXT, rent1 INTEGER, rent2 INTEGER, rent3 INTEGER, tipe TEXT, status TEXT, key TEXT, creator TEXT )"
	);
	for i, v in ipairs( getElementsByType( 'player' ) ) do
		setElementData( v, 'ke_len', tonumber( get( 'keyVipLength' ) ) );
		local acc = getPlayerAccount( v );
		if not isGuestAccount( acc ) then
			setElementData( v, 'HSV_accountName', getAccountName( acc ) );
		end;
		setElementData( v, 'mark_in', nil );
	end;
	local hr = sqly.Query( "SELECT * FROM housevip_data" );
	for i = 1, #hr do
		createHouseVip( false, hr[i].ID, hr[i].owner, hr[i].subowner, hr[i].user1, hr[i].user2, hr[i].user3, hr[i].rent1, hr[i].rent2, hr[i].rent3, hr[i].status, hr[i].en_X, hr[i].en_Y, hr[i].en_Z, hr[i].en_tX, hr[i].en_tY, hr[i].en_tZ, hr[i].ex_X, hr[i].ex_Y, hr[i].ex_Z, hr[i].ex_tX, hr[i].ex_tY, hr[i].ex_tZ, hr[i].int, hr[i].dim, hr[i].cost, hr[i].tipe, hr[i].key, hr[i].creator );
	end;
end );

function resetHomeConfig(theStaff, cmd, theResource)
	if hasObjectPermissionTo (theStaff, "function.setResourceDefaultSetting", false) then
		if theResource == "sistema-home" then
			local metaXML = xmlLoadFile( "meta.xml" )
			local settings = xmlFindChild( metaXML, "settings", 0 )
			local setting01 = xmlFindChild ( settings, "setting", 0 )
			local setting02 = xmlFindChild ( settings, "setting", 1 )
			local setting03 = xmlFindChild ( settings, "setting", 2 )
			local setting04 = xmlFindChild ( settings, "setting", 3 )
			local setting05 = xmlFindChild ( settings, "setting", 4 )

			local valor = xmlNodeGetAttribute ( setting01, "value" )
			valor = string.gsub(valor, "%p", "")
			set ("*playerHomeCounter", tonumber (valor))
			
			local valor = xmlNodeGetAttribute ( setting02, "value" )
			valor = string.gsub(valor, "%p", "")
			set ("*keyVipLength", tonumber (valor))
			
			local valor = xmlNodeGetAttribute ( setting03, "value" )
			set ("*vipACL", valor)
			
			local valor = xmlNodeGetAttribute ( setting04, "value" )
			set ("*premiumACL", valor)
			
			local valor = xmlNodeGetAttribute ( setting05, "value" )
			valor = string.gsub(valor, "%p", "")
			set ("*rentTimer", tonumber (valor))
			
			outputChatBox ("As configurações do resource '"..theResource.."' foram resetadas ao valor padrão.", theStaff)
		elseif not theResource then
			outputChatBox ("Erro de sintaxe: /reset <nome-do-resource>", theStaff)
		end
	else
		outputChatBox ("Você não tem acesso a este comando.", theStaff, 255, 50, 50)
	end
end
addCommandHandler("reset", resetHomeConfig)

addEventHandler( 'onResourceStop', resourceRoot, function()
	for i, v in ipairs( getElementsByType( 'player' ) ) do
		setElementData( v, 'ke_len', nil );
		setElementData( v, 'HSV_accountName', nil );
	end;
end );

addEventHandler( 'onPlayerJoin', root, function()
	setElementData( source, 'ke_len', tonumber( get( 'keyVipLength' ) ) );
end );

addEventHandler( 'onPlayerLogin', root, function( _, acc )
	setElementData( source, 'HSV_accountName', getAccountName( acc ) );
end );

addEventHandler( 'onPlayerLogout', root, function( _, acc )
	setElementData( source, 'HSV_accountName', nil );
end );

testMode = false --Não mexa aqui!
addCommandHandler( 'home', function( theStaff )
	if hasObjectPermissionTo (theStaff, "command.home", false) then --Se o jogador tem essa permissão, faz o seguinte:
		if testMode == true then --Se estiver em modo teste, manda a mensagem abaixo e nada acontece.
			outputChatBox( 'O resource associado com este comando está em modo testes. Portanto, este comando está indisponível.', theStaff, 255, 0, 0 );
		else --Se não estiver em modo teste, faz o seguinte:
			if not getElementData( theStaff, 'HPV_Opened' ) and not getElementData( theStaff, 'mark_in' ) then --Se o painel de criação de casas não estiver aberto, faz o seguinte:
				triggerClientEvent( theStaff, 'HPV_SetVisible', root, true ); --Abre o painel de criação de casas.
			end;
		end
	else --Se o jogador não tem a permissão, manda a mensagem abaixo e nada acontece.
		outputChatBox( 'Você não possui permissão para usar este comando.', theStaff, 255, 0, 0 );
	end
end);
--Por padrão, coloquei a permissão na ACL Group 'autogroup_sistema-home', basta adicionar seu 'user.login' lá para obter acesso.
--Ao instalar este resource pela primeira vez, ele vai solicitar permissão aos comandos descritos no meta.xml, autorize todos eles com o comando /aclrequest allow sistema-home all
--Tenha certeza de que existam os ACL Groups que estão configurados nos settings deste resource. Você pode alterá-los, caso necessário. Por padrão é 'Vip' e 'Premium'.
--É necessário reiniciar este resource depois de alterar alguma configuração dele.


addEvent( 'onPlayerAttemptCreateHouseVip', true );
addEventHandler( 'onPlayerAttemptCreateHouseVip', root, function( rt )
	createHouseVip( true, #sqly.Query( "SELECT * FROM housevip_data" ) + 1, '', '', '', '', '', '', '', '', 'closed', rt[1], rt[2], rt[3], rt[4], rt[5], rt[6], rt[7], rt[8], rt[9], rt[10], rt[11], rt[12], rt[13], rt[14], rt[15], rt[16], '', rt[17]);
end );

function createHouseVip( add, ID, owner, subowner, user1, user2, user3, rent1, rent2, rent3, status, eX, eY, eZ, etX, etY, etZ, exX, exY, exZ, extX, extY, extZ, int, dim, cost, tipe, key, creator )
	if add then
		sqly.Query("INSERT INTO housevip_data (ID, en_X, en_Y, en_Z, en_tX, en_tY, en_tZ, ex_X, ex_Y, ex_Z, ex_tX, ex_tY, ex_tZ, int, dim, cost, owner, subowner, user1, user2, user3, rent1, rent2, rent3, tipe, status, key, creator) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", ID, eX, eY, eZ, etX, etY, etZ, exX, exY, exZ, extX, extY, extZ, int, dim, cost, "", "", "", "", "", "", "", "", tipe, status, "", creator);
		-- outputChatBox (tostring(add), client) --Use para testes, para verificar se os valores passados estão corretos.
		-- outputChatBox ("ID: "..tostring(ID), client)
		-- outputChatBox ("Owner: "..tostring(owner), client)
		-- outputChatBox ("SubOwner: "..tostring(subowner), client)
		-- outputChatBox ("User1: "..tostring(user1), client)
		-- outputChatBox ("User2: "..tostring(user2), client)
		-- outputChatBox ("User3: "..tostring(user3), client)
		-- outputChatBox ("Rent1: "..tostring(rent1), client)
		-- outputChatBox ("Rent2: "..tostring(rent2), client)
		-- outputChatBox ("Rent3: "..tostring(rent3), client)
		-- outputChatBox ("Status: "..tostring(status), client)
		-- outputChatBox ("eX: "..tostring(eX), client)
		-- outputChatBox ("eY: "..tostring(eY), client)
		-- outputChatBox ("eZ: "..tostring(eZ), client)
		-- outputChatBox ("etX: "..tostring(etX), client)
		-- outputChatBox ("etY: "..tostring(etY), client)
		-- outputChatBox ("etZ: "..tostring(etZ), client)
		-- outputChatBox ("exX: "..tostring(exX), client)
		-- outputChatBox ("exY: "..tostring(exY), client)
		-- outputChatBox ("exZ: "..tostring(exZ), client)
		-- outputChatBox ("extX: "..tostring(extX), client)
		-- outputChatBox ("extY: "..tostring(extY), client)
		-- outputChatBox ("extZ: "..tostring(extZ), client)
		-- outputChatBox ("int: "..tostring(int), client)
		-- outputChatBox ("dim: "..tostring(dim), client)
		-- outputChatBox ("cost: "..tostring(cost), client)
		-- outputChatBox ("tipe: "..tostring(tipe), client)
		-- outputChatBox ("key: "..tostring(key), client)
		-- outputChatBox ("creator: "..tostring(creator), client)
		outputChatBox( 'A casa #'..ID..' foi criada com sucesso!', client, 255, 255, 0 );
	end;
	local m_Enter = createMarker( eX, eY, eZ - 1, 'cylinder', 1.25, 255, 255, 0, 150 ); --Cria amarelo, o original é (0, 153, 255, 150)
	setElementData( m_Enter, 'HSV_INFO', { etX, etY, etZ, int, dim, cost, owner, subowner, ID, user1, user2, user3, rent1, rent2, rent3, status, tipe, key, creator } );
	-- 'HSV_INFO' [1] = etX
	-- 'HSV_INFO' [2] = etY
	-- 'HSV_INFO' [3] = etZ
	-- 'HSV_INFO' [4] = int
	-- 'HSV_INFO' [5] = dim
	-- 'HSV_INFO' [6] = cost
	-- 'HSV_INFO' [7] = owner
	-- 'HSV_INFO' [8] = subowner (antes era key)
	-- 'HSV_INFO' [9] = ID
	-- 'HSV_INFO'[10] = user1
	-- 'HSV_INFO'[11] = user2
	-- 'HSV_INFO'[12] = user3
	-- 'HSV_INFO'[13] = rent1
	-- 'HSV_INFO'[14] = rent2
	-- 'HSV_INFO'[15] = rent3
	-- 'HSV_INFO'[16] = status
	-- 'HSV_INFO'[17] = tipe (era pra ser type, mas essa palavra é reservada na programação)
	-- 'HSV_INFO'[18] = key
	-- 'HSV_INFO'[19] = creator
	
	if getElementData( m_Enter, 'HSV_INFO' )[7] ~= '' then --Se a casa tem dono (dono é diferente de vazio), independente do tipo então:
		setMarkerColor( m_Enter, 255, 51, 36, 150 ); --Muda o marker para vermelho.
	elseif getElementData( m_Enter, 'HSV_INFO' )[7] == '' and getElementData( m_Enter, 'HSV_INFO' )[17] == 'Free' then --Se a casa não tem dono e o tipo dela é 'Free', então:
		setMarkerColor( m_Enter, 0, 153, 255, 150 ); --Muda o marker para azul ciano.
	elseif getElementData( m_Enter, 'HSV_INFO' )[7] == '' and getElementData( m_Enter, 'HSV_INFO' )[17] == 'Reserved' then --Se a casa não tem dono e o tipo dela for 'Reserved', então:
		setMarkerColor( m_Enter, 255, 255, 255, 150 ); --Muda o marker para Branco.
	end; --Se a casa não tem dono e o tipo dela for VIP, continua amarelo.
	
	addEventHandler( 'onMarkerHit', m_Enter, function( player, dim )
		if getElementType( player ) == 'player' and not getPedOccupiedVehicle( player ) and dim then
			if not getElementData( player, 'HPV_Opened' ) then
				if not isGuestAccount( getPlayerAccount( player ) ) then
					setElementData( player, 'mark_in', getElementData( source, 'HSV_INFO' )[9] );
					onPlayerHouseMarkerHit( player, source, true );
					setElementFrozen( player, true );
				else
					outputChatBox( 'Você precisa estar logado para abrir o painel desta casa!', player, 255, 51, 36 );
				end;
			end;
		end;
	end);
	
	addEventHandler( 'onMarkerLeave', m_Enter, function( player )
		if getElementType( player ) == 'player' and not getPedOccupiedVehicle( player ) then
			setElementData( player, 'mark_in', nil );
		end;
	end );
	
	local m_Exit = createMarker( exX, exY, exZ - 1, 'cylinder', 1.25, 0, 153, 255, 150 );
	setElementData( m_Exit, 'parent', m_Enter );
	setElementInterior( m_Exit, int );
	setElementDimension( m_Exit, dim );
	
	setElementData( m_Exit, 'extX', extX );
	setElementData( m_Exit, 'extY', extY );
	setElementData( m_Exit, 'extZ', extZ );
	
	addEventHandler( 'onMarkerHit', m_Exit, function( player, dim )
		if getElementType( player ) == 'player' and dim then
			toggleAllControls( player, false );
			fadeCamera( player, false );
			setTimer( function( player, mark )
				if getPedOccupiedVehicle( player ) then removePedFromVehicle( player ); end;
				local x, y, z = getElementData( mark, 'extX' ), getElementData( mark, 'extY' ), getElementData( mark, 'extZ' );
				setElementPosition( player, x, y, z );
				setElementInterior( player, 0 );
				setElementDimension( player, 0 );
				toggleAllControls( player, true );
				fadeCamera( player, true );
			end, 1200, 1, player, source );
		end;
	end );
end;

function onPlayerHouseMarkerHit( player, mark, cursor )
	local acc = getPlayerAccount( player );
	local housetype = getElementData( mark, 'HSV_INFO' )[17];
	if isGuestAccount( acc ) then
		outputChatBox( 'Você precisa estar logado para abrir o painel desta casa!', player, 255, 51, 36 );
		setElementData( player, 'mark_in', nil );
		setElementFrozen( player, false );
		return false;
	end;
	local tts = { [1] = false, [2] = false, [3] = false, [4] = false, [5] = false, [6] = false, [7] = false };
	local owner = getElementData( mark, 'HSV_INFO' )[7];
	local subowner = getElementData( mark, 'HSV_INFO' )[8];
	local resident1 = getElementData( mark, 'HSV_INFO' )[10];
	local resident2 = getElementData( mark, 'HSV_INFO' )[11];
	local resident3 = getElementData( mark, 'HSV_INFO' )[12];
	local accName = getAccountName( acc );
	local status = getElementData( mark, 'HSV_INFO' )[16];
	if housetype == 'Free' then
		if owner == '' then--If the house has not an owner. (owner is empty)
			tts[1] = true;--The player can buy the house.
			if hasObjectPermissionTo( player, 'command.ban', false ) then--If the players is a SuperModerator or above.
				tts[4] = true;--Can Enter the house.
			end;
		elseif owner ~= '' then --If the house have an owner.
			if subowner == accName then--If the player is the sub owner, he can't buy the house because it already has an owner, he can do everything except delete the house, sell the house and change ownership.
				tts[1] = false; --1=Buy
				tts[2] = true;	--2=Sell/Leave
				tts[3] = true;	--3=Change Status
				tts[4] = true;	--4=Enter House
				tts[5] = false;	--5=Give Ownership to sub owner.
				tts[6] = true;	--6=Add Resident or sub owner.
			elseif owner == accName then--If the player is the owner, he can't buy the house because it already has an owner, he can do everything except delete the house.
				tts[1] = false; --1=Buy
				tts[2] = true;	--2=Sell/Leave
				tts[3] = true;	--3=Change Status
				tts[4] = true;	--4=Enter House
				tts[5] = true;	--5=Give Ownership to sub owner.
				tts[6] = true;	--6=Add Resident or sub owner.
			elseif resident1 == accName or resident2 == accName or resident3 == accName then --If the player is one of the residents, he can enter the house.
				tts[1] = false; --1=Buy
				tts[2] = true;	--2=Sell/Leave
				tts[3] = false;	--3=Change Status
				tts[4] = true;	--4=Enter House
				tts[5] = false;	--5=Give Ownership to sub owner.
				tts[6] = false;	--6=Add Resident or sub owner.
			elseif status == 'opened' then
				tts[1] = false; --1=Buy
				tts[2] = false;	--2=Sell/Leave
				tts[3] = false;	--3=Change Status
				tts[4] = true;	--4=Enter House
				tts[5] = false;	--5=Give Ownership to sub owner.
				tts[6] = false;	--6=Add Resident or sub owner.
			end
			if accName == "guest" then --If the player is logged with an account named 'guest' then he can do nothing. (this is different from not logged)
				tts[1] = false;
				tts[2] = false;
				tts[3] = false;
				tts[4] = false;
				tts[5] = false;
				tts[6] = false;
				outputChatBox ("Sua conta 'guest' é ilegal, você não pode usar o painel de casas.", player, 255, 51, 36 ); --Tell him that the account 'guest' is ilegal.
			end;
		end;
		if hasObjectPermissionTo( player, 'command.delete', false ) then --If he is Admin or above, he can delete the house.
			tts[7] = true;	--7=Delete house
		end;
	elseif housetype == 'VIP' then
		if owner == '' then
			if isObjectInACLGroup( 'user.'..getAccountName( acc ), aclGetGroup(get('vipACL')) ) then--If the player is VIP.
				tts[1] = true;--Can buy the house.
			end
			if hasObjectPermissionTo( player, 'command.ban', false ) then
				tts[4] = true;--Can Enter the house.
			end;
		elseif owner ~= '' then --If the house have an owner.
			if subowner == accName then--If the player is the sub owner, he can't buy the house because it already has an owner, he can do everything except delete the house, sell the house and change ownership.
				tts[1] = false; --1=Buy
				tts[2] = true;	--2=Sell/Leave
				tts[3] = true;	--3=Change Status
				tts[4] = true;	--4=Enter House
				tts[5] = false;	--5=Give Ownership to sub owner.
				tts[6] = true;	--6=Add Resident or sub owner.
			elseif owner == accName then--If the player is the owner, he can't buy the house because it already has an owner, he can do everything except delete the house.
				tts[1] = false; --1=Buy
				tts[2] = true;	--2=Sell/Leave
				tts[3] = true;	--3=Change Status
				tts[4] = true;	--4=Enter House
				tts[5] = true;	--5=Give Ownership to sub owner.
				tts[6] = true;	--6=Add Resident or sub owner.
			elseif resident1 == accName or resident2 == accName or resident3 == accName then --If the player is one of the residents, he can enter the house.
				tts[1] = false; --1=Buy
				tts[2] = true;	--2=Sell/Leave
				tts[3] = false;	--3=Change Status
				tts[4] = true;	--4=Enter House
				tts[5] = false;	--5=Give Ownership to sub owner.
				tts[6] = false;	--6=Add Resident or sub owner.
			elseif status == 'opened' then
				tts[1] = false; --1=Buy
				tts[2] = false;	--2=Sell/Leave
				tts[3] = false;	--3=Change Status
				tts[4] = true;	--4=Enter House
				tts[5] = false;	--5=Give Ownership to sub owner.
				tts[6] = false;	--6=Add Resident or sub owner.
			end
			if accName == "guest" then --If the player is logged with an account named 'guest' then he can do nothing. (this is different from not logged)
				tts[1] = false;
				tts[2] = false;
				tts[3] = false;
				tts[4] = false;
				tts[5] = false;
				tts[6] = false;
				outputChatBox ("Sua conta 'guest' é ilegal, você não pode usar o painel de casas.", player, 255, 51, 36 ); --Tell him that the account 'guest' is ilegal.
			end;
		end;
		if hasObjectPermissionTo( player, 'command.delete', false ) then --If he is Admin or above, he can delete the house.
			tts[7] = true;	--7=Delete house
		end;
		if isObjectInACLGroup ('user.'..getAccountName (acc), aclGetGroup ('Console')) or isObjectInACLGroup ('user.'..getAccountName (acc), aclGetGroup ('Sub-Dono')) then--If the player is Console, he can Delete the house.
			tts[7] = true;	--7=Delete house
		end;
	elseif housetype == 'Reserved' then
		if owner == '' then
			if isObjectInACLGroup( 'user.'..getAccountName( acc ), aclGetGroup(get('premiumACL')) ) then--If the player is Premium. (the player needs to be added here temporaly, after he buys the house, he needs to be removed from this ACL or he will have permission to buy all the Reserved houses.)
				tts[1] = true;--Can buy the house.
			end
			if hasObjectPermissionTo( player, 'command.ban', false ) then
				tts[4] = true;--Can Enter the house.
			end;
		elseif owner ~= '' then --If the house have an owner.
			if subowner == accName then--If the player is the sub owner, he can't buy the house because it already has an owner, he can do everything except delete the house, sell the house and change ownership.
				tts[1] = false; --1=Buy
				tts[2] = true;	--2=Sell/Leave
				tts[3] = true;	--3=Change Status
				tts[4] = true;	--4=Enter House
				tts[5] = false;	--5=Give Ownership to sub owner.
				tts[6] = true;	--6=Add Resident or sub owner.
			elseif owner == accName then--If the player is the owner, he can't buy the house because it already has an owner, he can do everything except delete the house.
				tts[1] = false; --1=Buy
				tts[2] = true;	--2=Sell/Leave
				tts[3] = true;	--3=Change Status
				tts[4] = true;	--4=Enter House
				tts[5] = true;	--5=Give Ownership to sub owner.
				tts[6] = true;	--6=Add Resident or sub owner.
			elseif resident1 == accName or resident2 == accName or resident3 == accName then --If the player is one of the residents, he can enter the house.
				tts[1] = false; --1=Buy
				tts[2] = true;	--2=Sell/Leave
				tts[3] = false;	--3=Change Status
				tts[4] = true;	--4=Enter House
				tts[5] = false;	--5=Give Ownership to sub owner.
				tts[6] = false;	--6=Add Resident or sub owner.
			elseif status == 'opened' then
				tts[1] = false; --1=Buy
				tts[2] = false;	--2=Sell/Leave
				tts[3] = false;	--3=Change Status
				tts[4] = true;	--4=Enter House
				tts[5] = false;	--5=Give Ownership to sub owner.
				tts[6] = false;	--6=Add Resident or sub owner.
			end
			if accName == "guest" then --If the player is logged with an account named 'guest' then he can do nothing. (this is different from not logged)
				tts[1] = false;
				tts[2] = false;
				tts[3] = false;
				tts[4] = false;
				tts[5] = false;
				tts[6] = false;
				outputChatBox ("Sua conta 'guest' é ilegal, você não pode usar o painel de casas.", player, 255, 51, 36 ); --Tell him that the account 'guest' is ilegal.
			end;
		end;
		if isObjectInACLGroup ('user.'..getAccountName (acc), aclGetGroup ('Console')) or isObjectInACLGroup ('user.'..getAccountName (acc), aclGetGroup ('Sub-Dono')) then--If the player is Console, he can Delete the house.
			tts[7] = true;	--7=Delete house
		end;
	end
	tts[8] = getElementData( mark, 'HSV_INFO' )[9]; -- ID
	tts[9] = getElementData( mark, 'HSV_INFO' )[7]; -- Owner
	tts[10] = getElementData( mark, 'HSV_INFO' )[6]; -- Cost
	tts[11] = getElementData( mark, 'HSV_INFO' )[8]; -- Sub Owner
	tts[12] = getElementData( mark, 'HSV_INFO' )[10]; -- Resident 1
	tts[13] = getElementData( mark, 'HSV_INFO' )[11]; -- Resident 2
	tts[14] = getElementData( mark, 'HSV_INFO' )[12]; -- Resident 3
	tts[15] = getElementData( mark, 'HSV_INFO' )[13]; -- Rent 1
	tts[16] = getElementData( mark, 'HSV_INFO' )[14]; -- Rent 2
	tts[17] = getElementData( mark, 'HSV_INFO' )[15]; -- Rent 3
	tts[18] = status;
	tts[19] = housetype;
	if isObjectInACLGroup ('user.'..getAccountName (acc), aclGetGroup ('Admin')) or hasObjectPermissionTo( player, 'command.delete', false ) then --If the player is Admin or above, he can see the hidden infos.
		tts[20] = true;	--20=Hidden infos button.
	else
		tts[20] = false;
	end;
	tts[21] = getElementData( mark, 'HSV_INFO' )[19]; -- House Creator
	setTimer(triggerClientEvent, 500, 1, player, 'openHouseManagementWndVip', root, tts, cursor );
end;

addEvent( 'HOUSEVIP_Buy', true );
addEventHandler( 'HOUSEVIP_Buy', root, function( cost )
	local accName = getAccountName( getPlayerAccount( client ) );
	local houseCounter = 0;
	for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
		if getElementData( v, 'HSV_INFO' ) then
			local owner = getElementData( v, 'HSV_INFO' )[7];
			local subowner = getElementData( v, 'HSV_INFO' )[8];
			local resident1 = getElementData( v, 'HSV_INFO' )[10];
			local resident2 = getElementData( v, 'HSV_INFO' )[11];
			local resident3 = getElementData( v, 'HSV_INFO' )[12];
			if owner == accName or subowner == accName or resident1 == accName or resident2 == accName or resident3 == accName then
				houseCounter = houseCounter + 1;
			end;
		end;
	end;
	if houseCounter >= tonumber( get( 'playerHomeCounter' ) ) then
		outputChatBox( 'Você não pode ter mais do que #00FF00'..get( 'playerHomeCounter' )..' casas#FF3324 ao mesmo tempo!', client, 255, 51, 36, true );
		setElementFrozen( client, false );
		return false;
	end;
	if getPlayerMoney( client ) >= tonumber( cost ) then
		outputChatBox( 'Parabéns! Você comprou uma casa!', client, 255, 255, 0 );
		sqly.Query( "UPDATE housevip_data SET owner = '"..accName.."' WHERE ID = ?", getElementData( client, 'mark_in' ) );
		takePlayerMoney( client, cost );
		local mark = getHouseByID( getElementData( client, 'mark_in' ) );
		local t = {};
		for i = 1, 19 do
			t[i] = getElementData( mark, 'HSV_INFO' )[i];
		end;
		t[7] = accName;
		if getElementData( mark, 'HSV_INFO' )[17] == 'Reserved' then
			aclGroupRemoveObject (aclGetGroup(get('premiumACL')), "user."..accName)
			outputChatBox( 'Você gastou sua permissão de comprar casas reservadas.', client);
		end
		setElementData( mark, 'HSV_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15], t[16], t[17], t[18], t[19] } );
		setMarkerColor( mark, 255, 51, 36, 150 ); -- Red Color
		setTimer( onPlayerHouseMarkerHit, 500, 1, client, mark, true );
	else
		outputChatBox( 'Você não tem dinheiro suficiente!', client, 255, 51, 36 );
		onPlayerHouseMarkerHit( client, getHouseByID( getElementData( client, 'mark_in' ) ), true );
	end;
end );

addEvent( 'HOUSEVIP_Sell', true );
addEventHandler( 'HOUSEVIP_Sell', root, function()
	sqly.Query( "UPDATE housevip_data SET owner=?, subowner=?, user1=?, user2=?, user3=?, rent1=?, rent2=?, rent3=?, status=? WHERE ID = ?", "", "", "", "", "", "", "", "", "closed", getElementData( client, 'mark_in' ) );
	local mark = getHouseByID( getElementData( client, 'mark_in' ) );
	givePlayerMoney( client, getElementData( mark, 'HSV_INFO' )[6] / 2 ); --Returns half of the house value to the player.
	local t = {};
	for i = 1, 6 do
		t[i] = getElementData( mark, 'HSV_INFO' )[i];
	end;
	t[7] = ''; --Owner
	t[8] = ''; --Sub owner
	t[9] = getElementData( client, 'mark_in' ); --ID
	for i = 10, 15 do
		t[i] = '';
	end;
	t[16] = 'closed'
	t[17] = getElementData( mark, 'HSV_INFO' )[17];
	t[18] = '';
	t[19] = getElementData( mark, 'HSV_INFO' )[19];
	
	setElementData( mark, 'HSV_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15], t[16], t[17], t[18], t[19] } );
	if getElementData( mark, 'HSV_INFO' )[17] == 'Free' then
		setMarkerColor( mark, 0, 153, 255, 150 ); --Cyan Blue color
	elseif getElementData( mark, 'HSV_INFO' )[17] == 'VIP' then
		setMarkerColor( mark, 255, 255, 0, 150 ); --Yellow color
	elseif getElementData( mark, 'HSV_INFO' )[17] == 'Reserved' then
		setMarkerColor( mark, 255, 255, 255, 150 ); --White color
	else
		setMarkerColor( mark, 0, 0, 0, 150 ); --Black color, this indicates that an error happened.
		outputChatBox ("Tipo: "..tostring(getElementData( mark, 'HSV_INFO' )[17]))
	end
	setTimer( onPlayerHouseMarkerHit, 500, 1, client, mark, false );
end);

addEvent( 'HOUSEVIP_Leave', true );
addEventHandler( 'HOUSEVIP_Leave', root, function(user)
	local mark = getHouseByID( getElementData( client, 'mark_in' ) );
	local t = {};
	for i = 1, 19 do
		t[i] = getElementData( mark, 'HSV_INFO' )[i];
	end;
	
	if user == 0 then
		sqly.Query( "UPDATE housevip_data SET subowner=? WHERE ID = ?", "", getElementData( client, 'mark_in' ) );
		t[8] = ''; --Sub owner
	elseif user == 1 then
		sqly.Query( "UPDATE housevip_data SET user1=?, rent1=? WHERE ID = ?", "", "", getElementData( client, 'mark_in' ) );
		t[10] = ''; --User1
		t[13] = ''; --Rent1
	elseif user == 2 then
		sqly.Query( "UPDATE housevip_data SET user2=?, rent2=? WHERE ID = ?", "", "", getElementData( client, 'mark_in' ) );
		t[11] = ''; --User2
		t[14] = ''; --Rent2
	elseif user == 3 then
		sqly.Query( "UPDATE housevip_data SET user3=?, rent3=? WHERE ID = ?", "", "", getElementData( client, 'mark_in' ) );
		t[12] = ''; --User3
		t[15] = ''; --Rent3
	end
	
	setElementData( mark, 'HSV_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15], t[16], t[17], t[18], t[19] } );
	
	setTimer( onPlayerHouseMarkerHit, 500, 1, client, mark, false );
end);

addEvent( 'HOUSEVIP_Enter', true );
addEventHandler( 'HOUSEVIP_Enter', root, function()
	setElementFrozen( client, false );
	local mark = getHouseByID( getElementData( client, 'mark_in' ) );
	local t = {};
	for i = 1, 5 do
		t[i] = getElementData( mark, 'HSV_INFO' )[i];
	end;
	fadeCamera( client, false );
	toggleAllControls( client, false );
	setTimer( function( player, t )
		if getPedOccupiedVehicle( player ) then removePedFromVehicle( player ); end;
		setElementInterior( player, t[4], t[1], t[2], t[3] );
		setElementDimension( player, t[5] );
		toggleAllControls( player, true );
		fadeCamera( player, true );
		setElementData( player, 'mark_in', nil )
	end, 1200, 1, client, t );
end );

addEvent( 'HOUSEVIP_ChangeKey', true );
addEventHandler( 'HOUSEVIP_ChangeKey', root, function(opened, key)
	local mark = getHouseByID( getElementData( client, 'mark_in' ) );
	local t = {};
	for i = 1, 19 do
		t[i] = getElementData( mark, 'HSV_INFO' )[i];
	end;
	-- t[9] = getElementData( client, 'mark_in' ); --ID
	
	if opened == true then
		t[16] = "opened";
	else
		t[16] = "closed";
	end
	sqly.Query( "UPDATE housevip_data SET status = '"..t[16].."' WHERE ID = ?", getElementData( client, 'mark_in' ) );
	
	if key ~= '' then
		t[18] = key;
	else
		t[18] = "";
	end
	sqly.Query( "UPDATE housevip_data SET key = '"..t[18].."' WHERE ID = ?", getElementData( client, 'mark_in' ) );

	setElementData( mark, 'HSV_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15], t[16], t[17], t[18], t[19] } );
end );

addEvent( 'HOUSEVIP_ChangeOwner', true );
addEventHandler( 'HOUSEVIP_ChangeOwner', root, function( name )
	local mark = getHouseByID( getElementData( client, 'mark_in' ) );
	local subowner = getAccountName( getPlayerAccount(client) );
	sqly.Query( "UPDATE housevip_data SET owner = '"..name.."' WHERE ID = ?", getElementData( client, 'mark_in' ) );
	sqly.Query( "UPDATE housevip_data SET subowner = '"..subowner.."' WHERE ID = ?", getElementData( client, 'mark_in' ) );
	
	local t = {};
	for i = 1, 19 do
		t[i] = getElementData( mark, 'HSV_INFO' )[i];
	end;
	t[7] = name
	t[8] = subowner
	t[9] = getElementData( client, 'mark_in' );
	setElementData( mark, 'HSV_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15], t[16], t[17], t[18], t[19] } );
	setTimer( onPlayerHouseMarkerHit, 500, 1, client, mark, false );
	if isElement (getPlayerByAccountName( name )) then
		outputChatBox( '#FFFF00'..getPlayerName( client )..'#00FF00 transferiu a escritura da casa para você!', getPlayerByAccountName( name ), 0, 255, 0, true );
	end
end );

addEvent( 'HOUSEVIP_AddResidents', true );
addEventHandler( 'HOUSEVIP_AddResidents', root, function( subowner, user1, user2, user3, newRent1, newRent2, newRent3 )
	local mark = getHouseByID( getElementData( client, 'mark_in' ) );
	if subowner ~= false then
		local houseCounter0 = 0;
		for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
			if getElementData( v, 'HSV_INFO' ) then
				local owner = getElementData( v, 'HSV_INFO' )[7];
				local subOwn = getElementData( v, 'HSV_INFO' )[8];
				local resident1 = getElementData( v, 'HSV_INFO' )[10];
				local resident2 = getElementData( v, 'HSV_INFO' )[11];
				local resident3 = getElementData( v, 'HSV_INFO' )[12];
				if owner == subowner or subOwn == subowner or resident1 == subowner or resident2 == subowner or resident3 == subowner then
					houseCounter0 = houseCounter0 + 1;
				end;
			end;
		end;
		if houseCounter0 >= tonumber( get( 'playerHomeCounter' ) ) and subowner ~= getElementData( mark, 'HSV_INFO' )[8] then
			outputChatBox( 'O jogador cujo login informado em Sub-Dono já atingiu o limite de #00FF00'..get( 'playerHomeCounter' )..' casas#FF3324 ao mesmo tempo!', client, 255, 51, 36, true );
			subowner = false
		end;
	end;
	if user1 ~= false then
		local houseCounter1 = 0;
		for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
			if getElementData( v, 'HSV_INFO' ) then
				local owner = getElementData( v, 'HSV_INFO' )[7];
				local subowner = getElementData( v, 'HSV_INFO' )[8];
				local resident1 = getElementData( v, 'HSV_INFO' )[10];
				local resident2 = getElementData( v, 'HSV_INFO' )[11];
				local resident3 = getElementData( v, 'HSV_INFO' )[12];
				if owner == user1 or subowner == user1 or resident1 == user1 or resident2 == user1 or resident3 == user1 then
					houseCounter1 = houseCounter1 + 1;
				end;
			end;
		end;
		if houseCounter1 >= tonumber( get( 'playerHomeCounter' ) ) and user1 ~= getElementData( mark, 'HSV_INFO' )[10] then
			outputChatBox( 'O jogador cujo login informado em Morador 1 já atingiu o limite de #00FF00'..get( 'playerHomeCounter' )..' casas#FF3324 ao mesmo tempo!', client, 255, 51, 36, true );
			user1 = false
			newRent1 = false
		end;
	end;
	if user2 ~= false then
		local houseCounter2 = 0;
		for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
			if getElementData( v, 'HSV_INFO' ) then
				local owner = getElementData( v, 'HSV_INFO' )[7];
				local subowner = getElementData( v, 'HSV_INFO' )[8];
				local resident1 = getElementData( v, 'HSV_INFO' )[10];
				local resident2 = getElementData( v, 'HSV_INFO' )[11];
				local resident3 = getElementData( v, 'HSV_INFO' )[12];
				if owner == user2 or subowner == user2 or resident1 == user2 or resident2 == user2 or resident3 == user2 then
					houseCounter2 = houseCounter2 + 1;
				end;
			end;
		end;
		if houseCounter2 >= tonumber( get( 'playerHomeCounter' ) ) and user2 ~= getElementData( mark, 'HSV_INFO' )[11] then
			outputChatBox( 'O jogador cujo login informado em Morador 2 já atingiu o limite de #00FF00'..get( 'playerHomeCounter' )..' casas#FF3324 ao mesmo tempo!', client, 255, 51, 36, true );
			user2 = false
			newRent2 = false
		end;
	end;
	if user3 ~= false then
		local houseCounter3 = 0;
		for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
			if getElementData( v, 'HSV_INFO' ) then
				local owner = getElementData( v, 'HSV_INFO' )[7];
				local subowner = getElementData( v, 'HSV_INFO' )[8];
				local resident1 = getElementData( v, 'HSV_INFO' )[10];
				local resident2 = getElementData( v, 'HSV_INFO' )[11];
				local resident3 = getElementData( v, 'HSV_INFO' )[12];
				if owner == user3 or subowner == user3 or resident1 == user3 or resident2 == user3 or resident3 == user3 then
					houseCounter3 = houseCounter3 + 1;
				end;
			end;
		end;
		if houseCounter3 >= tonumber( get( 'playerHomeCounter' ) ) and user3 ~= getElementData( mark, 'HSV_INFO' )[12] then		
			outputChatBox( 'O jogador cujo login informado em Morador 3 já atingiu o limite de #00FF00'..get( 'playerHomeCounter' )..' casas#FF3324 ao mesmo tempo!', client, 255, 51, 36, true );
			user3 = false
			newRent3 = false
		end;
	end;
	
	local t = {};
	for i = 1, 9 do
		t[i] = getElementData( mark, 'HSV_INFO' )[i];
	end;
	
	if subowner == 'guest' or subowner == false then -- If the login informed is empty or the player is logged out.
		t[8] = '';
		sqly.Query( "UPDATE housevip_data SET subowner = ? WHERE ID = ?", "", getElementData( client, 'mark_in' ) );
	else
		sqly.Query( "UPDATE housevip_data SET subowner = '"..subowner.."' WHERE ID = ?", getElementData( client, 'mark_in' ) );
		t[8] = subowner
	end
	if user1 == 'guest' or user1 == false then
		t[10] = ''
		sqly.Query( "UPDATE housevip_data SET user1 = ? WHERE ID = ?", "", getElementData( client, 'mark_in' ) );
		newRent1 = false
	else
		sqly.Query( "UPDATE housevip_data SET user1 = '"..user1.."' WHERE ID = ?", getElementData( client, 'mark_in' ) );
		t[10] = user1
	end
	if newRent1 == false then
		t[13] = '';
		sqly.Query( "UPDATE housevip_data SET rent1 = ? WHERE ID = ?", "", getElementData( client, 'mark_in' ) );
	else
		sqly.Query( "UPDATE housevip_data SET rent1 = '"..newRent1.."' WHERE ID = ?", getElementData( client, 'mark_in' ) );
		t[13] = newRent1
	end
	if user2 == 'guest' or user2 == false then
		t[11] = ''
		sqly.Query( "UPDATE housevip_data SET user2 = ? WHERE ID = ?", "", getElementData( client, 'mark_in' ) );
		newRent2 = false
	else
		sqly.Query( "UPDATE housevip_data SET user2 = '"..user2.."' WHERE ID = ?", getElementData( client, 'mark_in' ) );
		t[11] = user2
	end
	if newRent2 == false then
		t[14] = '';
		sqly.Query( "UPDATE housevip_data SET rent2 = ? WHERE ID = ?", "", getElementData( client, 'mark_in' ) );
	else
		sqly.Query( "UPDATE housevip_data SET rent2 = '"..newRent2.."' WHERE ID = ?", getElementData( client, 'mark_in' ) );
		t[14] = newRent2
	end
	if user3 == 'guest' or user3 == false then
		t[12] = ''
		sqly.Query( "UPDATE housevip_data SET user3 = ? WHERE ID = ?", "", getElementData( client, 'mark_in' ) );
		newRent3 = false
	else
		sqly.Query( "UPDATE housevip_data SET user3 = '"..user3.."' WHERE ID = ?", getElementData( client, 'mark_in' ) );
		t[12] = user3
	end
	if newRent3 == false then
		t[15] = '';
		sqly.Query( "UPDATE housevip_data SET rent3 = ? WHERE ID = ?", "", getElementData( client, 'mark_in' ) );
	else
		sqly.Query( "UPDATE housevip_data SET rent3 = '"..newRent3.."' WHERE ID = ?", getElementData( client, 'mark_in' ) );
		t[15] = newRent3
	end
	
	for i = 16, 19 do
		t[i] = getElementData( mark, 'HSV_INFO' )[i];
	end;
	
	setElementData( mark, 'HSV_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15], t[16], t[17], t[18], t[19] } );
end );

addEvent( 'HOUSEVIP_Destroy', true );
addEventHandler( 'HOUSEVIP_Destroy', root, function()
	local mark = getHouseByID( getElementData( client, 'mark_in' ) );
	if getElementData (mark, 'HSV_INFO' )[19] ~= "Console" then
		for ii, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
			if getElementData( v, 'parent' ) == mark then
				destroyElement( v );
			end;
		end;
		local hr = sqly.Query( "SELECT * FROM housevip_data" );
		for i = getElementData( source, 'mark_in' ), #hr do
			if getHouseByID( i ) ~= mark then
				sqly.Query( "UPDATE housevip_data SET ID = "..( i - 1 ).." WHERE ID = ?", i );
				local res = sqly.Query( "SELECT owner, key FROM housevip_data WHERE ID = ?", i - 1 );
				local nextmark = getHouseByID( i );
				local t = {};
				for i = 1, 6 do
					t[i] = getElementData( nextmark, 'HSV_INFO' )[i];
				end;
				t[7] = res[1].owner;
				t[8] = res[1].key;
				t[9] = i - 1;
				setElementData( nextmark, 'HSV_INFO', { t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9] } );
				local player = getPlayerByHouseID( i - 1 );
				setElementData( player, 'mark_in', i - 1 );
			else
				sqly.Query( "DELETE FROM housevip_data WHERE ID = ?", i );
				destroyElement( mark );
			end;
		end;
		outputChatBox ('Casa #'..getElementData( source, 'mark_in' )..' foi destruída!', source, 255, 255, 0);
		setElementFrozen (source, false);
		setElementData (source, 'mark_in', nil);
	else
		outputChatBox ('Casas criadas pelo Console não podem ser destruídas in-game.', source, 255, 150, 0);
	end
end );

function getHouseByID( id )
	for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do
		if getElementData( v, 'HSV_INFO' ) and getElementData( v, 'HSV_INFO' )[9] == id then
			return v;
		end;
	end;
	return false;
end;

function getPlayerByHouseID( id )
	for i, v in ipairs( getElementsByType( 'player' ) ) do
		if getElementData( v, 'mark_in' ) == id then
			return v;
		end;
	end;
	return false;
end;

addEvent( 'setFrozen', true );
addEventHandler( 'setFrozen', root, function( state )
	setElementFrozen( client, state );
end );

addEventHandler( 'onPlayerWasted', root, function()
	if getElementData( source, 'mark_in' ) then
		setElementData( source, 'mark_in', nil );
		setElementFrozen( source, false );
	end;
end );

function getPlayerByAccountName( name )
	for i, v in ipairs( getElementsByType( 'player' ) ) do
		if getElementData( v, 'HSV_accountName' ) == name then
			return v;
		end;
	end;
	return false;
end;

timerRent = tonumber (get( 'rentTimer' )*60000)
rentTimer = setTimer (function ()
	for i, v in ipairs( getElementsByType( 'marker', getResourceRootElement() ) ) do --Para cada elemento do tipo marker criado:
		local housev = getHouseByID (i) --Verifica se o marker é uma casa. Se não for, então isso é false.
		if housev then --Se o marker for qualquer coisa exceto false ou nulo: (se for false então não é um marker de casa)
			local ownerv = getElementData (housev, 'HSV_INFO')[7] --ownerv recebe o dono desta casa.
			local userv1 = getPlayerByAccountName (getElementData (housev, 'HSV_INFO')[10]) --recebe o morador1
			local userv2 = getPlayerByAccountName (getElementData (housev, 'HSV_INFO')[11]) --morador2
			local userv3 = getPlayerByAccountName (getElementData (housev, 'HSV_INFO')[12]) --3
			local rentv1 = getElementData (housev, 'HSV_INFO')[13] --recebe o aluguel1
			if rentv1 == '' then --Se o valor do aluguel1 for vazio, então recebe 0.
				rentv1 = 0
			end
			local rentv2 = getElementData (housev, 'HSV_INFO')[14] --recebe o aluguel2
			if rentv2 == '' then
				rentv2 = 0
			end
			local rentv3 = getElementData (housev, 'HSV_INFO')[15] --recebe o aluguel3
			if rentv3 == '' then
				rentv3 = 0
			end
			for int, players in ipairs( getElementsByType( 'player' ) ) do --Para cada jogador do servidor:
				local accv = getAccountName (getPlayerAccount (players)) --Recebe a conta deste jogador.
				if ownerv == accv then --Se o dono da casa for este jogador:
					if isElement (userv1) and getElementType (userv1) == 'player' then
						if getPlayerMoney (userv1) >= tonumber(rentv1) then
							outputChatBox ("O #fff000morador 1#E7D9B0 da sua casa #fff000ID "..i.."#E7D9B0 te pagou o aluguel de #00ff00$"..rentv1, players, 231, 217, 176, true)
							outputChatBox ("Você pagou o aluguel da cada #fff000ID "..i.."#E7D9B0 no valor de #00ff00$"..rentv1, userv1, 231, 217, 176, true)
							takePlayerMoney (userv1, tonumber(rentv1))
							givePlayerMoney (players, tonumber(rentv1))
						else
							outputChatBox ("O #fff000morador 1#FF3324 da sua casa #fff000ID "..i.."#FF3324 não pagou o aluguel de #fff000$"..rentv1.."#FF3324 pois não possui dinheiro suficiente.", players, 255, 51, 36, true)
							outputChatBox ("Você não tem dinheiro suficiente para pagar o aluguel da cada #fff000ID "..i.."#FF3324 no valor de #fff000$"..rentv1..".#FF3324 O dono da casa foi notificado.", userv1, 255, 51, 36, true)
						end
					end
					if isElement (userv2) and getElementType (userv2) == 'player' then
						if getPlayerMoney (userv2) >= tonumber(rentv2) then
							outputChatBox ("O #fff000morador 2#E7D9B0 da sua casa #fff000ID "..i.."#E7D9B0 te pagou o aluguel de #00ff00$"..rentv2, players, 231, 217, 176, true)
							outputChatBox ("Você pagou o aluguel da cada #fff000ID "..i.."#E7D9B0 no valor de #00ff00$"..rentv2, userv2, 231, 217, 176, true)
							takePlayerMoney (userv2, tonumber(rentv2))
							givePlayerMoney (players, tonumber(rentv2))
						else
							outputChatBox ("O #fff000morador 2#FF3324 da sua casa #fff000ID "..i.."#FF3324 não pagou o aluguel de #fff000$"..rentv2.."#FF3324 pois não possui dinheiro suficiente.", players, 255, 51, 36, true)
							outputChatBox ("Você não tem dinheiro suficiente para pagar o aluguel da cada #fff000ID "..i.."#FF3324 no valor de #fff000$"..rentv2..".#FF3324 O dono da casa foi notificado.", userv2, 255, 51, 36, true)
						end
					end
					if isElement (userv3) and getElementType (userv3) == 'player' then
						if getPlayerMoney (userv3) >= tonumber(rentv3) then
							outputChatBox ("O #fff000morador 3#E7D9B0 da sua casa #fff000ID "..i.."#E7D9B0 te pagou o aluguel de #00ff00$"..rentv3, players, 231, 217, 176, true)
							outputChatBox ("Você pagou o aluguel da cada #fff000ID "..i.."#E7D9B0 no valor de #00ff00$"..rentv3, userv3, 231, 217, 176, true)
							takePlayerMoney (userv3, tonumber(rentv3))
							givePlayerMoney (players, tonumber(rentv3))
						else
							outputChatBox ("O #fff000morador 3#FF3324 da sua casa #fff000ID "..i.."#FF3324 não pagou o aluguel de #fff000$"..rentv3.."#FF3324 pois não possui dinheiro suficiente.", players, 255, 51, 36, true)
							outputChatBox ("Você não tem dinheiro suficiente para pagar o aluguel da cada #fff000ID "..i.."#FF3324 no valor de #fff000$"..rentv3..".#FF3324 O dono da casa foi notificado.", userv3, 255, 51, 36, true)
						end
					end
				end
			end
		end
	end
end, timerRent, 0)

 

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