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

Lua Talkaction - rewrite !buypoints to tfs 1.1

zerghel

Tsuni
Joined
Jul 1, 2008
Messages
299
Reaction score
9
hello otlanders, i had this talkaction working on our server, but i moved to tfs 1.1 and the talkaction is working no more, i'm not a scripter myself as many of you are, so i beg a little help rewriting it for tfs 1.1.

this talkaction gives points in exchange of crystal coins, so the players can buy items in the website and it works fine in tfs 0.2.15

(i think i posted this on a wrong section before(sorry for that))

Code:
dofile('./config.lua')
function addPoints(playerName, amount)
    local accNum = getAccountNumberByPlayerName(playerName)
    if accNum == 0 or amount == 0 then
        return
    end
    local env = assert(luasql.mysql())
    local con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
    assert(con:execute('UPDATE `znote_accounts` SET `points` = `points` + ' .. amount .. ' WHERE `account_id` = ' .. accNum .. ' LIMIT 1;'))
    con:close()
    env:close()
end

function onSay(cid, words, param)
        if doPlayerRemoveMoney(cid, 100000) then
        addPoints(getCreatureName(cid), 10)
        doCreatureSay(cid, 'You have received 10 premium points!', TALKTYPE_ORANGE_1)
        else
            doPlayerSendCancel(cid, "You don't have enough money, 10 premium point costs 10 crystal coins.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
end
 
Last edited:
Not tested, please test before using it on a live server.

Code:
function onSay(player, words, param)
    if(player:removeMoney(100000)) then
        db.query('UPDATE `znote_accounts` SET `points` = `points` + 10 WHERE `account_id` = ' .. player:getAccountId() .. ' LIMIT 1;')
        player:say('You have received 10 premium points!', TALKTYPE_MONSTER_SAY)
    else
        player:sendCancelMessage("You don't have enough money, 10 premium point costs 10 crystal coins.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
 
Back
Top