Page 1 of 1
Beep when whispered
Posted: Fri Sep 02, 2011 8:53 pm
by zephir
Hello,
I would like that when i'm whispered, my pc beeps.
I would like the code, to work a bit like the 'gmMonitor'
http://www.solarstrike.net/phpBB3/viewt ... =detection
A code that when detects whispers, run this code:
Hope you can help me

Thanks and regards.
Re: Beep when whispered
Posted: Fri Sep 02, 2011 9:14 pm
by lisa
if onload have
Code: Select all
<onload>
EventMonitorStart("Whispers", "CHAT_MSG_WHISPER");
registerTimer("beepwhispers", secondsToTimer(5), beepwhispers);
local function beepwhispers()
repeat
local time, moreToCome, name, msg = EventMonitorCheck("Whispers", "4,1")
if time ~= nil then
printf("\a\a\a");
end
until moreToCome == false
end
</onload>
Something like that will probably do the trick.
Re: Beep when whispered
Posted: Sat Sep 03, 2011 4:35 am
by zephir
Thank you for you quick reply.
but It now appears the following error:
Code: Select all
scripts\rom\bot.lua:436: onLoad error: [string "..."]:5 Error: Non-function type passed to registerTimer() where a funtion is expected.
Re: Beep when whispered
Posted: Sat Sep 03, 2011 4:43 am
by lisa
Try this, it is probably because I had the function after the timer, so MM hadn't read the code for the function yet.
Code: Select all
<onload>
function beepwhispers()
repeat
local time, moreToCome, name, msg = EventMonitorCheck("Whispers", "4,1")
if time ~= nil then
printf("\a\a\a");
end
until moreToCome == false
end
EventMonitorStart("Whispers", "CHAT_MSG_WHISPER");
registerTimer("beepwhispers", secondsToTimer(5), beepwhispers);
</onload>
Re: Beep when whispered
Posted: Sat Sep 03, 2011 7:16 am
by zephir
Now it beeps when whispered like it should

the problem is that 'RB Command' macro starts being pressed like crazy
and it stops executting the code, stopping at some point
and I cant even press END to pause it
probably something in the 'repeat'
Re: Beep when whispered
Posted: Sat Sep 03, 2011 8:16 am
by lisa
I guess it depends how often u get whispered, if it is lots then could probably add in a time check so it only beeps at you once for messages every 30 secs or something, can be tricky to get timing working nicely though.
It will stay in the loop beeping for aslong as you get whispers, if you get 5 then it will beep 3 times for each whisper for total of 15 times, then it will go back to the macro usage every 5 seconds.
Assuming nothing else is going on. Are you getting bot to run anything else?
Re: Beep when whispered
Posted: Sat Sep 03, 2011 8:52 am
by zephir
the only code I'm using is:
Code: Select all
<onLoad>
function beepwhispers()
repeat
local time, moreToCome, name, msg = EventMonitorCheck("Whispers", "4,1")
if time ~= nil then
printf("\a\a\a");
end
until moreToCome == false
end
EventMonitorStart("Whispers", "CHAT_MSG_WHISPER");
registerTimer("beepwhispers", secondsToTimer(5), beepwhispers);
</onLoad>
<onLeaveCombat>
</onLeaveCombat>
<onDeath>
RoMScript("BrithRevive();");
waitForLoadingScreen()
yrest(settings.profile.options.WAIT_TIME_AFTER_RES);
player:update();
player:rest(1);
printf("\a\a\a");
error("You died", 0);
</onDeath>
<onLevelup>
</onLevelup>
<onSkillCast>
</onSkillCast>
<onHarvest>
</onHarvest>
<!-- Lua code to execute when MAX_UNSTICK_TRIALS is reached. -->
<onUnstickFailure>
player:logout(nil,true);
</onUnstickFailure>
and something strange happens:
I press DEL and activates code
it walks 5 waypoints, but then it stops the code (the macromicro stops code excution, and I can't press DEL or END)
and I happened to press the party button, and the chat opened and it typed '0' and closed the chat and walked to the next waypoint
Re: Beep when whispered
Posted: Sat Sep 03, 2011 8:58 am
by lisa
sounds like an issue with the WP or possibly an addon.
Re: Beep when whispered
Posted: Wed Sep 28, 2011 11:27 am
by spawni

Hi there,
great bot - great board. I´m a totaly newbie - at least i have coded other script-languages.
I tried diffrent things with the bot - all works fine - but the whisper-beep-script will not run.
Would be nice, if you can give me a tip - where do I have to fill in the code-snippet?
I tried out profile and scripts - in all cases it stops the waypoint-script from running....
Hope you can help me

Re: Beep when whispered
Posted: Wed Sep 28, 2011 12:01 pm
by rock5
Why don't you show us your code so we can see if there is something wrong with it? So there was no error message?
Re: Beep when whispered
Posted: Wed Sep 28, 2011 12:17 pm
by spawni
wow - fast reply
unfortunately no error msg. What i have tried first was a simple copy n paste thing with your Rock5's Millers Ranch Chickens run and the beep-code snippet
Try and errors:
1. code-snippet in profile-xml - onload-section- result: chicken run won´t work - no error message
2. code-snippet in your eggs-script - result: chicken run won´t work - no error message
In your script i put the snippet in one try on top of onload-section in another try at the end fo the script.
Used code:
<onLoad><![CDATA[
-- edit by spawni 27.09 beep by whisper ----
function beepwhispers()
repeat
local time, moreToCome, name, msg = EventMonitorCheck("Whispers", "4,1")
if time ~= nil then
printf("\a\a\a");
end
until moreToCome == false
end
EventMonitorStart("Whispers", "CHAT_MSG_WHISPER");
registerTimer("beepwhispers", secondsToTimer(5), beepwhispers)
]]></onLoad>
Re: Beep when whispered
Posted: Wed Sep 28, 2011 12:47 pm
by rock5
Ok I think I got it.
'moreToCome' only returns true or false if EventMonitorCheck actually returns a log entry. If it doesn't, ie. there is nothing to return, then moreToCome will be nil. Actually all the vlues, "time, moreToCome, name, msg" will be nil.
Try this instead.
That should work.
Re: Beep when whispered
Posted: Wed Sep 28, 2011 12:53 pm
by spawni
ty - will try it out and give feedback (tomorrow)

Re: Beep when whispered
Posted: Thu Sep 29, 2011 10:26 am
by spawni

your tip made the difference - no it beeps - thx for your help
Re: Beep when whispered
Posted: Fri Oct 21, 2011 9:43 am
by mike
Hi
I'm trying to implement this as follows:
Code: Select all
if (soundLoad) then
notifysound = soundLoad(getExecutionPath() .. "/alarm.wav");
if (notifysound == nil) then
warning("Failed to load sound file \'alarm.wav\'");
end
end
function beepwhispers()
repeat
local time, moreToCome, name, msg = EventMonitorCheck("WhisperNotify", "4,1")
if time ~= nil and name ~= "Newbie Pet" then
printf("Someone whispered!\n");
if (notifysound == nil) then
printf("\a\a\a");
else
if (soundGetState(notifysound) ~= "playing") then
soundPlay(notifysound);
end
end
end
until moreToCome ~= true
end
function enablenotifications()
EventMonitorStart("WhisperNotify", "CHAT_MSG_WHISPER");
registerTimer("beepwhispers", secondsToTimer(5), beepwhispers);
printf("Enabled notifications.\n");
end
However it seems time is always nil so the sound is never played. Any ideas?
Thanks,
Mike
Re: Beep when whispered
Posted: Fri Oct 21, 2011 9:59 am
by rock5
'time' uses 'os.time()' which was removed from the game awhile back. You will need an addon like d303fix to add it again or maybe check by 'moretocome'. That should always return true or false if an entry was found so this should work
Code: Select all
if moreToCome ~= nil and name ~= "Newbie Pet" then
printf("Someone whispered!\n");
Re: Beep when whispered
Posted: Fri Oct 21, 2011 10:17 am
by mike
Ah offcourse! Thanks for helping a noob Rock5.
Re: Beep when whispered
Posted: Sat Sep 21, 2013 8:11 pm
by BlubBlab
Is there an order in moreToCome or will it response random?
Re: Beep when whispered
Posted: Sun Sep 22, 2013 2:54 am
by rock5
It should send you the messages in order from oldest to newest.
Re: Beep when whispered
Posted: Sun Sep 22, 2013 12:48 pm
by BlubBlab
Then it should work as intended thx