• 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!

[Talkaction] Points TFS 1.2

yoiker

Member
Joined
Jan 21, 2012
Messages
194
Solutions
1
Reaction score
9
Hello and happy day, afternoon or evening for all depends on your local country!

I make this post because I'm covered and I can not go because I have no idea what to do for the talkaction that I will later work

I explain what I tried to do was a talkaction to start trade simulating an item which by accepting the other player will give you a premium point in their account and who initiated the trade it will remove the premium point account of it

Now I have a problem and you can not complete the trade because once accepting says "Trade could not be completed". And of course, it does not give me the premium point not removed the other player...

Now only your hand if you want to help me because I can not continue because the truth I do not know what else to do.

Talkaction;

Code:
function onSay(player, words, param, channel)
    local split = param:split(",")
    if split[2] == nil then
        player:sendCancelMessage("Insufficient parameters.")
        return false
    end

    local target = Player(split[1])
    if target == nil then
        player:sendCancelMessage("Trade player not found.")
        return false
    end

    local position = player:getPosition()
    if position:getDistance(target:getPosition()) > 2 then
        player:sendCancelMessage("Trade player is too far away.")
        return false
    end

    local plural = ''
    if playerGetPoints(player) > 1 then
    plural = 's'
    end

    local points = playerGetPoints(player)
    local curentPoints = split[2]
    if points < 1 then
        player:sendCancelMessage("You do not have enough points.")
        return false
    end

    local item = 0
    local stuff
    local trade

    stuff = Game.createItem(24774, curentPoints)
    --item = stuff:addItem(24774, curentPoints)

    Game.startTrade(player, target, stuff)

    return false
end

And I put these functions in lib/core/player

Code:
function playerSetPoints(player, amount)
    local plural = ''
    db.query("UPDATE `accounts` SET `premium_pointss` = " .. amount .. " WHERE `id` = " .. player:getAccountId() .. ' LIMIT 1;')
    if amount > 1 then plural = 's' end
    return true
end
function playerAddPoints(player, amount)
    local plural = ''
    db.query("UPDATE `accounts` SET `premium_pointss` = `premium_pointss` + " .. amount .. " WHERE `id` = " .. player:getAccountId() .. ' LIMIT 1;')
    if amount > 1 then plural = 's' end
    return true
end
function playerRemovePoints(player, amount)
    local plural = ''
    db.query("UPDATE `accounts` SET `premium_pointss` = `premium_pointss` - " .. amount .. " WHERE `id` = " .. player:getAccountId() .. ' LIMIT 1;')
    if amount > 1 then plural = 's' end
    return true
end
function playerGetPoints(player)
local resultId = db.storeQuery("SELECT `premium_pointss` FROM `accounts` WHERE `id` = " .. player:getAccountId())
    if resultId ~= false then
    local pointsId = result.getNumber(resultId, "premium_pointss")
    result.free(resultId)
    return pointsId
end
    return 0
end
 
sure you can initiate trade with talkaction but you need to do something with the trade in order to remove/transfer/add "points"
hint:
Code:
function Player:onTradeAccept(target, item, targetItem)
    return true
end
events

also this belongs in support since you're asking help with a script, not requesting one
 
Back
Top