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

possible to add Tibia coins via a command

mimsol

New Member
Joined
Mar 18, 2020
Messages
83
Reaction score
2
Hello need some help
i want to add tibia coins via a command
would be nice if someone help
 
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
 
Anmerkung 2020-08-30 201751.png
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
Post automatically merged:

sory had no internet for a week :D
 
Replace

Lua:
local t = string.explode(param, ",")

for

Lua:
local t = string.split(param, ",")

OR

Lua:
local t = param:split(",")
 
stil not working :d

Lua:
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
 
Lua:
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()
I found this in other forum
 
Lua:
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()
I found this in other forum
Thank you <3
 
Back
Top