• 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 NPC error.

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
Ignore the title, because before it was a mistake and got put away , but now I have the following questions :

How do I add extra options ?
Example:

When I say "trade" to the NPC, then "trade" got 2 modal options:
"Buy";
"Sell";

Then "Buy" got new sub-options:
"Buy" > "Spear";
"Buy" > "Arrow";

How to do this?
Script:
Code:
function onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent("ferris_zepistekar_modal")
    local spear = 2389
    if modalWindowId == 97171401 then
        if buttonId == 100 then
      

            if choiceId == 1 then
                local valor = 10
                local quantidade = 1
                if player:getMoney() >= valor then
                    if getGlobalStorageValue(Ferris_Zepistekar_Spear) >= quantidade then
                        setGlobalStorageValue(Ferris_Zepistekar_Spear, getGlobalStorageValue(Ferris_Zepistekar_Spear)-quantidade)
                        player:addItem(spear, quantidade)
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "Voce comprou ".. quantidade .. " spear. A loja ainda tem ".. getGlobalStorageValue(Ferris_Zepistekar_Spear) .." spears sobrando.")
                        player:removeMoney(valor)
                    else
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "O estoque da loja esta em ".. getGlobalStorageValue(Ferris_Zepistekar_Spear) .." spears.")
                    end
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Voce precisa ter no minimo ".. valor .." gold coins para comprar.")
                end
      

            elseif choiceId == 2 then
                local valor = 50
                local quantidade = 5
                if player:getMoney() >= valor then
                    if getGlobalStorageValue(Ferris_Zepistekar_Spear) >= quantidade then
                        setGlobalStorageValue(Ferris_Zepistekar_Spear, getGlobalStorageValue(Ferris_Zepistekar_Spear)-quantidade)
                        player:addItem(spear, quantidade)
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "Voce comprou ".. quantidade .. " spears. A loja ainda tem ".. getGlobalStorageValue(Ferris_Zepistekar_Spear) .." spears sobrando.")
                        player:removeMoney(valor)
                    else
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "O estoque da loja esta em ".. getGlobalStorageValue(Ferris_Zepistekar_Spear) .." spears.")
                    end
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Voce precisa ter no minimo ".. valor .." gold coins para comprar.")
                end
      

            elseif choiceId == 3 then
                local valor = 100
                local quantidade = 10
                if player:getMoney() >= valor then
                    if getGlobalStorageValue(Ferris_Zepistekar_Spear) >= quantidade then
                        setGlobalStorageValue(Ferris_Zepistekar_Spear, getGlobalStorageValue(Ferris_Zepistekar_Spear)-quantidade)
                        player:addItem(spear, quantidade)
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "Voce comprou ".. quantidade .. " spears. A loja ainda tem ".. getGlobalStorageValue(Ferris_Zepistekar_Spear) .." spears sobrando.")
                        player:removeMoney(valor)
                    else
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "O estoque da loja esta em ".. getGlobalStorageValue(Ferris_Zepistekar_Spear) .." spears.")
                    end
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Voce precisa ter no minimo ".. valor .." gold coins para comprar.")
                end


            elseif choiceId == 4 then
                local valor = 200
                local quantidade = 20
                if player:getMoney() >= valor then
                    if getGlobalStorageValue(Ferris_Zepistekar_Spear) >= quantidade then
                        setGlobalStorageValue(Ferris_Zepistekar_Spear, getGlobalStorageValue(Ferris_Zepistekar_Spear)-quantidade)
                        player:addItem(spear, quantidade)
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "Voce comprou ".. quantidade .. " spears. A loja ainda tem ".. getGlobalStorageValue(Ferris_Zepistekar_Spear) .." spears sobrando.")
                        player:removeMoney(valor)
                    else
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "O estoque da loja esta em ".. getGlobalStorageValue(Ferris_Zepistekar_Spear) .." spears.")
                    end
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Voce precisa ter no minimo ".. valor .." gold coins para comprar.")
                end


                elseif choiceId == 5 then
                local valor = 400
                local quantidade = 40
                if player:getMoney() >= valor then
                    if getGlobalStorageValue(Ferris_Zepistekar_Spear) >= quantidade then
                        setGlobalStorageValue(Ferris_Zepistekar_Spear, getGlobalStorageValue(Ferris_Zepistekar_Spear)-quantidade)
                        player:addItem(spear, quantidade)
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "Voce comprou ".. quantidade .. " spears. A loja ainda tem ".. getGlobalStorageValue(Ferris_Zepistekar_Spear) .." spears sobrando.")
                        player:removeMoney(valor)
                    else
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "O estoque da loja esta em ".. getGlobalStorageValue(Ferris_Zepistekar_Spear) .." spears.")
                    end
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "Voce precisa ter no minimo ".. valor .." gold coins para comprar.")
                end
            end
        end
    end
end

I want to make this smaller and more practical script.
I created the basics, is already working, but would like to add those extra options I mentioned.
 
Last edited:
Choose:
#1 Buy
#2 Sell

If "Buy" then
#1 choice: spear
#2 choice: arrow

If "Sell" then
#1 choice: spear
#2 choice: crossbow
#2 choice: bow
 
Last edited:
Back
Top