function onSay(cid, words, param)
local t = string.explode(param, ",")
if t[1] ~= nil and t[2] ~= nil then
local result = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '"..t[1].."';")
db.executeQuery("UPDATE `accounts` SET `coins` = `coins` + "..t[2].." WHERE `id` = '" ..result:getDataString("account_id").. "';")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..t[1].." has received "..t[2].." Tibia Coins.")
result:free()
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires two params.")
end
return TRUE
end
<talkaction words="/addcoins" separator=" " script="addcoins.lua" />
Not tested.
talkactions/addcoins.lua
LUA:function onSay(cid, words, param) local t = string.explode(param, ",") if t[1] ~= nil and t[2] ~= nil then local result = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '"..t[1].."';") db.executeQuery("UPDATE `accounts` SET `coins` = `coins` + "..t[2].." WHERE `id` = '" ..result:getDataString("account_id").. "';") doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..t[1].." has received "..t[2].." Tibia Coins.") result:free() else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Command requires two params.") end return TRUE end
talkactions.xml
XML:<talkaction words="/addcoins" separator=" " script="addcoins.lua" />
Example: /addcoins Loney, 10
stil not working :d
function onSay(player, words, param)
local split = param:split(",")
local target = split[1] and Player(split[1])
if not target then
return player:sendCancelMessage("This player does not exist.")
end
local givecoins = tonumber(split[2])
if type(givecoins) ~= 'number' or givecoins > 25000 then
player:sendCancelMessage("Total Coins (Max: 25000).")
return false
end
local result = db.query('UPDATE accounts SET coins = coins+'.. givecoins ..' WHERE id = ' .. getAccountNumberByPlayerName(target:getName()))
if result then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You gave " .. givecoins .. " tibia coins.")
target:sendTextMessage(MESSAGE_INFO_DESCR, "You received " .. givecoins .. " tibia coins.")
end
return true
end
local tibiaCoins = TalkAction("/tc")
function tibiaCoins.onSay(player, words, param)
if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
return true
end
local usage = "/tc PLAYER NAME,TC AMOUNT"
if param == "" then
player:sendCancelMessage("Command param required. Usage: ".. usage)
return false
end
local split = param:split(",")
if not split[2] then
player:sendCancelMessage("Insufficient parameters. Usage: ".. usage)
return false
end
local target = Player(split[1])
if not target then
player:sendCancelMessage("A player with that name is not online.")
return false
end
--trim left
split[2] = split[2]:gsub("^%s*(.-)$", "%1")
player:sendCancelMessage("Added " .. split[2] .. " tibia coins to the character '" .. target:getName() .. "'.")
target:sendCancelMessage("Received " .. split[2] .. " tibia coins!")
target:addTibiaCoins(tonumber(split[2]))
target:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
end
tibiaCoins:separator(" ")
tibiaCoins:register()
Thank you <3I found this in other forumLUA:local tibiaCoins = TalkAction("/tc") function tibiaCoins.onSay(player, words, param) if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then return true end local usage = "/tc PLAYER NAME,TC AMOUNT" if param == "" then player:sendCancelMessage("Command param required. Usage: ".. usage) return false end local split = param:split(",") if not split[2] then player:sendCancelMessage("Insufficient parameters. Usage: ".. usage) return false end local target = Player(split[1]) if not target then player:sendCancelMessage("A player with that name is not online.") return false end --trim left split[2] = split[2]:gsub("^%s*(.-)$", "%1") player:sendCancelMessage("Added " .. split[2] .. " tibia coins to the character '" .. target:getName() .. "'.") target:sendCancelMessage("Received " .. split[2] .. " tibia coins!") target:addTibiaCoins(tonumber(split[2])) target:getPosition():sendMagicEffect(CONST_ME_HOLYAREA) end tibiaCoins:separator(" ") tibiaCoins:register()
put it into data/scripts as a Lua file.and how to use that ?
/tc Xikini, 45
to give me 45 tibia coins.accounts
SET coins
= coins
+ '" .. quantity .. "' WHERE id
= '" .. target:getAccountId() .. "';")help please!!!!!, i have Canary v.13.32
local printConsole = true
local tibiaCoin = TalkAction("/tc")
function tibiaCoin.onSay(player, words, param)
--if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
--return true
--end
if param == "" then
player:sendCancelMessage("Command param required.")
return false
end
local split = param:split(",")
local name = split[1]
local quantity = tonumber(split[2])
if not quantity or quantity <= 0 then
player:sendCancelMessage("Invalid quantity.")
return false
end
local target = Player(name)
if target then
db.query("UPDATE accounts SET coins = coins + '" .. quantity .. "' WHERE id = '" .. target:getAccountId() .. "';")
target:sendTextMessage(MESSAGE_INFO_DESCR, "You received ".. quantity .." Tibia Coins from ".. player:getName() ..".")
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully transferred ".. quantity .." Tibia Coins to ".. target:getName() ..".")
if printConsole then
Spdlog.info(string.format("[tibiaCoin.onSay] - Player: %s has transferred %d Tibia Coins to the player: %s",
player:getName(), quantity, target:getName()))
end
return true
else
player:sendCancelMessage("Player not found.")
return true
end
return false
end
tibiaCoin:separator(" ")
tibiaCoin:groupType("normal")
tibiaCoin:register()