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;
And I put these functions in lib/core/player
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