• 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 talkaction help needed

caraeri

soulmate
Joined
Sep 14, 2014
Messages
65
Reaction score
5
Location
Sweden
hi everyone
I made acc to ask about something. I have been following this web for long, and I can see that people have knowledge in scripting. I would like to ask for your help guys.

Atm, I am using this talkaction:

Code:
    <talkaction words="!rope" script="rope.lua" />

Code:
local config = {
    price = 100,
    itemId = 2120
}

function onSay(cid, words, param)
    local count = 1
    if isNumber(param) == TRUE and param < 21 then
        count = param
    end
  
    if doPlayerRemoveMoney(cid, config.price * count) == TRUE then
        for i = 1, count do
            doPlayerAddItem(cid, config.itemId, 1)
            doSendMagicEffect(getPlayerPosition(cid), 12)
        end
    else
        doPlayerSendCancel(cid, "You need "..count * config.price.." gold to buy "..count.." Rope(s).")
        doSendMagicEffect(getPlayerPosition(cid), 2)
    end
  
    return TRUE
end


My idea is about making this script more advanced, but with different items.

I would like to have script like this one, for buying
* 1 backpack of sd,
* also 100 sd runes, 100 potions.. so on?
is that even possible?
I could not find any guide about doing such script on this website that is why I made this post in here.

If someone could make for me script* !buybpsd - to buy full backpack of sd per 100 in rune
Also I would like to ask for !buysd - to not buy each rune x1 but rune times 100 so when someone says !buysd he gets 100 sd rune for 30k gold.

:) anybody who knows help plz>:)
thx in advance
 
bp full with sds 100x each
Code:
local config = {
    price = 100,
    itemId = 1988,
    runeId = 2263,
    countitems = 2000
}

function onSay(cid, words, param)
    local count = 1
    if isNumber(param) == TRUE then
        count = param
    end
    if doPlayerRemoveMoney(cid, config.price * count) == TRUE then
        for i = 1, count do
            local bag = doPlayerAddItem(cid, config.itemId, count)
            doPlayerAddItem(cid, config.bag, 1)
            doAddContainerItem(bag, config.runeId, config.countitems)
            doSendMagicEffect(getPlayerPosition(cid), 12)
        end
    else
        doPlayerSendCancel(cid, "You need "..count * config.price.." gold to buy "..count.." bp of sd(s).")
        doSendMagicEffect(getPlayerPosition(cid), 2)
    end
    return TRUE
end

edit: changed the id of the sd
 
Last edited:
Code:
[18/09/2014 14:19:50] Lua Script Error: [TalkAction Interface]
[18/09/2014 14:19:50] data/talkactions/scripts/bpsd.lua:onSay
[18/09/2014 14:19:50] LuaScriptInterface::luaDoPlayerAddItem(). Item not found
[18/09/2014 14:19:50] stack traceback:
[18/09/2014 14:19:50]     [C]: in function 'doPlayerAddItem'
[18/09/2014 14:19:50]     data/talkactions/scripts/bpsd.lua:16: in function <data/talkactions/scripts/bpsd.lua:8>

What is that?:p

Also it is not working correctly.
Whenever I do !bpsd.. it does not say you do not have CAP to buy it, I have 40 cap on some char.. I say !bpsd.. and it gives me empty backpack. cuz I dont have more cap to get sd in it.

Also how to make it to say : You bought bp sd for 600.000gp gold? I mean so it says orange/green msg
 
Last edited by a moderator:
Code:
[18/09/2014 14:19:50] Lua Script Error: [TalkAction Interface]
[18/09/2014 14:19:50] data/talkactions/scripts/bpsd.lua:onSay
[18/09/2014 14:19:50] LuaScriptInterface::luaDoPlayerAddItem(). Item not found
[18/09/2014 14:19:50] stack traceback:
[18/09/2014 14:19:50]     [C]: in function 'doPlayerAddItem'
[18/09/2014 14:19:50]     data/talkactions/scripts/bpsd.lua:16: in function <data/talkactions/scripts/bpsd.lua:8>

What is that?:p

Also it is not working correctly.
Whenever I do !bpsd.. it does not say you do not have CAP to buy it, I have 40 cap on some char.. I say !bpsd.. and it gives me empty backpack. cuz I dont have more cap to get sd in it.

edit: fixed that error and now you get a message on the client (idk where did you want the message to appear) try it
Code:
local config = {
    price = 600000,
    bpId = 1988,
    runeId = 2275,
    countitems = 2000
}

function onSay(cid, words, param)
    local count = 1
    if isNumber(param) == TRUE then
        count = param
    end
    if doPlayerRemoveMoney(cid, config.price * count) == TRUE then
        for i = 1, count do
            local bag = doPlayerAddItem(cid, config.bpId, count)
            doAddContainerItem(bag, config.runeId, config.countitems)
            doSendMagicEffect(getPlayerPosition(cid), 12)
        end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You bought "..count.." bps of sds for "..count * config.price.." gold.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You need "..count * config.price.." gold to buy "..count.." bp of sd(s).")
        doSendMagicEffect(getPlayerPosition(cid), 2)
    end
    return TRUE
end

edit2: tabs
 
Last edited:
Hi again.
Now it is working thank you very much.
- No error anymore

I just used this for popping message:
Code:
cid, MESSAGE_INFO_DESCR
This is what is working now:
19:20 You bought 1 bps of sds for 600000 gold.
19:23 You need 600000 gold to buy 1 bp of sd(s).

But I still need a popping message that I need specific amount of CAP to carry this backpack. Because whenever I am typing the command !bpsd, and I do not have specific amount of capacity, it gives me an empty backpack.
 
Anybody know kow to do it?
I still need a popping message that I need specific amount of CAP to carry this backpack. Because whenever I am typing the command !bpsd, and I do not have specific amount of capacity, it gives me an empty backpack.
 
Try this:
Code:
local config = {
    price = 600000,
    bpId = 1988,
    runeId = 2275,
    countitems = 2000
}

function onSay(cid, words, param)
    local count = 1
    if(tonumber(param)) then
        count = param
    end
  
    if(getPlayerFreeCap(cid) <= (getItemWeight(config.bpId) * count)) then
        doPlayerSendCancel(cid, "Sorry, you do not have enough capacity.")
        return true
    end
  
    if(doPlayerRemoveMoney(cid, config.price * count)) then
        for i = 1, count do
            local bag = doPlayerAddItem(cid, config.bpId, count)
            doAddContainerItem(bag, config.runeId, config.countitems)
            doSendMagicEffect(getPlayerPosition(cid), 12)
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You bought " .. count .. " bps of sds for " .. count * config.price .. " gold.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You need " .. count * config.price .. " gold to buy " .. count .. " bp of sd(s).")
        doSendMagicEffect(getPlayerPosition(cid), 2)
    end
return true
end
 
Sadly it does not work.. it still gives as many runes as I can handle for my current amount of cap ;/

also it takes 600.000 gp gold, even if it gives me only half backpack of sd, cuz I dont have more cap to handle full.. lol =p but problem is it does not tell me how much cap I need to carry bp of sd
 
To make sure of what you are trying to do, you're buying more than 1 backpack at once, or are you buying X stack of runes and then putting it all in 1 single backpack?
 
This is script for bp sd.
Whenever I use command: !bpsd

I get full backpack of SD
J8-fe-8W.png

13:58 You see a backpack (Vol:20).
It weighs 1418.00 oz.
ItemID: [1988].
Position: [X: 32384] [Y: 32644] [Z: 7].

The problem is with CAP.. It does not check if someone is able to carry this bp.
whenever I have lets say 200 cap, I get as much runes as I can carry, sometimes even empty backpack.. and it still takes 600.000gp money
 
Try this

Code:
local config = {
price = 600000,
bpId = 1988,
runeId = 2275,
countitems = 2000
}

function onSay(cid, words, param)
if(getPlayerFreeCap(cid) <= (getItemWeight(config.runeId) * countitems)) then
doPlayerSendCancel(cid, "Sorry, you do not have enough capacity.")
return true
end

if doPlayerRemoveMoney(cid, config.price) then
local bag = doPlayerAddItem(cid, config.bpId, 1)
for i = 1, 20 do
doAddContainerItem(bag, config.runeId, 100)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You bought a backpack of sds for " .. config.price .. " gold.")
doSendMagicEffect(getPlayerPosition(cid), 12)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You need " .. config.price .. " gold to buy a backpack of sd(s).")
doSendMagicEffect(getPlayerPosition(cid), 2)
end
return true
end
 
This is script for bp sd.
Whenever I use command: !bpsd

I get full backpack of SD
J8-fe-8W.png

13:58 You see a backpack (Vol:20).
It weighs 1418.00 oz.
ItemID: [1988].
Position: [X: 32384] [Y: 32644] [Z: 7].

The problem is with CAP.. It does not check if someone is able to carry this bp.
whenever I have lets say 200 cap, I get as much runes as I can carry, sometimes even empty backpack.. and it still takes 600.000gp money
you can say !bpsd 2 and you will get 2 bps of sd
 
Try this

Code:
local config = {
price = 600000,
bpId = 1988,
runeId = 2275,
countitems = 2000
}

function onSay(cid, words, param)
if(getPlayerFreeCap(cid) <= (getItemWeight(config.runeId) * countitems)) then
doPlayerSendCancel(cid, "Sorry, you do not have enough capacity.")
return true
end

if doPlayerRemoveMoney(cid, config.price) then
local bag = doPlayerAddItem(cid, config.bpId, 1)
for i = 1, 20 do
doAddContainerItem(bag, config.runeId, 100)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You bought a backpack of sds for " .. config.price .. " gold.")
doSendMagicEffect(getPlayerPosition(cid), 12)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You need " .. config.price .. " gold to buy a backpack of sd(s).")
doSendMagicEffect(getPlayerPosition(cid), 2)
end
return true
end
ok im going to try it one sec
 
[22/09/2014 14:37:17] Lua Script Error: [TalkAction Interface]
[22/09/2014 14:37:17] data/talkactions/scripts/bpsd.lua:eek:nSay
[22/09/2014 14:37:17] data/talkactions/scripts/bpsd.lua:9: attempt to perform arithmetic on global 'countitems' (a nil value)
[22/09/2014 14:37:17] stack traceback:
[22/09/2014 14:37:17] [C]: in function '__mul'
[22/09/2014 14:37:17] data/talkactions/scripts/bpsd.lua:9: in function <data/talkactions/scripts/bpsd.lua:8>

not working :(
 
not working :(
My bad, wrote a variable the wrong way.

Code:
local config = {
price = 600000,
bpId = 1988,
runeId = 2275,
countitems = 2000
}

function onSay(cid, words, param)
if(getPlayerFreeCap(cid) <= (getItemWeight(config.runeId) * config.countitems)) then
doPlayerSendCancel(cid, "Sorry, you do not have enough capacity.")
return true
end

if doPlayerRemoveMoney(cid, config.price) then
local bag = doPlayerAddItem(cid, config.bpId, 1)
for i = 1, 20 do
doAddContainerItem(bag, config.runeId, 100)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You bought a backpack of sds for " .. config.price .. " gold.")
doSendMagicEffect(getPlayerPosition(cid), 12)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You need " .. config.price .. " gold to buy a backpack of sd(s).")
doSendMagicEffect(getPlayerPosition(cid), 2)
end
return true
end

should fix it.
 
Back
Top