Page 1 of 1
get the guild of player
Posted: Sat Dec 15, 2012 3:41 am
by Ajoir
for access to name player, the variable is player.Name. For access the level of player, the variable is player.Level. What variable is used for access to guild of player? I try player.Guild, but don't work for me. Thank you in advace.
Re: get the guild of player
Posted: Sat Dec 15, 2012 4:39 am
by lisa
There is none, you would need to use an ingame function of some kind to get the guild info.
Only one I can think of at the moment is AskPlayerInfo("charname")
Needless to say guild of a player is more complicated than just doing player.Name, do you really need it?
Re: get the guild of player
Posted: Sat Dec 15, 2012 6:45 am
by rock5
If I remember correctly AskPlayerInfo("charname") only prints to the screen which is pretty useless. I know you needed to use it for gmmonitor but if all the user wants is the players guild name they can use GetGuildInfo(). That's what I used in the AT script. So
Code: Select all
GuildName = RoMScript("GetGuildInfo()")
If you need more information about your guild, that function does return more values.
Code: Select all
local guildName, leaderName, bRecruit, alreadyCreate,
MaxMemberCount, Score, GuildNote, Introduce,
isLeader, isBBSEnable, isOpenGuild, Level, IsOwnHouse, IsOpenVisit = GetGuildInfo();
I'll leave you to figure out what they all mean if you need them.
Re: get the guild of player
Posted: Sat Dec 15, 2012 7:58 am
by lisa
Ahh yes I was assuming they wanted guild of a different character, not the character they were logged on to.
Re: get the guild of player
Posted: Sat Dec 15, 2012 4:28 pm
by Ajoir
Thank your very much for your fast answer. I´ll try apply your solutions.
Re: get the guild of player
Posted: Sat Dec 15, 2012 9:41 pm
by Ajoir
Hi again. I found what i was looking. The function what i want is: "UnitIsInMyGuild= Returns whether a unit is in the player's guild". Try the code:
Code: Select all
help="object"; --object was the name of the object.
if (RoMScript ("UnitIsInMyGuild ("..help..")")) then
print("GREAT!");
end
But give me an error. I think return a nill value, but i´m not sure (IGF: [STRING "LOCAL A={UnitIsInMyGuild (object)} return a"]:1: attempt to call global 'UnitIsInMyGuild' (a nil value). May be that this function isn´t implemented in rombot, or some thing similar.
I want add this code an a function similar of the created by lisa GM:detection, and give an alarm to me if someone of my guild its near. Could you help me, please? thank you in advance
Re: get the guild of player
Posted: Sat Dec 15, 2012 10:14 pm
by lisa
lol I was right, you do want the guild of another character.
Well you will need to add in the code yourself as I don't want the GM monitor to detect other guild members.
So basically you want to add in another check in the userfunction for if your guild name is posted with the AskPlayerInfo that it does. Gm monitor only does this when whispered, so basically you will need to add in your own funtion or just make a new userfunction for yourself.
Code: Select all
local obj = nil;
local objectList = CObjectList();
objectList:update();
for i = 0,objectList:size() do
obj = objectList:getObject(i);
if( obj.Type == PT_PLAYER ) then
EventMonitorStart("GuildDetect", "CHAT_MSG_SYSTEM");
sendMacro("AskPlayerInfo(\'"..obj.Name.."\');")
yrest(1000)
local time, moreToCome, msg = EventMonitorCheck("GuildDetect", "1")
if msg ~= nil then
if string.find(msg,"Addyourguildnamehere") then
if playalarm then playalarm() playalarm() end
-add what ever else you want to do, like logout
end
end
end
end
This is very basic, you should really add the obj.Name to a table so it only calls it once and not repeatedly, plus some tweaking here and there.
Have fun
Re: get the guild of player
Posted: Sat Dec 15, 2012 11:45 pm
by Ajoir
you are really fast!!.
I add your code, and work prefectly. if I had thought a little more, i would have found the solution too, because I had already used the "askplayerinfo" and the "EventMonitorCheck" in other times. Thank you very much for your help.
I still have a little doubt. Is it better to add the "EventMonitorStop" at the end, or really does not affect performance?
Re: get the guild of player
Posted: Sun Dec 16, 2012 12:10 am
by lisa
Ajoir wrote:I still have a little doubt. Is it better to add the "EventMonitorStop" at the end, or really does not affect performance?
probably best to add it at end,
you see the addon itself will continue monitoring the guild messages long after you stop botting, basically until the game is fully exited it will continue to monitor guild chat.