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

Solved [TFS 1.0] Buy function

Techrlz

System Manager & Programmer
Premium User
Joined
Feb 20, 2014
Messages
1,073
Solutions
4
Reaction score
177
I need help to make my buy function,

i have this:

Code:
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
doPlayerRemoveMoney(cid, t[item].buyprice*amount)
doPlayerAddItem(cid, [t]item, amount)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought " .. amount .. "x " .. getItemName(item) .. " for " .. t[item].price*amount .. " gold.")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You dont have money")
end

and have one variable with this named t:
Code:
local t = {
[7493] = {price = 750},{buyprice = 9999}}
 
Maybe:
Code:
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
    if (doPlayerRemoveMoney(cid, t[item].buyprice*amount) == TRUE) {
        doPlayerAddItem(cid, [t]item, amount)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought " .. amount .. "x " .. getItemName(item) .. " for " .. t[item].price*amount .. " gold.")
    }
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You dont have money")
end
 
Code:
[Warning - NpcScript::NpcScript] Can not load script: Haroun.lua
data/npc/scripts/Haroun.lua:110: unexpected symbol near '['
 
Back
Top