Help whit Bandit script!
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Help whit Bandit script!

Started by WickeD, 30 January, 2004, 14:26:13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

WickeD

Can eny one write this script so if eny user type a command in main chat from this scripts commands, the typed command only will bee showed to the user that type it!

This is the script:
----------------------------------------------------------------------
--One Armed Bandit by chill
--Stops on command

bot = "[BOT]Bandit"

BPrefix = "!"
cmd1 = "insert"
cmd2 = "spin"
cmd3 = "stop"
cmd4 = "bstats"

BPlayers = {}
BSpin = {}
BPoints = {}
dofile("BPoints.txt")

scount = 0

function Main()
   SetTimer(1000)
   StartTimer()
end

function OnTimer()
   for i,v in BSpin do
      BSpin.Time = BSpin.Time + 1
      if BSpin.Time == 5 then
         doShowSpin(i)
      end
   end
   scount = scount +1
   if scount == 300 then
      WriteTable(BPoints,"BPoints","BPoints.txt")
   end
end

function OnExit()
   WriteTable(BPoints,"BPoints","BPoints.txt")
end

function DataArrival(curUser,data)
   if strsub(data,1,1) == "<" then
      data = strsub(data,1,strlen(data)-1)
      _,_,word1 = strfind(data,"^%b<>%s+(%S+)")
      if word1 and BFUNCS[word1] then
         BFUNCS[word1](curUser,data)
      end
   end
end
--------------------------------------------------------------------------
--   SHOW ONE SPIN
--------------------------------------------------------------------------
function doShowSpin(curNick)
   local num = random(getn(BSpin[curNick].Wheel))
   local num1 = BSpin[curNick].Wheel[num]
   local num2 = random(9)
   for i = 1,getn(BSpin[curNick].WheelChar) do
      if i == num1 then
         BSpin[curNick].WheelChar = num2
      end
   end
   curUser = GetItemByName(curNick)
   if curUser then
      curUser:SendData(bot,"\r\n"..
      "\t--------------------------\r\n\r\n"..
      "\t---- "..BSpin[curNick].WheelChar[1].." ---- "..BSpin[curNick].WheelChar[2].." ---- "..BSpin[curNick].WheelChar[3].." ----\r\n\r\n"..
      "\t--------------------------\r\n")
   else
      BSpin[curNick] = nil
      return
   end
   BSpin[curNick].Time = 0
   tremove(BSpin[curNick].Wheel,num)
   if getn(BSpin[curNick].Wheel) == 0 then
      BPoints[curUser.sName] = BPoints[curUser.sName] or 0
      local curSum = {}
      for i = 1,3 do
         if curSum[BSpin[curNick].WheelChar] then
            curSum[BSpin[curNick].WheelChar] = curSum[BSpin[curNick].WheelChar] + 1
         else
            curSum[BSpin[curNick].WheelChar] = 1
         end
      end
      for i,v in curSum do
         if curSum == 2 then
            BPoints[curUser.sName] = BPoints[curUser.sName] + i
            curUser:SendData(bot,"You get "..i.." Point(s).")
         elseif curSum == 3 then
            BPoints[curUser.sName] = BPoints[curUser.sName] + (i*10)
            curUser:SendData(bot,"You get "..(i*10).." Point(s).")
            if i == 9 then
               BPoints[curUser.sName] = BPoints[curUser.sName] + 300
               curUser:SendData(bot,"*****  JAKPOT YOU GET 300 extra Points.")
            end
         end
      end
      BSpin[curNick] = nil
   end
end
--------------------------------------------------------------------------
--   SAVE POINTS
--------------------------------------------------------------------------
function WriteTable(table,tablename,file)
   local handle = openfile(file,"w")
   write(handle,tablename.." = {\n")
   for i,v in table do
      write(handle,"["..format('%q',i).."] = "..v..",\n")
   end
   write(handle,"}")
   closefile(handle)
end
--------------------------------------------------------------------------
--   BANDIT FUNCS
--------------------------------------------------------------------------
BFUNCS = {

   [BPrefix..cmd1] = function(curUser,data)
      local _,_,num = strfind(data,"(%d+)$")
      if not BPlayers[curUser.sName] and tonumber(num) and tonumber(num) <= 20 and tonumber(num) > 0 then
         BPlayers[curUser.sName] = tonumber(num)
         curUser:SendData(bot,"You have inserted "..num.." coins.")
      else
         curUser:SendData(bot,"We are no bank.We don't store or give out money.")
      end
   end,

   [BPrefix..cmd2] = function(curUser,data)
      if BPlayers[curUser.sName] and not BSpin[curUser.sName] then
         BPlayers[curUser.sName] = BPlayers[curUser.sName] - 1
         if BPlayers[curUser.sName] == 0 then
            BPlayers[curUser.sName] = nil
         end
         BSpin[curUser.sName] = {
            Wheel = { 1,2,3 },
            WheelChar = { "X","X","X" },
            Time = 0,
         }
         curUser:SendData(bot,"Spinning the Wheel.\r\n\r\n"..
         "\t--------------------------\r\n\r\n"..
         "\t---- X ---- X ---- X ----\r\n\r\n"..
         "\t--------------------------\r\n")
      else
         curUser:SendData(bot,"You need to insert a coin first.")
      end
   end,

   [BPrefix..cmd3] = function(curUser,data)
      if BSpin[curUser.sName] then
         doShowSpin(curUser.sName)
      end
   end,

   [BPrefix..cmd4] = function(curUser,data)
      TCopy = {}

      for i,v in BPoints do

         tinsert(TCopy,{i,v})

      end

      sort(TCopy,function(a,b) return(a[2]>b[2]) end)
      local msg = "-- Top Bandits ---\r\n\r\n"
      for i = 1,getn(TCopy) do
         msg = msg.."\t# "..i.."  -  "..TCopy[1]..",  Points: "..TCopy[2].."\r\n"
      end
      curUser:SendData(bot,msg)
   end,
}

----------------------------------------------------------------------
//WickeD

NightLitch

well that the point right ?? or what, you want others to see when the play ??? hope I understand you correctly
//NL

WickeD

You are so right NightLitch! I did not think of that!  =) =)

Thx!!

//WickeD

SMF spam blocked by CleanTalk