zRodrigoMM Posted June 27, 2020 Share Posted June 27, 2020 bom eu estou tentando mudar o seguinte valor: local housesLimit = tonumber ( get ( "maxHouses" ) ) or 2 para que passe a ser possível ter mais de uma casa como dono, mas ao alterar o valor dessa linha ainda continuo limitado há apenas uma casa, alguém pode me ajudar ? Server side completo: local playersWarping = { } local playersInInterior = { } local lastWarp = { } local interiors = { [ 1 ] = { 1, 244.4119, 305.0329, 999.1484 }, [ 2 ] = { 2, 266.5009, 304.9670, 999.1484 }, [ 3 ] = { 4, 302.1809, 300.7229, 999.1484 }, [ 4 ] = { 3, 2496.0065, -1692.8518, 1014.7421 }, [ 5 ] = { 5, 1260.9622, -785.4465, 1091.9062 }, [ 6 ] = { 2, 2468.5056, -1698.2500, 1013.5078 }, [ 7 ] = { 5, 2352.4500, -1180.9650, 1027.976 }, [ 8 ] = { 8, 2807.6347, -1174.2792, 1025.5703 }, [ 9 ] = { 5, 318.6222, 1114.7529, 1083.8828 }, [ 10 ] = { 12, 2324.4501, -1149.2780, 1050.7100 }, [ 11 ] = { 5, 140.2478, 1366.3989, 1083.8593 }, [ 12 ] = { 4, -260.6278, 1456.6441, 1084.3671 }, [ 13 ] = { 8, -42.5800, 1405.6099, 1084.4269 }, [ 14 ] = { 6, -68.8081, 1351.4376, 1080.2109 }, [ 15 ] = { 5, 2233.6950, -1114.8648, 1050.8828 }, [ 16 ] = { 8, 2365.3103, -1135.4029, 1050.8750 }, [ 17 ] = { 11, 2282.9099, -1140.2900, 1050.8980 }, [ 18 ] = { 10, 2270.0161, -1210.4719, 1047.5625 }, [ 19 ] = { 6, 2333.1760, -1077.0630, 1049.0230 }, [ 20 ] = { 2, 491.1, 1398.8, 1080.2 }, [ 21 ] = { 2, 447.0, 1397.2, 1084.3 }, [ 22 ] = { 5, 22.875, 1403.51, 1084.4 }, [ 23 ] = { 5, 226.62, 1114.29, 1080.9 }, [ 24 ] = { 6, 234.16, 1064.05, 1084.21 }, [ 25 ] = { 9, 83.05, 1322.47, 1083.86 }, [ 26 ] = { 10, 23.98, 1340.27, 1084.37 }, [ 27 ] = { 15, 376.85, 1417.34, 1081.32 }, [ 28 ] = { 15, 295.1, 1472.2, 1080.2 } } local housesLimit = tonumber ( get ( "maxHouses" ) ) or 2 addEventHandler ( "onResourceStart", resourceRoot, function ( ) for _, house in ipairs ( getHousingList ( ) ) do createHouse(house) end for _, player in pairs(getElementsByType("player")) do createHouseBlips(player) end for _, interior in ipairs ( interiors ) do local int, x, y, z = unpack ( interior ) local exitColshape = createColTube ( x, y, ( z - 0.5 ), 1.3, 2.5 ) setElementInterior ( exitColshape, int ) addEventHandler ( "onColShapeHit", exitColshape, onInteriorLeave ) end end ) addEvent ( "housing:isPlayerInsideHouse", true ) addEventHandler ( "housing:isPlayerInsideHouse", resourceRoot, function ( ) local dimension = getElementDimension ( client ) local houseName = houseIDS [ dimension ] if ( houseName and housesCreated [ houseName ] ) then playersInInterior [ client ] = houseName housesCreated [ houseName ].playersInside [ client ] = true lastWarp [ client ] = getTickCount ( ) end end ) function onHouseColshapeHit ( hitElement, d ) if ( isElement( hitElement ) and d ) then if ( getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement ) ) then local houseName = getElementData ( source, "houseName" ) if ( houseName ) then viewHouseInformation ( hitElement, housesCreated [ houseName ] [ "data" ], source ) end end end end function viewHouseInformation ( thePlayer, houseData, colshape ) if ( houseData and type ( houseData ) == "table" ) then if ( colshape and isElement ( colshape ) ) then if ( isElementWithinColShape ( thePlayer, colshape ) ) then local accountName = getPlayerAccountName ( thePlayer ) triggerClientEvent ( thePlayer, "housing:showHouseInformation", resourceRoot, houseData, accountName ) end end end end function onInteriorLeave ( leaveElement ) if ( getElementType ( leaveElement ) == "player" ) then if ( playersInInterior [ leaveElement ] ) and ( not playersWarping [ leaveElement ] ) and ( getTickCount ( ) - lastWarp [ leaveElement ] >= 3000 ) then setPlayerInInterior ( leaveElement, playersInInterior [ leaveElement ] ) end end end addEvent ( "housing:enterInterior", true ) addEventHandler ( "housing:enterInterior", resourceRoot, function ( houseName ) local accountName = getPlayerAccountName ( client ) local houseData = housesCreated [ houseName ] [ "data" ] local dimension = houseData.dimension local interior = houseData.interior local doorStatus = houseData.interiorState if ( doorStatus ~= "Open" ) then if ( accountName ~= housesCreated [ houseName ] [ "data" ].owner ) then return triggerClientEvent ( client, "housing:showInfo", resourceRoot, "error", "Esta casa está trancada" ) end end setPlayerInInterior ( client, houseName ) end ) function setPlayerInInterior ( thePlayer, houseName ) if ( houseName ) then local houseData = housesCreated [ houseName ] [ "data" ] local dimension = houseData.dimension local interior = houseData.interior toggleAllControls ( thePlayer, false ) fadeCamera ( thePlayer, false, 1 ) playersWarping [ thePlayer ] = true setTimer ( function ( thePlayer, houseName, interior, dimension ) if ( isElement ( thePlayer ) ) then if ( getElementInterior ( thePlayer ) == interiors [ interior ] [ 1 ] ) then x, y, z = getElementPosition ( housesCreated [ houseName ] [ "pickup" ] ) int, dimension = 0, 0 else int, x, y, z = unpack ( interiors [ interior ] ) end setElementInterior ( thePlayer, int, x, y, z+1 ) setElementDimension ( thePlayer, dimension ) fadeCamera ( thePlayer, true, 1 ) toggleAllControls ( thePlayer, true ) playersWarping [ thePlayer ] = nil lastWarp [ thePlayer ] = getTickCount ( ) if ( int > 0 ) then housesCreated [ houseName ].playersInside [ thePlayer ] = true playersInInterior [ thePlayer ] = houseName else housesCreated [ houseName ].playersInside [ thePlayer ] = nil playersInInterior [ thePlayer ] = nil end triggerEvent ( ( dimension == 0 and "onPlayerLeaveHouse" or "onPlayerEnterHouse" ), thePlayer, houseName ) end end ,1000, 1, thePlayer, houseName, interior, dimension ) end end addEvent ( "housing:buyHouse", true ) addEventHandler ( "housing:buyHouse", resourceRoot, function ( houseName ) if ( not isPlayerLoggedIn ( client ) ) then return triggerClientEvent ( client, "housing:showInfo", resourceRoot, "error", "Você precisa estar logado" ) end local house = housesCreated [ houseName ] if ( house [ "data" ] [ "forSale" ] == "Yes" ) then local price = tonumber ( house [ "data" ] [ "price" ] ) local owner = house [ "data" ] [ "owner" ] local accountName = getPlayerAccountName ( client ) if ( #getAccountHouses ( accountName ) >= housesLimit ) then return triggerClientEvent ( client, "housing:showInfo", resourceRoot, "error", "Você não pode comprar mais do que ".. housesLimit .." casa(s)" ) end if ( getPlayerMoney ( client ) >= price ) then if ( owner ~= "" ) then local playerOwner = getAccountPlayer ( getAccount ( owner ) ) if ( not playerOwner ) then return triggerClientEvent ( client, "housing:showInfo", resourceRoot, "error", "Você não pode comprar esta casa porque o dono não está on-line" ) end createHouseBlips ( playerOwner ) givePlayerMoney ( playerOwner, price ) outputChatBox ( "Housing: ".. getPlayerName ( client ):gsub ( "#%x%x%x%x%x%x", "" ) .." comprou sua ".. houseName .." casa por $".. convertNumber ( price ), playerOwner, 0, 255, 0 ) end if ( house [ "pickup" ] ) and isElement( house [ "pickup" ] ) then setMarkerColor(house["pickup"], 255, 0, 0, 255) end local cDate, cTime = getCurrentDateAndTime ( ) setHouseData ( houseName, { "houseOwner", "housePrice", "houseForSale", "buyDate", "houseInteriorState" }, { accountName, price, "No", ( cDate .." - ".. cTime ), "Closed" } ) createHouseBlips ( client ) takePlayerMoney ( client, price ) triggerClientEvent ( client, "housing:showHouseInformation", resourceRoot, housesCreated [ houseName ] [ "data" ], accountName ) triggerClientEvent ( client, "housing:showInfo", resourceRoot, "info", "Você comprou a casa por $".. convertNumber ( price ) .."." ) else triggerClientEvent ( client, "housing:showInfo", resourceRoot, "error", "Você precisa de $".. convertNumber ( price - getPlayerMoney ( client ) ) .." para comprar a casa." ) end else triggerClientEvent ( client, "housing:showInfo", resourceRoot, "error", "A casa não está à venda." ) end end ) addEvent ( "housing:toggleSaleStatus", true ) addEventHandler ( "housing:toggleSaleStatus", resourceRoot, function ( houseName ) if ( not isPlayerLoggedIn ( client ) ) then return triggerClientEvent ( client, "housing:showInfo", resourceRoot, "error", "Você precisa estar logado." ) end local house = housesCreated [ houseName ] local accountName = getPlayerAccountName ( client ) if ( house [ "data" ] [ "owner" ] == accountName ) then local newState = ( house [ "data" ].forSale == "No" and "Yes" or "No" ) local pickupModelYes = ( newState == "Yes" and 255 or 0 ) local pickupModelNo = ( newState == "No" and 255 or 0 ) setMarkerColor(house["pickup"], pickupModelNo, pickupModelYes, 0, 255) setHouseData ( houseName, { "houseForSale", "houseInteriorState" }, { newState, ( newState == "Yes" and "Open" or "Closed" ) } ) triggerClientEvent ( client, "housing:showInfo", resourceRoot, "info", ( newState == "Yes" and "A casa agora está a venda." or "A casa agora não esta a venda." ) ) triggerClientEvent ( client, "housing:showHouseInformation", resourceRoot, housesCreated [ houseName ] [ "data" ], accountName ) else triggerClientEvent ( client, "housing:showInfo", resourceRoot, "error", "Você não é o dono desta casa." ) end end ) addCommandHandler ( "casa", function ( thePlayer ) if hasObjectPermissionTo ( thePlayer, "command.mute" ) then triggerClientEvent ( thePlayer, "housing:showHousingManager", resourceRoot, getHousingList ( ), interiors, "add" ) end end ) addCommandHandler ( "invcasa", function ( thePlayer ) local houseName = playersInInterior [ thePlayer ] if houseName then if ( getPlayerAccountName ( thePlayer ) == housesCreated [ houseName ] [ "data" ].owner ) then triggerClientEvent ( thePlayer, "housing:showWeaponsManager", resourceRoot, getPedWeapons( thePlayer ), getHouseData( houseName, "houseWeapons" ) ) end end end ) addEvent ( "housing:addWeaponHouse", true ) addEventHandler ( "housing:addWeaponHouse", resourceRoot, function ( weaponID, ammo ) local houseName = playersInInterior [ client ] if houseName then local houseData = getHouseData( houseName, "houseWeapons" ) if houseData then local itens = fromJSON( houseData ) if itens [ tostring( weaponID ) ] then local newAmmo = tonumber ( itens [ tostring( weaponID ) ] ) + ammo takeWeapon( client, weaponID ) itens [ weaponID ] = newAmmo setHouseData ( houseName, "houseWeapons", toJSON ( itens ) ) triggerClientEvent( client, "housing:updateWeaponsManager", resourceRoot, getPedWeapons( client ), getHouseData( houseName, "houseWeapons" ) ) return end takeWeapon( client, weaponID ) itens [ weaponID ] = ammo setHouseData ( houseName, "houseWeapons", toJSON ( itens ) ) triggerClientEvent( client, "housing:updateWeaponsManager", resourceRoot, getPedWeapons( client ), getHouseData( houseName, "houseWeapons" ) ) else local itens = {} takeWeapon( client, weaponID ) itens [ weaponID ] = ammo setHouseData ( houseName, "houseWeapons", toJSON ( itens ) ) triggerClientEvent( client, "housing:updateWeaponsManager", resourceRoot, getPedWeapons( client ), getHouseData( houseName, "houseWeapons" ) ) end end end ) addEvent ( "housing:removeWeaponHouse", true ) addEventHandler ( "housing:removeWeaponHouse", resourceRoot, function ( weaponID, ammo ) local houseName = playersInInterior [ client ] if houseName then local houseData = getHouseData( houseName, "houseWeapons" ) if houseData then local itens = fromJSON( houseData ) giveWeapon( client, weaponID, ammo, true ) itens [ tostring( weaponID ) ] = nil setHouseData ( houseName, "houseWeapons", toJSON ( itens ) ) triggerClientEvent( client, "housing:updateWeaponsManager", resourceRoot, getPedWeapons( client ), getHouseData( houseName, "houseWeapons" ) ) end end end ) function getPedWeapons(ped) local playerWeapons = {} if isElement(ped) and getElementType(ped) == "player" then for i=1,9 do local wep = getPedWeapon(ped,i) local ammo = getPedTotalAmmo(ped,i) if wep ~= 0 then playerWeapons[wep] = ammo end end else return false end return playerWeapons end addEvent ( "housing:createHouse", true ) addEventHandler ( "housing:createHouse", resourceRoot, function ( houseName, houseOwner, housePrice, housePosition, interior ) if ( houseOwner ~= "" and #getAccountHouses ( houseOwner ) >= housesLimit ) then return triggerClientEvent ( client, "housing:showInfo", resourceRoot, "error", "Esta conta já possui casa" ) end local added, errorMsg = addHouseToDatabase ( houseName, houseOwner, housePrice, split ( housePosition, " ," ), interior, client ) if ( added ) then triggerClientEvent ( client, "housing:returnHouses", resourceRoot, getHousingList ( ) ) outputChatBox ( "Housing manager: Você criou a casa com sucesso.", client, 0, 255, 0 ) else outputChatBox ( "Housing manager: ".. errorMsg or "Unknown" ..".", client, 255, 0, 0 ) end end ) addEvent ( "housing:removeHouse", true ) addEventHandler ( "housing:removeHouse", resourceRoot, function ( houseName, houseOwner ) local removed, errorMsg = removeHouseFromDatabase ( houseName, client ) if ( removed ) then outputChatBox ( "Housing manager: A casa foi removida com sucesso.", client, 0, 255, 0 ) triggerClientEvent ( client, "housing:returnHouses", resourceRoot, getHousingList ( ) ) else outputChatBox ( "Housing manager: ".. errorMsg or "Unknown" ..".", client, 255, 0, 0 ) end end ) addEvent ( "housing:editHouse", true ) addEventHandler ( "housing:editHouse", resourceRoot, function ( houseName, houseName_, houseOwner, housePrice, housePosition, interiorID ) if ( houseName ) then local toSet = { [ "houseName" ] = { houseName_, "name" }, [ "houseOwner" ] = { houseOwner, "owner" }, [ "housePrice" ] = { housePrice, "price" }, [ "housePosition" ] = { toJSON ( split ( housePosition, " ," ) ), "position" }, [ "houseInterior" ] = { interiorID, "interior" } } for dataName, dataValue in pairs ( toSet ) do setHouseData ( houseName, dataName, dataValue [ 1 ] ) end triggerClientEvent ( client, "housing:returnHouses", resourceRoot, getHousingList ( ) ) outputChatBox ( "Housing manager: A casa foi atualizada com sucesso.", client, 0, 255, 0 ) end end ) addEvent ( "housing:setDoorStatus", true ) addEventHandler ( "housing:setDoorStatus", resourceRoot, function ( houseName ) local accountName = getPlayerAccountName ( client ) local houseData = housesCreated [ houseName ] [ "data" ] local doorStatus = houseData.interiorState local newDoorStatus = ( doorStatus == "Open" and "Closed" or "Open" ) setHouseData ( houseName, "houseInteriorState", newDoorStatus ) triggerClientEvent ( client, "housing:showInfo", resourceRoot, "info", "A casa agora está ".. ( newDoorStatus == "Closed" and "fechada" or "aberta" ) ) triggerClientEvent ( client, "housing:showHouseInformation", resourceRoot, housesCreated [ houseName ] [ "data" ], accountName ) end ) addEvent ( "housing:setSalePrice", true ) addEventHandler ( "housing:setSalePrice", resourceRoot, function ( houseName, housePrice ) if ( not isPlayerLoggedIn ( client ) ) then return triggerClientEvent ( client, "housing:showInfo", resourceRoot, "error", "Você precisa estar logado." ) end local house = housesCreated [ houseName ] local accountName = getPlayerAccountName ( client ) if ( house [ "data" ] [ "owner" ] == accountName ) then if ( house [ "data" ] [ "forSale" ] == "No" ) then setHouseData ( houseName, "housePrice", housePrice ) triggerClientEvent ( client, "housing:showInfo", resourceRoot, "info", "Preço definido para $".. convertNumber ( housePrice ) ) triggerClientEvent ( client, "housing:showHouseInformation", resourceRoot, housesCreated [ houseName ] [ "data" ], accountName ) else triggerClientEvent ( client, "housing:showInfo", resourceRoot, "error", "Você não pode definir o preço durante a venda." ) end else triggerClientEvent ( client, "housing:showInfo", resourceRoot, "error", "Você não é o dono desta casa." ) end end ) addEventHandler ( "onPlayerLogin", root, function ( ) setTimer( function( s ) if ( getElementInterior ( s ) ~= 0 ) then local dimension = getElementDimension ( s ) local houseName = houseIDS [ dimension ] if ( houseName and housesCreated [ houseName ] ) then playersInInterior [ s ] = houseName housesCreated [ houseName ].playersInside [ s ] = true lastWarp [ s ] = getTickCount ( ) end end end, 1000, 1, source ) end ) addEventHandler ( "onPlayerWasted", root, function ( ) if ( getElementInterior ( source ) > 0 ) then local houseName = playersInInterior [ source ] if ( houseName ) then local house = housesCreated [ houseName ] if ( house ) then housesCreated [ houseName ].playersInside [ source ] = nil end end playersInInterior [ source ] = nil end triggerClientEvent(source, "housing:showHousingManager", resourceRoot, _, _, "remove") end ) Link to comment
Angelo Pereira Posted June 28, 2020 Share Posted June 28, 2020 no resouce, o problema se encontra aqui : --> Valor : local housesLimit = tonumber ( get ( "maxHouses" ) ) or 2 --linha 164 : if ( #getAccountHouses ( accountName ) >= housesLimit ) then --> Problema : ">=", o que significa? se for maior, ou igual. --> Então se a pessoa tentar compra a 2ª casa, retornará. Solução : if ( #getAccountHouses ( accountName ) > housesLimit ) then --> Apenas deixa, se for acima do valor. 1 Link to comment
zRodrigoMM Posted June 28, 2020 Author Share Posted June 28, 2020 1 hour ago, Angelo Pereira said: no resouce, o problema se encontra aqui : --> Valor :local housesLimit = tonumber ( get ( "maxHouses" ) ) or 2--linha 164 :if ( #getAccountHouses ( accountName ) >= housesLimit ) then--> Problema : ">=", o que significa? se for maior, ou igual.--> Então se a pessoa tentar compra a 2ª casa, retornará. Solução : if ( #getAccountHouses ( accountName ) > housesLimit ) then--> Apenas deixa, se for acima do valor. obrigado, deu certo! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now