Перейти к содержанию
ohgodboyyes

Автоматическая продажа еды и воды для магов

Рекомендуемые сообщения

1. не работает, когда вы афк.

2. невозможно украсть у вас что либо.

3. работает в общем и целом.

4. есть один баг, о котором я забыл.

5. можно продавать только еду, воду максимального уровня.

6. для работы необходим предмет который будет прыгать по всему трейд окну с неимоверной скоростью пока хомячки думают.

7. не вставляйте деньги.

8. Если кто-то кинет вам в трейд 80 голды вы автоматически примете предложение (тру стори)

9. Нужен супермакро последней версии.

10. слать НДС друиду корове с ником Simrahd на норздейле

Включение/выключение: TB_Toggle()

Вывод логов:

 TB_PrintLog(1)  - разница в голде

 TB_PrintLog(2)  - что вам нашептали

 

Настройки (вставьте в расширенный луа код для быстрого редактирования) (не забывайте сохранять для применения изменений)

TB_StackPrice = 5000 -- цена за стак (любой) в количестве медных монеток
TB_StackPriceString = "50 silver" -- (сообщение которое выводится через шепот)
TB_YellPriceString = "50s/20" -- (сообщение которое выводится через крик)
TB_CancelTime = 60 -- суммарное время через которое вы отмените трейд
TB_BanTime = 120 -- суммарное время через которое вы забаните человеку использование этой штуки
TB_LowLevelMaxTries = 4 -- а хз, не помню
TB_LowLevelStart = 53 -- минимальный уровень
TB_GroupDecline = true --true/false включить автомотическую отмену приглашений в группу/рейд
                                 
TB_MessageCooldown = 0.6 -- кд на сообщения (не меняйте)
TB_YellTime = 60      -- таймаут на крик
TB_EnableYell = true  --true/false включить автомотическую рекламу через крик    

TB_PlayThing = "INV_Misc_Book_02"  -- часть/полное название иконки предмета, который будет прыгать в инвентаре. (стандартно: Libram of Rapidity)
TB_ShoutString = "WTS 55 %s in front of AH (%s) /trade" -- фраза которая будет кричаться, первая %s - не менять, вторая - цена из сообщения выше    
 

код вставляется куда угодно. Можно в sm_extend.lua

Код:


function TB_AddMessage(message, owner, IsTrade, stage, CheckMoney)
  TB_MessagesCount = TB_MessagesCount + 1
  TB_Messages[1][TB_MessagesCount] = message 
  TB_Messages[2][TB_MessagesCount] = owner 
  TB_Messages[3][TB_MessagesCount] = IsTrade
  if stage == nil then stage = 0 end
  TB_Messages[4][TB_MessagesCount] = stage
  TB_Messages[5][TB_MessagesCount] = CheckMoney
end
function TB_CheckMsgs()
  if TB_MessagesCount > 0 then
    for i=1,TB_MessagesCount do
      if (TB_Messages[3][i] and TB_Messages[3][i] ~= TB_trading) or TB_Messages[4][i] < TB_phase then
        TB_Clear(i)
      else
        if TB_trading and TB_Messages[5][i] then
           if GetTargetTradeMoney() > 0 then      
             TB_Clear(i)
           end
        end
      end
    end
    local counter=1
    for i=1,TB_MessagesCount do 
      if TB_Messages[1][i]~= nil then
        if i > counter then
          TB_Messages[1][counter] = TB_Messages[1][i]
          TB_Messages[2][counter] = TB_Messages[2][i] 
          TB_Messages[3][counter] = TB_Messages[3][i]
          TB_Messages[4][counter] = TB_Messages[4][i]
          TB_Messages[5][counter] = TB_Messages[5][i]
        end
        counter = counter+1
      end
    end
    TB_MessagesCount=counter-1        
    if TB_MessagesCount >0 then                  
      local CurTime=GetTime()   
      if CurTime > TB_LastMsgTime + TB_MessageCooldown then
        SendChatMessage(TB_Messages[1][1],"WHISPER",GetDefaultLanguage("player"),TB_Messages[2][1]);
        TB_LastMsgTime = CurTime
        for i=1,TB_MessagesCount do 
          TB_Messages[1][i] = TB_Messages[1][i+1]
          TB_Messages[2][i] = TB_Messages[2][i+1] 
          TB_Messages[3][i] = TB_Messages[3][i+1]
          TB_Messages[4][i] = TB_Messages[4][i+1]
          TB_Messages[5][i] = TB_Messages[5][i+1]
        end     
        TB_MessagesCount=TB_MessagesCount-1
        if TB_MessagesCount >0 then 
          SM_IN(TB_MessageCooldown, "/run TB_CheckMsgs()")
        end
      else
        local time = TB_LastMsgTime + TB_MessageCooldown +0.05 - CurTime
        SM_IN(time, "/run TB_CheckMsgs()")
      end
    end
  end
end
       
function TB_Clear(num) 
  TB_Messages[1][num] = nil 
  TB_Messages[2][num] = "" 
  TB_Messages[3][num] = nil 
  TB_Messages[4][num] = 0 
  TB_Messages[5][num] = nil 
end
   
function TB_ClearMsgs() 
  if TB_MessagesCount > 0 then for i=1,TB_MessagesCount do TB_Clear(i)end end
  TB_MessagesCount=0
end           
                                                               
-- Flags
TB_status = nil
TB_trading = nil      
TB_phase = nil   
TB_nofood = nil    
TB_nowater = nil    
-- 1 - waiting for response 2 - waiting for response + possible accept 3 - waiting for money 

-- Settings

TB_StackPrice = 5000
TB_StackPriceString = "50 silver"
TB_YellPriceString = "50s/20"
TB_CancelTime = 60
TB_BanTime = 120
TB_LowLevelMaxTries = 4
TB_LowLevelStart = 53
TB_GroupDecline = true
                                 
TB_MessageCooldown = 0.6
TB_YellTime = 60
TB_EnableYell = true     

TB_FoodName = "INV_Misc_Food_73CinnamonRoll"
TB_WaterName = "INV_Drink_18" 
TB_PlayThing = "INV_Misc_Book_02"  
TB_ShoutString = "WTS 55 %s in front of AH (%s) /trade"    

-- Trade info
TB_owner = ""                
TB_OwnerHasMana = nil
TB_ItemCount = 0                                                            
TB_TradeShowTime = 0
TB_SucTrade = nil   
TB_LastYellTime = 0
TB_LastPlayIndex = nil
TB_LastPlayTime = 0
TB_PlayPeriod = 0.25    
TB_LastMsgTime = 0

TB_Messages = {}  
TB_Messages[1] = {} 
TB_Messages[2] = {} 
TB_Messages[3] = {} 
TB_Messages[4] = {} 
TB_Messages[5] = {}             
TB_MessagesCount = 0

-- db info 
TB_TimeTaken = {}
TB_TimeTakenName = {}
TB_TimeTakenCount = 0 

TB_WhisperMsgs = {}
TB_WhisperNames = {}
TB_WhisperCount = 0

TB_LowLevelTries = {}
TB_LowLevelNames = {}
TB_LowLevelCount = 0

TB_SuccTrades = 0
TB_GoldFarmed = 0
TB_StartGold = 0

TB_enumNumbers = {"1","2","3","4","5","6"}
TB_enumNumbers2 = {"one","two","three","four","five","six"}

function TB_Toggle()                            
  if not TB_status then
    if not TradeBotFrame then TB_Load()
    else 
      TB_status=true
      TB_trading = nil  
      TB_LastYellTime = 0   
      TradeBotYell:Show();
    end
    Print("TradeBot Enabled")
  else
    TB_status=nil  
    TB_trading = nil  
    TradeBotTimer:Hide();
    TradeBotPlay:Hide();
    TradeBotYell:Hide();    
    Print("TradeBot Disabled")
  end
end 
function TB_Load()    
  TB_status=true
  TB_trading = nil 
  TB_StartGold = GetMoney()   
  TradeBotFrame = CreateFrame("FRAME", "TradeBotEvents");      
  TradeBotFrame:RegisterEvent("CHAT_MSG_SYSTEM");       
  TradeBotFrame:RegisterEvent("TRADE_SHOW");
  TradeBotFrame:RegisterEvent("TRADE_CLOSED");
  TradeBotFrame:RegisterEvent("TRADE_ACCEPT_UPDATE")
  TradeBotFrame:RegisterEvent("TRADE_MONEY_CHANGED");
  TradeBotFrame:RegisterEvent("CHAT_MSG_SAY");                          
  TradeBotFrame:RegisterEvent("CHAT_MSG_WHISPER");
  TradeBotFrame:RegisterEvent("PARTY_INVITE_REQUEST");
  TradeBotFrame:SetScript("OnEvent", TradeBotEventHandler);    
  TradeBotTimer = CreateFrame("FRAME", "TradeBotTimer");             
  TradeBotTimer:SetScript("OnUpdate", TradeBotTimer_OnUpdate);    
  TradeBotPlay = CreateFrame("FRAME", "TradeBotPlay");              
  TradeBotPlay:SetScript("OnUpdate", TradeBotPlay_OnUpdate);                
  TradeBotYell = CreateFrame("FRAME", "TradeBotYell");             
  TradeBotYell:SetScript("OnUpdate", TradeBotYell_OnUpdate);
  TradeBotYell:Show();
end                         

function TradeBotTimer_OnUpdate()                       
  if TB_status then
    if TB_trading then
       if GetTime() > TB_TradeShowTime + TB_CancelTime then       
          CancelTrade()
       end
    end 
  end
end      

function TradeBotYell_OnUpdate()
  if TB_status then
    if TB_EnableYell then
       if not TB_trading then 
          if GetTime() > TB_YellTime + TB_LastYellTime then
            local foodnum, waternum = TB_GetStock()
            if foodnum + waternum > 0 then
              if foodnum == 0 then
                SendChatMessage(string.format(TB_ShoutString, "water",TB_YellPriceString) ,"YELL",GetDefaultLanguage("player"));
              elseif waternum == 0 then
                SendChatMessage(string.format(TB_ShoutString, "food",TB_YellPriceString) ,"YELL",GetDefaultLanguage("player"));
              else 
                SendChatMessage(string.format(TB_ShoutString, "water/food",TB_YellPriceString) ,"YELL",GetDefaultLanguage("player"));
              end           
              SM_IN(2,'/run TargetNearestFriend()DoEmote("dance")ClearTarget()')
              TB_LastMsgTime = GetTime()
            end
            TB_LastYellTime=GetTime();
          end
       end
    end 
  end
end       

function TB_CalcMoney(index)
   local summ=0
   for i=1,index do                   
     summ= summ + 7*math.pow(10,i-1)
   end
   return summ
end

function TradeBotPlay_OnUpdate()
  if TB_phase == 1 and GetTime()> TB_LastPlayTime + TB_PlayPeriod then
    if not TB_LastPlayIndex then 
      local a,b=nil,nil                 
      local name, count
      for i=0,4 do
        for g=1,GetContainerNumSlots(i)do
          name,count=GetContainerItemInfo(i,g)
          if name then 
            if string.find(name,TB_PlayThing)then
              a=i
              b=g
            end
          end
        end
      end
      if a then
        PickupContainerItem(a,b)
        ClickTradeButton(1) 
        TB_LastPlayIndex=1  
        TB_LastPlayTime=GetTime()  
        SetTradeMoney(TB_CalcMoney(TB_LastPlayIndex))  
      else
        Print("WTFLOL")
        TB_CancelPlay()
      end                          
    else
      ClickTradeButton(TB_LastPlayIndex) 
      TB_LastPlayIndex=TB_LastPlayIndex+1
      if TB_LastPlayIndex>6 then TB_LastPlayIndex=1 end     
      ClickTradeButton(TB_LastPlayIndex) 
      TB_LastPlayTime=GetTime()
      SetTradeMoney(TB_CalcMoney(TB_LastPlayIndex))   
    end
  end                  --
end                             
 
function TradeBotEventHandler()
  if not TB_status then return                     
  elseif event == "CHAT_MSG_SYSTEM" then
    if arg1 then
      if string.find(arg1, "Вы отошли от компьютера, оставив сообщение")then
        TB_Toggle() 
        if TB_trading then
          TB_AddMessage("Sorry, my owner is afk" ,TB_owner , nil,10); 
          CloseTrade();
        end
      end
    end
                                          
  elseif event == "TRADE_SHOW" then
                         
    TB_ItemMoney = 0     
    TB_SucTrade = nil    
    TB_ItemCount = 0    
    TB_owner = UnitName("npc")
    local _,class = UnitClass("npc")
    TB_OwnerHasMana = string.find("PALADIN HUNTER PRIEST SHAMAN MAGE WARLOCK DRUID",class) 
    if TB_owner == nil then Print("OMG owner == nil")end
    
    if UnitLevel("npc")<TB_LowLevelStart then 
      local ExName, ban = nil,nil
      for i=1,TB_LowLevelCount do
        if TB_LowLevelNames[i]== TB_owner then
          ExName = i
        end 
      end
      if ExName then
        TB_LowLevelTries[ExName] = TB_LowLevelTries[ExName]+1
        if TB_LowLevelTries[ExName] >= TB_LowLevelMaxTries then ban = "YES" end
      else
        TB_LowLevelCount = TB_LowLevelCount+1
        TB_LowLevelTries[TB_LowLevelCount] = 1  
        TB_LowLevelNames[TB_LowLevelCount] = TB_owner
      end
      if ban then SM_IN(0.5, "/run CancelTrade()TargetByName('"..TB_owner.."')DoEmote('spit')AddIgnore('"..TB_owner.."')") 
      else 
        SM_IN(0.5, "/run CancelTrade()")
        SendChatMessage("I'm not selling low level stuff nor portals right now" ,"WHISPER",GetDefaultLanguage("player"),TB_owner);
      end 
    else
      local foodnum, waternum = TB_GetStock()
      if foodnum+waternum == 0 then
        SendChatMessage("Sorry, we're out of stock" ,"WHISPER",GetDefaultLanguage("player"),TB_owner);        
        SM_IN(0.5, "/run CancelTrade()") 
      else      
        TB_trading = 1                                                                                 
        TB_phase = 1    
        TB_AddMessage("Welcome to Snack Dispenser :D I have: ".. foodnum .. " stacks of food and " .. waternum .. " stacks of water. Price: ".. TB_StackPriceString .. " for each stack",TB_owner,TB_trading,TB_phase+10);  
        if TB_GroupDecline then  
         TB_AddMessage("Remember! I am not selling portals right now",TB_owner,TB_trading,TB_phase+10);
        end                                
        if foodnum==0 then
          TB_nofood=true                   
          if waternum>6 then waternum=6 end           
          TB_AddMessage("Please, select how many stacks of water would you like (1-"..waternum..")",TB_owner,TB_trading,TB_phase);
        elseif TB_OwnerHasMana and waternum>0 then   
          if waternum>6 then waternum=6 end
          TB_AddMessage("Please, select how many stacks of water would you like (1-"..waternum..")",TB_owner,TB_trading,TB_phase);
        elseif waternum==0 then  
          TB_nowater=true            
          if foodnum>6 then foodnum=6 end                                                            
          TB_AddMessage("Please, select how many stacks of food would you like (1-"..foodnum..")",TB_owner,TB_trading,TB_phase);
        else
          if foodnum>6 then foodnum=6 end                                                                         
          TB_AddMessage("Please, select how many stacks of food would you like (0-"..foodnum..")",TB_owner,TB_trading,TB_phase);
        end         
        TB_CheckMsgs()
        TB_LastPlayIndex = nil 
        TB_LastPlayTime=GetTime()   
        TradeBotPlay:Show()
      end                   
    end     
    TB_TradeShowTime = GetTime()-0.5
		TradeBotTimer:Show();
    
  elseif event == "TRADE_CLOSED" then  
    if not TB_SucTrade and TB_trading and TB_owner then
      SendChatMessage("Goodbye" ,"WHISPER",GetDefaultLanguage("player"),TB_owner);
    end                  
    local time = GetTime()
    if TB_trading and not TB_SucTrade and TB_owner then       
      local ExName, ban = nil,nil
      for i=1,TB_TimeTakenCount do
        if TB_TimeTakenName[i]== TB_owner then
          ExName = i
        end 
      end
      if ExName then
         Printd("prev time: "..TB_TimeTaken[ExName])
         TB_TimeTaken[ExName] = TB_TimeTaken[ExName]+time-TB_TradeShowTime 
      else                                    
        Printd("prev time: 0")
        TB_TimeTakenCount = TB_TimeTakenCount+1                                      
        ExName = TB_TimeTakenCount              
        TB_TimeTaken[ExName] = time-TB_TradeShowTime 
        TB_TimeTakenName[ExName] = TB_owner           
      end
      Printd("curr time: "..TB_TimeTaken[ExName])
      if TB_TimeTaken[ExName] > TB_BanTime then
        TargetByName(TB_owner)
        DoEmote("spit")
        AddIgnore(TB_owner)
      end
    end
    TB_trading = nil                                                         
    TB_TradeShowTime = 0
    TB_SucTrade = nil
    TradeBotTimer:Hide();
    TradeBotPlay:Hide()     
    if TB_LastYellTime + TB_YellTime + TB_MessageCooldown < time then
      TB_LastYellTime = time - TB_YellTime + TB_MessageCooldown
    end
    
  elseif event == "TRADE_ACCEPT_UPDATE" then  
    if TB_trading then 
      if arg1==1 and arg2==1 then 
      TB_SucTrade = 1
      TB_SuccTrades = TB_SuccTrades+1
      TB_GoldFarmed = TB_GoldFarmed+ TB_ItemCount*TB_StackPrice/10000                               
      TB_AddMessage("Understandable, Have a Nice Day",TB_owner,nil,10);
      TargetByName(TB_owner)              
      DoEmote("dance")
      ClearTarget() 
      end
      if arg1==0 and arg2==1 and TB_phase >1 then
        if GetTargetTradeMoney()>=TB_ItemCount * TB_StackPrice  then 
           AcceptTrade() 
        elseif GetTargetTradeMoney() == 0 and TB_ItemCount>0 then                                                       
         TB_AddMessage("Where's my money ???",TB_owner,nil,TB_phase,1);
        end
      end      
      TB_CheckMsgs()                                                    
    end 
  elseif event == "TRADE_MONEY_CHANGED" then 
    if TB_trading then 
      if TB_phase >1 and GetTargetTradeMoney()>=TB_ItemCount * TB_StackPrice then
        AcceptTrade()
      end   
    end               
    
    
    

  elseif event == "CHAT_MSG_SAY" or event == "CHAT_MSG_WHISPER" then  
  
    if TB_trading and arg2 == TB_owner then
      local foodnum, waternum = TB_GetStock()
      local LegitMsg=nil
      local checknum=0
      if string.find(string.lower(arg1),"0") or string.find(string.lower(arg1),"zero") or string.find(string.lower(arg1),"null") then LegitMsg=0 end
      for i=1,6 do
        if string.find(string.lower(arg1),TB_enumNumbers[i]) or string.find(string.lower(arg1),TB_enumNumbers2[i]) then LegitMsg=i checknum=i end 
      end
        
      if TB_phase == 1 then   
        if LegitMsg and (LegitMsg~=0 or ((not TB_nofood and not TB_OwnerHasMana) or (not TB_nowater and TB_OwnerHasMana))) then
          TB_CancelPlay()
          TB_ItemCount=LegitMsg                         
          local gold, silver = 0,0
          silver = math.mod(TB_ItemCount*TB_StackPrice,10000)/100
          gold = math.floor(TB_ItemCount*TB_StackPrice/10000)
          local tempmsg = "Please, "            
          local msg = TB_GetMsg(gold, silver) 
          if LegitMsg and checknum>0 and string.find(string.lower(arg1),"each") then      
            TB_phase=3                                   
            if LegitMsg > 3 then LegitMsg=3 end
            if foodnum > LegitMsg then foodnum = LegitMsg end 
            if waternum > LegitMsg then waternum = LegitMsg end 
            TB_ItemCount= foodnum + waternum 
            silver = math.mod(TB_ItemCount*TB_StackPrice,10000)/100
            gold = math.floor(TB_ItemCount*TB_StackPrice/10000)   
            msg = TB_GetMsg(gold, silver)                     
            TB_AddMessage("You have selected ".. foodnum .. " stacks of food and ".. waternum.. " stacks of water. Cancel the trade if you made a mistake",TB_owner,TB_trading,TB_phase);
            TB_AddMessage(tempmsg..msg,TB_owner,TB_trading,TB_phase);
            if foodnum > 0 then TB_InsertFood(foodnum)end
            if waternum > 0 then TB_InsertWater(waternum,foodnum)end                             
          else
            if LegitMsg and checknum>0 and string.find(string.lower(arg1),"water") and not TB_OwnerHasMana then                
              TB_phase=3               
              TB_AddMessage("You have selected ".. LegitMsg .. " stacks of water. Cancel the trade if you made a mistake",TB_owner,TB_trading,TB_phase);
              TB_AddMessage(tempmsg..msg,TB_owner,TB_trading,TB_phase);
              TB_InsertWater(TB_ItemCount)
            elseif LegitMsg and checknum>0 and string.find(string.lower(arg1),"food") and TB_OwnerHasMana then        
              TB_phase=3       
              TB_AddMessage("You have selected ".. LegitMsg .. " stacks of food. Cancel the trade if you made a mistake",TB_owner,TB_trading,TB_phase);
              TB_AddMessage(tempmsg..msg,TB_owner,TB_trading,TB_phase);           
              TB_InsertFood(TB_ItemCount) 
            else
              if TB_nofood then                             -- if each elseif water else -----        
                TB_phase=3                    
                TB_AddMessage("You have selected ".. LegitMsg .. " stacks of water. Cancel the trade if you made a mistake",TB_owner,TB_trading,TB_phase);
                TB_AddMessage(tempmsg..msg,TB_owner,TB_trading,TB_phase);
                TB_InsertWater(TB_ItemCount)
              elseif TB_OwnerHasMana then        
                if TB_nowater then
                  TB_phase=3             
                  TB_AddMessage("You have selected ".. LegitMsg .. " stacks of food. Cancel the trade if you made a mistake",TB_owner,TB_trading,TB_phase); 
                  TB_AddMessage(tempmsg..msg,TB_owner,TB_trading,TB_phase);    
                  TB_InsertFood(TB_ItemCount) 
                else                   
                  if TB_ItemCount> 0 then TB_InsertWater(TB_ItemCount)end
                  if foodnum==0  then         
                    TB_phase=3                 
                    TB_AddMessage("You have selected ".. LegitMsg .. " stacks of water. Cancel the trade if you made a mistake",TB_owner,TB_trading,TB_phase); 
                    TB_AddMessage(tempmsg..msg,TB_owner,TB_trading,TB_phase); 
                  else
                    TB_phase=2
                    TB_AddMessage("You have selected ".. LegitMsg .. " stacks of water. Cancel the trade if you made a mistake",TB_owner,TB_trading,TB_phase); 
                    tempmsg2= "0"
                    if TB_ItemCount == 0 then tempmsg2 = "1" end 
                    local maxavail = 6 - TB_ItemCount
                    if maxavail>foodnum then maxavail=foodnum end   
                    if maxavail > 0 then
                      TB_AddMessage("Please, select how many stacks of food would you like ("..tempmsg2.."-"..maxavail .. ")",TB_owner,TB_trading,TB_phase);      
                      if TB_ItemCount> 0 then TB_AddMessage("or "..msg,TB_owner,TB_trading,TB_phase);  end
                    else
                       TB_AddMessage(tempmsg..msg,TB_owner,TB_trading,TB_phase); 
                    end  
                  end
                end                
              else         
                if waternum==0 then
                  TB_phase=3             
                  TB_AddMessage("You have selected ".. LegitMsg .. " stacks of food. Cancel the trade if you made a mistake",TB_owner,TB_trading,TB_phase); 
                  TB_AddMessage(tempmsg..msg,TB_owner,TB_trading,TB_phase); 
                else
                  TB_phase=2
                  tempmsg2= "0"
                  if TB_ItemCount == 0 then tempmsg2 = "1" end 
                  local maxavail = 6 - TB_ItemCount
                  if maxavail>waternum then maxavail=waternum end   
                  TB_AddMessage("You have selected ".. LegitMsg .. " stacks of food. Cancel the trade if you made a mistake",TB_owner,TB_trading,TB_phase); 
                  if maxavail > 0 then
                    TB_AddMessage("Please, select how many stacks of water would you like ("..tempmsg2.."-"..maxavail .. ")",TB_owner,TB_trading,TB_phase);      
                    if TB_ItemCount> 0 then TB_AddMessage("or "..msg,TB_owner,TB_trading,TB_phase);  end
                  else
                     TB_AddMessage(tempmsg..msg,TB_owner,TB_trading,TB_phase); 
                  end  
                end                
                if TB_ItemCount> 0 then TB_InsertFood(TB_ItemCount)end
              end    
            end
          end      
        else      
           if string.find(string.lower(arg1),"water") and not TB_OwnerHasMana then   
            TB_CancelPlay()
            TB_phase=2
            if waternum>6 then waternum=6 end
            TB_AddMessage("Please, select how many stacks of water would you like (1-".. waternum .. ")",TB_owner,TB_trading,TB_phase)
           elseif string.find(string.lower(arg1),"food") and TB_OwnerHasMana then   
            TB_CancelPlay()
            TB_phase=2
            if foodnum>6 then foodnum=6 end
            TB_AddMessage("Please, select how many stacks of food would you like (1-".. foodnum .. ")",TB_owner,TB_trading,TB_phase)
           else  
             TB_AddMessage("Please, select a correct number",TB_owner,TB_trading,TB_phase)
           end
        end                                   
        
      elseif TB_phase == 2  then 
          if LegitMsg and LegitMsg~=0 and LegitMsg + TB_ItemCount <= 6 then  
            TB_ItemCount = TB_ItemCount + LegitMsg     
            TB_phase=3            
            local gold, silver = 0,0
            silver = math.mod(TB_ItemCount*TB_StackPrice,10000)/100
            gold = math.floor(TB_ItemCount*TB_StackPrice/10000)
            local tempmsg = "Please, "            
            local msg = TB_GetMsg(gold, silver) 
            if TB_OwnerHasMana then
              TB_AddMessage("You have selected ".. LegitMsg .. " stacks of food. Cancel the trade if you made a mistake",TB_owner,TB_trading,TB_phase); 
              TB_AddMessage(tempmsg..msg,TB_owner,TB_trading,TB_phase); 
              if LegitMsg>0 then TB_InsertFood(LegitMsg, TB_ItemCount - LegitMsg )end   
            else
              TB_AddMessage("You have selected ".. LegitMsg .. " stacks of water. Cancel the trade if you made a mistake",TB_owner,TB_trading,TB_phase); 
              TB_AddMessage(tempmsg..msg,TB_owner,TB_trading,TB_phase); 
              if LegitMsg>0 then TB_InsertWater(LegitMsg, TB_ItemCount - LegitMsg )end    
            end
          elseif TB_ItemCount < 6 then                                       
            TB_AddMessage("Please, select a correct NUMBER",TB_owner,TB_trading,TB_phase); 
          end 
        
      elseif TB_phase == 3 then
      
      end   
      TB_CheckMsgs()
    end                                    
    if event == "CHAT_MSG_WHISPER" then 
      TB_WhisperCount = TB_WhisperCount +1
      TB_WhisperMsgs[TB_WhisperCount] = arg1
      TB_WhisperNames[TB_WhisperCount] = arg2
    end
  elseif event == "PARTY_INVITE_REQUEST" then  
    if TB_GroupDecline then
      SM_IN(0.3,"/run DeclineGroup()")
    end
  end 
  
end  

function TB_PrintLog(index)               
  if index == 0 or index == 1 then
    Printd("Successful trades: "..TB_SuccTrades..", gold farmed: "..TB_GoldFarmed.." g, difference: "..(GetMoney()-TB_StartGold)/10000 .. " g")
  end   
  if index == 0 or index == 2 then
    for i = 1 , TB_WhisperCount do
      Printd(TB_WhisperNames[i]..": "..TB_WhisperMsgs[i])  
    end 
  end
  if index == 0 or index == 3 then 
    for i = 1 , TB_TimeTakenCount do
      Printd(TB_TimeTakenName[i]..": "..TB_TimeTaken[i])  
    end 
  end
  if index == 0 or index == 4 then
    for i = 1 , TB_LowLevelCount do
      Printd(TB_LowLevelNames[i]..": "..TB_LowLevelTries[i])  
    end 
  end        
end 

function TB_ResetLog(index)               
  if index == 0 or index == 1 then
    TB_SuccTrades=0
    TB_GoldFarmed=0
    TB_StartGold=GetMoney()
  end   
  if index == 0 or index == 2 then
    for i = 1 , TB_WhisperCount do
      TB_WhisperNames[i]=0
      TB_WhisperMsgs[i]=0  
    end 
    TB_WhisperCount=0
  end
  if index == 0 or index == 3 then 
    for i = 1 , TB_TimeTakenCount do
      TB_TimeTakenName[i]=0
      TB_TimeTaken[i]=0  
    end 
    TB_TimeTakenCount=0
  end
  if index == 0 or index == 4 then
    for i = 1 , TB_LowLevelCount do
      TB_LowLevelNames[i]=0
      TB_LowLevelTries[i]=0 
    end 
    TB_LowLevelCount=0
  end        
end 

function TB_GetStock()
  local a,b=0,0                 
  local name, count
  for i=0,4 do
    for g=1,GetContainerNumSlots(i)do
      name,count=GetContainerItemInfo(i,g)
      if name then
        if string.find(name,TB_FoodName) and count==20 then
          a=a+1
        end
        if string.find(name,TB_WaterName) and count==20 then
          b=b+1
        end
      end
    end
  end
  return a,b;     
end

function TB_GetMsg(gold, silver)
  local msg = ""
  if gold>0 then
    if silver >0 then
      msg = "insert ".. gold .. " g " .. silver .. " s  and accept trade to proceed"
    else
      msg = "insert ".. gold .. " g and accept trade to proceed"
    end
  else
    msg="insert ".. silver .. " s and accept trade to proceed"
  end
  return msg
end
                            
function TB_A(num,num2)    
  if num ~= 0 and num ~= nil then TB_InsertWater(num) end
  if num2 ~= 0 and num2 ~= nil then TB_InsertFood(num2,num) end  
end            
    
function TB_InsertFood(num,num2)      
  if num2==nil then num2=0 end 
  local c=num2                 
  local name,count
  if num ~= 0 and num ~= nil then
    for i=0,4 do
      for g=1,GetContainerNumSlots(i)do
        name,count=GetContainerItemInfo(i,g)
        if name then
          if string.find(name,TB_FoodName) and count==20 then    
            c=c+1
            PickupContainerItem(i,g)
            ClickTradeButton(c)
            if c-num2>=num then return end
          end
        end
      end
    end      
  end    
end                    
function TB_InsertWater(num,num2)  -- /run TB_InsertWater(
  if num2==nil then num2=0 end 
  local c=num2              
  local name, count    
  if num ~= 0 and num ~= nil then   
    for i=0,4 do
      for g=1,GetContainerNumSlots(i)do
        name,count=GetContainerItemInfo(i,g)
        if name then
          if string.find(name,TB_WaterName) and count==20 then
            c=c+1                          
            PickupContainerItem(i,g)
            ClickTradeButton(c)
            if c-num2>=num then return end
          end
        end
      end
    end     
  end
end

function TB_CancelPlay()
  if TB_LastPlayIndex then
    PutItemInBackpack() 
    ClickTradeButton(TB_LastPlayIndex)   
    PutItemInBackpack() 
  end               
  TradeBotPlay:Hide();      
   SetTradeMoney(0)
end

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Для публикации сообщений создайте учётную запись или авторизуйтесь

Вы должны быть пользователем, чтобы оставить комментарий

Создать учетную запись

Зарегистрируйте новую учётную запись в нашем сообществе. Это очень просто!

Регистрация нового пользователя

Войти

Уже есть аккаунт? Войти в систему.

Войти

  • Последние посетители   0 пользователей онлайн

    Ни одного зарегистрированного пользователя не просматривает данную страницу

Официальный сайт сообщества
Официальный сайт игры
×
×
  • Создать...