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

TalkAction !aol and !backpack

@up

Code:
local shop = {
    ["aol"] = { id = 2173, count = 1, cost = 10000 },
    ["backpack"] = { id = 1988, count = 1, cost = 50 },
    ["bag"] = { id = <id of bag>, count = 1, cost = 20 }
}
function onSay(cid, words, param, channel)
    local cfg = shop[param]
    if(param == "") then
        doPlayerSendCancel(cid, "Command requires param.")
    elseif(getPlayerMoney(cid) < cfg.cost) then
        doPlayerSendCancel(cid, "You do not have enough money.")
    else
        doPlayerRemoveMoney(cid, cfg.cost)
        doPlayerAddItem(cid, cfg.id, cfg.count)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased " .. getItemNameById(cfg.id) .. ".")
    end
    return true
end
 
@up

Code:
local shop = {
    ["aol"] = { id = 2173, count = 1, cost = 10000 },
    ["backpack"] = { id = 1988, count = 1, cost = 50 },
    ["bag"] = { id = <id of bag>, count = 1, cost = 20 }
}
function onSay(cid, words, param, channel)
    local cfg = shop[param]
    if(param == "") then
        doPlayerSendCancel(cid, "Command requires param.")
    elseif(getPlayerMoney(cid) < cfg.cost) then
        doPlayerSendCancel(cid, "You do not have enough money.")
    else
        doPlayerRemoveMoney(cid, cfg.cost)
        doPlayerAddItem(cid, cfg.id, cfg.count)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased " .. getItemNameById(cfg.id) .. ".")
    end
    return true
end



[03/06/2010 23:07:56] [Error - TalkAction Interface]
[03/06/2010 23:07:56] data/talkactions/scripts/buyitems.lua:eek:nSay
[03/06/2010 23:07:57] Description:
[03/06/2010 23:07:57] data/talkactions/scripts/buyitems.lua:9: attempt to index local 'cfg' (a nil value)
[03/06/2010 23:07:57] stack traceback:
[03/06/2010 23:07:57] data/talkactions/scripts/buyitems.lua:9: in function <data/talkactions/scripts/buyitems.lua:5>


The point is if someone says !buy anything
I'll get that lag on server and it sucks if someone discovers that and abuses it.
 
At my server it removed money but didn't add the item.
If you have this problem just change this:
if doPlayerRemoveMoney(cid, 10000) == 1 then
to
if doPlayerRemoveMoney(cid, 10000) == true then


HTML:
function onSay(cid, words, param)
if doPlayerRemoveMoney(cid, 10000) == true then
doPlayerAddItem(cid, 2173, 1)
else
            doPlayerSendCancel(cid, 'You don\'t have enough money.')
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
        end

Hope it is usefull:cool:
 
Hey guys! I have a problem, I cant get these things to work.. Not 100%.. When I say !backpack , the money disappears, but I dont get a backpack, and when I say !blessings, it says "You dont have enough money", and same with !aol , it says "You need 6 crystal coins."

NOTE:

I have /i 2160 (crystal coin)x30

- - - Updated - - -

Nvm, fixed it, ty =)
 
tfs 0.4
function onSay(cid, words, param)
if getPlayerMoney(cid) >= 10000 then
doPlayerRemoveMoney(cid, 10000)
doPlayerAddItem(cid, 2173, 1)
doPlayerSendCancel(cid, 'You purchased aol.')
else
doPlayerSendCancel(cid, 'You don\'t have enough money.')
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
end
 
Maybe someone need code for tfs 1.x

!backpack
Lua:
local price_backpack = 10000

function onSay(player, words, param)
 
    if player:removeMoney(price_backpack) then
        player:getPosition():sendMagicEffect(CONST_ME_YELLOW_RINGS)
        player:addItem(2004, 1)  
    else
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:sendCancelMessage("Nie masz tyle CC!")
    end
 
end

!aol
Lua:
local price_aol = 50000

function onSay(player, words, param)
  
    if player:removeMoney(price_aol) then
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        player:addItem(2173, 1)   
    else
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:sendCancelMessage("You dont have enought money.")
    end
  
end
 
Back
Top