i have 2 problems that i hope someone could help me with..
im playing around with rightclick menus
question 1.how do i add a submenu? like in robocop?
question 2.i get disconnected when adding question to trivia game
code:
------------------------------------------------------------------------------
-- PtokaX Lua 5 version by PPK
-- UserCommand extension script for PtokaX by Gadget
function NewUserConnected(curUser)
if curUser.bUserCommand then
curUser:SendData("$UserCommand 255 7")
curUser:SendData("$UserCommand 0 3")
curUser:SendData("$UserCommand 1 3 *** "..frmHub:GetHubName().." (Rules) ***$<%[mynick]> !rules|")
curUser:SendData("$UserCommand 1 3 HELP$<%[mynick]> !help|")
curUser:SendData("$UserCommand 1 3 FAQ$<%[mynick]> !faq|")
curUser:SendData("$UserCommand 1 3 MYIP$<%[mynick]> !myip|")
curUser:SendData("$UserCommand 1 3 MYINFO$<%[mynick]> !myinfo|")
curUser:SendData("$UserCommand 1 3 change pass$<%[mynick]> !repass|")
curUser:SendData("$UserCommand 1 3 Tophubbers$<%[mynick]> !tophubbers|")
curUser:SendData("$UserCommand 1 3 Showreg$<%[mynick]> !showreg %[line:Enter profile (reg,vip,op,master)]|")
curUser:SendData("$UserCommand 1 3 Away message$<%[mynick]> !away %[line:Enter away message]|")
curUser:SendData("$UserCommand 1 3 Back after away$<%[mynick]> !back|")
curUser:SendData("$UserCommand 1 3 Get aways$<%[mynick]> !getaways|")
curUser:SendData("$UserCommand 1 3 Report Bad User$<%[mynick]> !report %[line:users nick] %[line:reason for reporting this user]|")
curUser:SendData("$UserCommand 1 3 My total hubtime$<%[mynick]> !myhubtime|")
curUser:SendData("$UserCommand 1 3 Free slots$<%[mynick]> !slots|")
curUser:SendData("$UserCommand 0 3")
curUser:SendData("$UserCommand 1 3 TRIVIA//Triviahelp$<%[mynick]> tbhelp|")
curUser:SendData("$UserCommand 1 3 TRIVIA//join triviagame$<%[mynick]> tbjoin|")
curUser:SendData("$UserCommand 1 3 TRIVIA//quit triviagame$<%[mynick]> tbpart|")
curUser:SendData("$UserCommand 1 3 TRIVIA//show scores$<%[mynick]> tbscores|")
curUser:SendData("$UserCommand 1 3 TRIVIA//top ten trivia players$<%[mynick]> tbtopten|")
curUser:SendData("$UserCommand 1 3 TRIVIA//show your points$<%[mynick]> tbpoints|")
curUser:SendData("$UserCommand 1 3 TRIVIA//triviaplayers$<%[mynick]> tbplayers|")
curUser:SendData("$UserCommand 1 3 TRIVIA//add a question to trivia database$<%[mynick]>tbaddquestion %[line:question here]%[line:answer here start with #]|")
end
end
------------------------------------------------------------------------------------
end of code
For Trivia you have it slightly wrong, hence disconnection,
Change this.. TRIVIA//Triviahelp
to this.. TRIVIA\\Triviahelp
And that is how you add submenu's by using \\
hehe thanks did'nt really connect there =)
About $UserCommand, i recommend reading this (http://dcplusplus.sourceforge.net/wiki/index.php/UserCommand%20command).
humm..got another one
how do i add this line so it sends the command to a bot
from main?
code:
-----------------------------------------------------------------------
curUser:SendData("$UserCommand 1 3 OFFLINE\\message to offline user$<%[mynick]> !mail %[line:nick] %[line:message] |")
-----------------------------------------------------------------------
end
%[botname:offlinebot] sure does not work ;)
QuoteOriginally posted by lynyrd
humm..got another one
how do i add this line so it sends the command to a bot
from main?
curUser:SendData("$UserCommand 1 3 OFFLINE\\message to offline user$<%[mynick]> !mail %[line:nick] %[line:message] |")
end
%[botname:offlinebot] sure does not work ;)
curUser:SendData("$UserCommand 1 3 Menu Level\\Menu Item$To: PUT_YOUR_BOTS_NAME_HERE From: %[mynick] $<%[mynick]> !cmd %[line:message] |")
It should work like that ... try and say .. :)
i got disconnected again.
tried your code an this...
curUser:SendData("$UserCommand 1 3 offline\\offline message$ To:offlinebot From:<%[mynick]> $ %<%[mynick]> !mail %[line:nick] %[line:message]|")
strange
Try this one:
curUser:SendData("$UserCommand 1 3 offline\\Offline Message$<%[mynick]> !mail %[line:Nick] %[line:Message]||")
Best regards.
thanks jiten
but the results comes up in main showing the whole command like this " !mail [SU]test test"
but i start to realise that it probably is much easier
to change the offline script to receive info from main
and if someone is willing to help out heres the script
code:
------------------------------------------------------------------------------
-- offlinemsg.lua, created by amutex 11.01.2003
-- thx to nathanos for the fine pm-parsing
-- bits and pieces added and deleted by bolamix over time, kudos to all scripters who helped!
-- attempted conversion to lua5 by bolamix Feb. 27 2005
-- successful conversion to lua5 by Jelf March 9 2005
-- usage: send a PM to the bot with
path = "messages" -- name of the folder where the message files will be stored
ext = ".msg" -- extension for the message files
command = "!mail"
botname = frmHub:GetHubBotName() -- or use whatever botname you want then uncomment the following 3 lines
--function main
-- frmHub:RegBot( botname )
--end
os.execute("mkdir ".."\""..string.gsub(path, "/", "\\").."\"")
function Get2Args(data)
s,e,whoTo,from,cmd,arg,arg2 = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(%S+)%s+(.*)")
return arg,arg2
end
function ToArrival(user, data)
s,e,whoTo = string.find(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
if (cmd == command) then
arg,arg2 = Get2Args(data)
local f,e = io.open(path.."/"..arg..ext,"a+")
if f then
f:write(""..user.sName.." sent you this message on "..GetDate().." at "..GetTime().." : "..arg2)
user:SendPM(botname,"Message stored. It will be sent to "..arg.." next time he/she logs in.")
f:close()
end
end
end
end
function NewUserConnected(curUser)
local handle = io.open(path.."/"..curUser.sName ..ext,"r")
if (handle ~= nil) then
local line = handle:read()
curUser:SendPM("#Offline_Message", line)
handle:close()
os.remove(path.."/"..curUser.sName..ext)
else
end
end
OpConnected = NewUserConnected
function GetTime()
h = os.date("%H")
m = os.date("%M")
Time = h..":"..m
return Time
end
function GetDate()
d = os.date("%d")
mm = os.date("%m")
y = os.date("%y")
Date = mm.."/"..d.."/"..y
return Date
end
------------------------------------------------------------------------------------
end of code
Try this one:
-- offlinemsg.lua, created by amutex 11.01.2003
-- converted to LUA 5 by jiten
-- thanks to dessamator for the rightclick hint :]
-- thx to nathanos for the fine pm-parsing
-- bits and pieces added and deleted by bolamix over time, kudos to all scripters who helped!
-- attempted conversion to lua5 by bolamix Feb. 27 2005
-- successful conversion to lua5 by Jelf March 9 2005
-- usage: send a PM to the bot with
path = "messages" -- name of the folder where the message files will be stored
ext = ".msg" -- extension for the message files
command = "!mail"
botname = frmHub:GetHubBotName() -- or use whatever botname you want then uncomment the following 3 lines
--function Main()
-- frmHub:RegBot( botname )
--end
os.execute("mkdir ".."\""..string.gsub(path, "/", "\\").."\"")
function Get2Args(data)
s,e,whoTo,from,cmd,arg,arg2 = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(%S+)%s+(.*)")
return arg,arg2
end
function ToArrival(user, data)
s,e,whoTo = string.find(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
if (cmd == command) then
arg,arg2 = Get2Args(data)
local f,e = io.open(path.."/"..arg..ext,"a+")
if f then
f:write(""..user.sName.." sent you this message on "..GetDate().." at "..GetTime().." : "..arg2)
user:SendPM(botname,"Message stored. It will be sent to "..arg.." next time he/she logs in.")
f:close()
end
end
end
end
function NewUserConnected(curUser)
UserCmds(curUser)
local handle = io.open(path.."/"..curUser.sName ..ext,"r")
if (handle ~= nil) then
local line = handle:read()
curUser:SendPM("#Offline_Message", line)
handle:close()
os.remove(path.."/"..curUser.sName..ext)
else
end
end
OpConnected = NewUserConnected
function GetTime()
h = os.date("%H")
m = os.date("%M")
Time = h..":"..m
return Time
end
function GetDate()
d = os.date("%d")
mm = os.date("%m")
y = os.date("%y")
Date = mm.."/"..d.."/"..y
return Date
end
function UserCmds(curUser)
curUser:SendData("$UserCommand 1 2 offline\\Offline Message$$To: "..botname.." From: %[mynick] $<%[mynick]> !mail %[line:Nick] %[line:Message]||")
end
Best regards,
jiten