• 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 Help with small change script

therrax

Member
Joined
Jul 12, 2012
Messages
262
Solutions
1
Reaction score
11
This script sell mount immediately.
You lost "..t.price.." gp! for mount!"
How to add request for example?
"Want you pay x for y mount?"
Please need help :(
Code:
local table = {
    ["Widow Queen"] = {price = 0, id = 1},
    ["Racing Bird"] = {price = 0, id = 2},
    ["War Bear"] = {price = 0, id = 3},
    ["Black Sheep"] = {price = 0, id = 4},
    ["Midnight Panther"] = {price = 0, id = 5},
    ["Draptor"] = {price = 0, id = 6},
    ["Titanica"] = {price = 0, id = 7},
    ["Tin Lizzard"] = {price = 0, id = 8},
    ["Blazebringer"] = {price = 0, id = 9},
    ["Rapid Boar"] = {price = 0, id = 10},
    ["Stampor"] = {price = 0, id = 11},
    ["Undead Cavebear"] = {price = 0, id = 12}
}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)          npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                  npcHandler:onThink()                    end

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     if table[msg] then
      local t = table[msg]
      talkState[talkUser] = 1
       if getPlayerPremiumDays(cid) >= 1 then
        if not getPlayerMount(cid, t.id) then
         if doPlayerRemoveMoney(cid, t.cena) then
          doPlayerAddMount(cid, t.id)
          selfSay("You lost "..t.price.." gp! for mount!", cid)
          talkState[talkUser] = 0
         else
          selfSay("Sorry, you do not have enough money!", cid)
          talkState[talkUser] = 0
         end
        else
         selfSay("You already have this mount!", cid)
         talkState[talkUser] = 0
        end
       else
        selfSay("You must be Premium!", cid)
        talkState[talkUser] = 0
       end
    else
    selfSay('What? Please told me a correct name of mount!', cid)
    talkState[talkUser] = 0
   end
   return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
local table = {
  ["Widow Queen"] = {price = 0, id = 1},
  ["Racing Bird"] = {price = 0, id = 2},
  ["War Bear"] = {price = 0, id = 3},
  ["Black Sheep"] = {price = 0, id = 4},
  ["Midnight Panther"] = {price = 0, id = 5},
  ["Draptor"] = {price = 0, id = 6},
  ["Titanica"] = {price = 0, id = 7},
  ["Tin Lizzard"] = {price = 0, id = 8},
  ["Blazebringer"] = {price = 0, id = 9},
  ["Rapid Boar"] = {price = 0, id = 10},
  ["Stampor"] = {price = 0, id = 11},
  ["Undead Cavebear"] = {price = 0, id = 12}
}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)  npcHandler:onCreatureAppear(cid)  end
function onCreatureDisappear(cid)  npcHandler:onCreatureDisappear(cid)  end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg)  end
function onThink()  npcHandler:onThink()  end

function creatureSayCallback(cid, type, msg)
     if(not npcHandler:isFocused(cid)) then
         return false
     end

     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
   
     local t = table[msg]
     if t then
         selfSay("Do you want to pay "..t.price.." for "..msg.." mount?", cid)
         talkState[talkUser] = 1
         xmsg = msg
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         t = table[xmsg]
         if getPlayerPremiumDays(cid) >= 1 then
             if not getPlayerMount(cid, t.id) then
                 if doPlayerRemoveMoney(cid, t.price) then
                     doPlayerAddMount(cid, t.id)
                     selfSay("You lost "..t.price.." gp! for mount!", cid)
                 else
                     selfSay("Sorry, you do not have enough money!", cid)
                 end
             else
                 selfSay("You already have this mount!", cid)
             end
         else
             selfSay("You must be Premium!", cid)
         end
         talkState[talkUser] = 0
     else
         selfSay('What? Please told me a correct name of mount!', cid)
         talkState[talkUser] = 0
     end
     return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top