Hello, I figured out how to do everything else I need to do for this one macro... but logoff when coming in contact with someone else who isn't in party. Is there a way to do this? I want a farm a spot, bot not take it over should someone else come.
I've tried searching but have some up empty. If someone could point me in the correct location I would appreciate it.
Thank you.
auto-logoff when coming in contact with someone else
-
- Posts: 7
- Joined: Fri Dec 17, 2010 12:34 am
Re: auto-logoff when coming in contact with someone else
You would have to search by object type so you can search for type "PT_PLAYER". There is no function that does that normally I think but you could use the evalfunc argument in player:findNearestnameOrId() function. Check out my MillersRanchChickens.xml waypoint file for an example on how to do this. I use about 3 separate eval functions in it.
If you need more help, let use know.
If you need more help, let use know.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
-
- Posts: 7
- Joined: Fri Dec 17, 2010 12:34 am
Re: auto-logoff when coming in contact with someone else
I will educate myself over the next couple of days and try and get it going. If I have problems, I'll come back with with some test script to see if you can clear it up. Thanks for trying to poke me in the right direction.
Re: auto-logoff when coming in contact with someone else
I made this for myself. No parameters are required.
player:PlayerInRange() in waypoint would scan for players within 300 range and return true if player detected.
You could add more obj.Name conditions after obj.Name ~= "<UNKNOWN>" for the names of party members you don't want to count.
I just made an addition (haven't tested yet).
Change "player1","player2" etc. to the names of the players you want to ignore.
player:PlayerInRange() in waypoint would scan for players within 300 range and return true if player detected.
You could add more obj.Name conditions after obj.Name ~= "<UNKNOWN>" for the names of party members you don't want to count.
Code: Select all
function CPlayer:PlayerInRange(_range,_X,_Z)
_range = _range or 300
_X = _X or self.X
_Z = _Z or self.Z
local dist = 0
local function isInDist(x1, y1, x2, y2, radius)
if( x2 >= x1-radius and x2 <= x1+radius and
y2 >= y1-radius and y2 <= y1+radius ) then
dist = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)
if( dist <= radius*radius ) then
dist = math.floor(math.sqrt(dist)+0.5)
return true
else
return false
end
end
return false
end
local found = false
local doOnce = true
local obj = nil
local objectList = CObjectList()
objectList:update()
for i = 0,objectList:size() do
obj = objectList:getObject(i)
if( obj.Type == PT_PLAYER and obj.Name ~= self.Name and obj.Name ~= "<UNKNOWN>" ) then
if( isInDist(_X, _Z, obj.X, obj.Z, _range) ) then
if( doOnce ) then
cprintf(cli.red,"Player Detection! ")
printf("NAME\n")
printf(" ----\n")
doOnce = false
end
printf(" %s - ", obj.Name)
printf("%s\n", dist)
found = true
end
end
end
return found
end
Change "player1","player2" etc. to the names of the players you want to ignore.
Code: Select all
function CPlayer:PlayerInRange(_range,_X,_Z)
_range = _range or 300
_X = _X or self.X
_Z = _Z or self.Z
local dist = 0
local function isInDist(x1, y1, x2, y2, radius)
if( x2 >= x1-radius and x2 <= x1+radius and
y2 >= y1-radius and y2 <= y1+radius ) then
dist = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)
if( dist <= radius*radius ) then
dist = math.floor(math.sqrt(dist)+0.5)
return true
else
return false
end
end
return false
end
local function evalPlayerName(_name)
local playerNames = {"player1","player2","player3","player4"}
for k, v in ipairs(playerNames) do
if _name == v then return false end
end
return true
end
local found = false
local doOnce = true
local obj = nil
local objectList = CObjectList()
objectList:update()
for i = 0,objectList:size() do
obj = objectList:getObject(i)
if( obj.Type == PT_PLAYER and obj.Name ~= self.Name and obj.Name ~= "<UNKNOWN>" and evalPlayerName(obj.Name) ) then
if( isInDist(_X, _Z, obj.X, obj.Z, _range) ) then
if( doOnce ) then
cprintf(cli.red,"Player Detection! ")
printf("NAME\n")
printf(" ----\n")
doOnce = false
end
printf(" %s - ", obj.Name)
printf("%s\n", dist)
found = true
end
end
end
return found
end
-
- Posts: 7
- Joined: Fri Dec 17, 2010 12:34 am
Re: auto-logoff when coming in contact with someone else
Thank you very much Alkaiser. This is very helpful.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests