Log in

View Full Version : Alarm X Keyword?



martintokio
05-23-2016, 12:20 PM
Hey, I want to make a exiva alarm but I didn't managed to find a way to make if X keyword alarm + private msg my char, since there is plenty ways of exiva:
Exiva "Charname
exiva charname
exiva "charname"
etc...
I want to make it with keyword X

Any idea?


local AlarmMessage = "Keyword", "Keyword"
LocalSpeechProxy.OnReceive("AlarmIfExiva",
function(proxy, mtype, speaker, level, text)
if text == AlarmMessage then
alert()
Self.PrivateMessage("Charname", "Someone just exived you, take care!")
end
end)
That's what I've tried so far.

martintokio
05-23-2016, 12:21 PM
@shadowart any suggestion?

texmex47
05-23-2016, 12:31 PM
You can't say if text == AlarmMessage, because AlarmMessage is an array. Btw you got a syntax error.
Either remove one "Keyword", or make an array of it and loop through the array and see if text is in it.

martintokio
05-23-2016, 12:53 PM
You can't say if text == AlarmMessage, because AlarmMessage is an array. Btw you got a syntax error.
Either remove one "Keyword", or make an array of it and loop through the array and see if text is in it.

Well w/e it was an example the one I got working with my char name it's working but with one variant only, thats why I need someway to check the keyword

martintokio
05-27-2016, 11:04 AM
bump anyone?

Stusse
05-27-2016, 01:21 PM
bump anyone?Try



function alarmer(proxy, message)
mtch = message:match("exiva")
if mtch then
alert()
Self.PrivateMessage("Charname", "Someone just exived you, take care!")
end
end

LocalSpeechProxy.New("alarmer"):OnReceive(alarmer)


/Stusse

anoyn
05-27-2016, 01:24 PM
You've got an array, i assume only the first position is being checked.

To check the entire list you could use a function to go through each spot in the array and compare it.


--#AlarmMessage represents the amount of indexes in the array.
--lua arrays start at 1, so this loop will do 1,2 in an array with two indexes
for i = 1, #AlarmMessage do
if text == AlarmMessage[i] then
--do stuff
break -- if we found one match, we wont find any others so stop checking
end
end

martintokio
05-27-2016, 02:04 PM
Try



function alarmer(proxy, message)
mtch = message:match("exiva")
if mtch then
alert()
Self.PrivateMessage("Charname", "Someone just exived you, take care!")
end
end

LocalSpeechProxy.New("alarmer"):OnReceive(alarmer)


/Stusse
Working <3 thanks <3<3<3

P.S: Only issue, is that with any msg on local chat the alarm pops up.

martintokio
05-27-2016, 02:05 PM
nvm, as said above