• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Houses For Premium Points TFS 1.2

kaszanalubizryc

New Member
Joined
Sep 10, 2015
Messages
148
Reaction score
1
hey, i need a Houses For Premium Points, or premium coin

TFS 1.2

and with command
!buyhousepremium

thanks!

bump

bump

ref
 
Last edited by a moderator:
hey, i need a Houses For Premium Points, or premium coin

TFS 1.2

and with command
!buyhousepremium

thanks!

bump

bump
Post a link to your sources since the current tfs is a little different than 1.2 and this would make it easier for people to make scripts for you.
 
Lua:
local pointsNeeded = 5

function playerCanBuyHouse(guid, amount)
    local resultId = db.storeQuery("SELECT * FROM `accounts` WHERE id = " .. guid)
    if resultId ~= false then
        local points = result.getDataInt(resultId, "premium_points")
        result.free(resultId)
        if points >= amount then
            local pointsNow = points - amount
            db.query("UPDATE `accounts` SET `premium_points` = ".. pointsNow .." WHERE id = " .. guid)
            return true
        end
    end
    return false
end

function onSay(player, words, param)
    local housePrice = configManager.getNumber(configKeys.HOUSE_PRICE)
    if housePrice == -1 then
        return true
    end

    if not player:isPremium() then
        player:sendCancelMessage("You need a premium account.")
        return false
    end

    if not playerCanBuyHouse(player:getGuid(), pointsNeeded) then
        player:sendCancelMessage("Sorry, "..player:getName().." you do not have enough points, you need "..pointsNeeded.." points to purchase a house.")
        return false
    end

    local position = player:getPosition()
    position:getNextPosition(player:getDirection())

    local tile = Tile(position)
    local house = tile and tile:getHouse()
    if house == nil then
        player:sendCancelMessage("You have to be looking at the door of the house you would like to buy.")
        return false
    end

    if house:getOwnerGuid() > 0 then
        player:sendCancelMessage("This house already has an owner.")
        return false
    end

    if player:getHouse() then
        player:sendCancelMessage("You are already the owner of a house.")
        return false
    end

    local price = house:getTileCount() * housePrice
    if not player:removeMoney(price) then
        player:sendCancelMessage("You do not have enough money.")
        return false
    end

    house:setOwnerGuid(player:getGuid())
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully bought this house, be sure to have the money for the rent in the bank.")
    return false
end
 
Lua:
local pointsNeeded = 5

function playerCanBuyHouse(guid, amount)
    local resultId = db.storeQuery("SELECT * FROM `accounts` WHERE id = " .. guid)
    if resultId ~= false then
        local points = result.getDataInt(resultId, "premium_points")
        result.free(resultId)
        if points >= amount then
            local pointsNow = points - amount
            db.query("UPDATE `accounts` SET `premium_points` = ".. pointsNow .." WHERE id = " .. guid)
            return true
        end
    end
    return false
end

function onSay(player, words, param)
    local housePrice = configManager.getNumber(configKeys.HOUSE_PRICE)
    if housePrice == -1 then
        return true
    end

    if not player:isPremium() then
        player:sendCancelMessage("You need a premium account.")
        return false
    end

    if not playerCanBuyHouse(player:getGuid(), pointsNeeded) then
        player:sendCancelMessage("Sorry, "..player:getName().." you do not have enough points, you need "..pointsNeeded.." points to purchase a house.")
        return false
    end

    local position = player:getPosition()
    position:getNextPosition(player:getDirection())

    local tile = Tile(position)
    local house = tile and tile:getHouse()
    if house == nil then
        player:sendCancelMessage("You have to be looking at the door of the house you would like to buy.")
        return false
    end

    if house:getOwnerGuid() > 0 then
        player:sendCancelMessage("This house already has an owner.")
        return false
    end

    if player:getHouse() then
        player:sendCancelMessage("You are already the owner of a house.")
        return false
    end

    local price = house:getTileCount() * housePrice
    if not player:removeMoney(price) then
        player:sendCancelMessage("You do not have enough money.")
        return false
    end

    house:setOwnerGuid(player:getGuid())
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully bought this house, be sure to have the money for the rent in the bank.")
    return false
end
thanks, but you can little explain how it work and how to use?
it will be work
1 house for pp and one other house for gp?
 
thanks, but you can little explain how it work and how to use?
it will be work
1 house for pp and one other house for gp?
Well gesior has premium points associated with its aac and the method playerCanBuyHouse calls up the player's account and checks to see if the account has enough points on it to purchase the house, pointsNeeded is the amount of points needed to purchase the home. The house still requires you to have the gp to purchase the home. I'll just make an adjustment to the script.

You can set the costMoneyToo to false and it won't remove money from the player, the points needed works just as it originally did.

Now that I look at it, this script although will work its execution is poorly written, because what if the player's money is taken but they don't have enough points? Honestly I don't feel like re-writing it.

Sorry, I am sure someone will jump in there and clean it up.
Lua:
local pointsNeeded = 5
local costMoneyToo = true
function playerCanBuyHouse(guid, amount)
    local resultId = db.storeQuery("SELECT * FROM `accounts` WHERE id = " .. guid)
    if resultId ~= false then
        local points = result.getDataInt(resultId, "premium_points")
        result.free(resultId)
        if points >= amount then
            local pointsNow = points - amount
            db.query("UPDATE `accounts` SET `premium_points` = ".. pointsNow .." WHERE id = " .. guid)
            return true
        end
    end
    return false
end
function onSay(player, words, param)
    local housePrice = configManager.getNumber(configKeys.HOUSE_PRICE)
    if housePrice == -1 then
        return true
    end
    if not player:isPremium() then
        player:sendCancelMessage("You need a premium account.")
        return false
    end
    local position = player:getPosition()
    position:getNextPosition(player:getDirection())
    local tile = Tile(position)
    local house = tile and tile:getHouse()
    if house == nil then
        player:sendCancelMessage("You have to be looking at the door of the house you would like to buy.")
        return false
    end
    if house:getOwnerGuid() > 0 then
        player:sendCancelMessage("This house already has an owner.")
        return false
    end
    if player:getHouse() then
        player:sendCancelMessage("You are already the owner of a house.")
        return false
    end
 
    if costMoneyToo then
        local price = house:getTileCount() * housePrice
        if not player:removeMoney(price) then
            player:sendCancelMessage("You do not have enough money.")
            return false
        end
    end

    if not playerCanBuyHouse(player:getGuid(), pointsNeeded) then
        player:sendCancelMessage("Sorry, "..player:getName().." you do not have enough points, you need "..pointsNeeded.." points to purchase a house.")
        return false
    end
    house:setOwnerGuid(player:getGuid())
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully bought this house, be sure to have the money for the rent in the bank.")
    return false
end
 
Last edited by a moderator:
Back
Top