Fatalism
17-11-2006, 07:49 AM
I'm trying to write my first mod, part of which involves getting the name of a guild member who is signing in and then checking to make sure they are a guild member and not just a friend. I'm having a problem getting the name out of the event CHAT_MSG_SYSTEM and the string passed |Hplayer :%s|h[%s]|h has come online.
Sample code:
if (event == "CHAT_MSG_SYSTEM") then
msg = arg1;
if (string.find(string.lower(msg), "online") ~= nil) then
a, b, c, altname = string.find(msg,"[\[].-[\]]");
SendChatMessage("Altname: " .. altname,"SAY");
SendChatMessage(kadyhi().."altname","SAY");
end
end
which is supposed to pull the players name from between the '[' and ']' but it keeps giving me errors taht altname is nil. I have also tried:
a, b, altname = string.find(msg,"[\[].-[\]]");
and other variations without luck. Obviously I'm missing something. Once I have the name I have to figure out how to compare it with a list of guild members somehow. Any suggestions on either problem would be appreciated.
Nihilism - 42 Druid - Draka
Sample code:
if (event == "CHAT_MSG_SYSTEM") then
msg = arg1;
if (string.find(string.lower(msg), "online") ~= nil) then
a, b, c, altname = string.find(msg,"[\[].-[\]]");
SendChatMessage("Altname: " .. altname,"SAY");
SendChatMessage(kadyhi().."altname","SAY");
end
end
which is supposed to pull the players name from between the '[' and ']' but it keeps giving me errors taht altname is nil. I have also tried:
a, b, altname = string.find(msg,"[\[].-[\]]");
and other variations without luck. Obviously I'm missing something. Once I have the name I have to figure out how to compare it with a list of guild members somehow. Any suggestions on either problem would be appreciated.
Nihilism - 42 Druid - Draka