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
well that the point right ?? or what, you want others to see when the play ??? hope I understand you correctly
You are so right NightLitch! I did not think of that! =) =)
Thx!!
//WickeD