I think this should work.
If a player appear, it will:
1. Wait a small delay that you setup. If you don't wanna wait then setup very low intervals like 1 or even 0. I recommend you to use some interval to make look legit.
2. Check if player stills on screen
3. If LeaveEvenIfPlayerLeft == true then it will leave no matter what, otherwise, if player stills there then say a random message like "I'm leaving" and also leave.
4. Once the location you setup is reached then it will wait for battle and logout.
local SafeList = { 'Player1', 'player2', 'friend'}
local TextsSay = { 'im leaving...', 'leaving', 'sup, im leaving', 'i am going out' }
local TimeToStartTalking = 1000 -- In milliseconds. Time to wait before START saying something.
local LOCATION = { X = 12345, Y = 12345, Z = 6 } -- Location to reach when player appears.
local LeaveEvenIfPlayerLeft = true -- Leave even if player left screen while waiting time TimeToStartTalking?
--[[ DON'T EDIT BELOW THIS LINE --]]
--[[ DON'T EDIT BELOW THIS LINE --]]
if connected() and (posx() ~= LOCATION.X or posy() ~= LOCATION.Y) then
table.lower(SafeList)
IGNORED_PLAYERS = IGNORED_PLAYERS or { }
local PlayersList = getcreatures('pfs')
local player_name = name()
local player_z = posz()
local flag = false
for _, player in ipairs(PlayersList) do
if player.name ~= player_name and player.visible and player.posz == player_z and table.find(IGNORED_PLAYERS, player.name) == nil and table.find(SafeList, player.name:lower()) == nil then
wait(TimeToStartTalking)
local pcount = paround(7, player.name)
if LeaveEvenIfPlayerLeft or pcount > 0 then
if pcount > 0 then
local RANDOM_INDEX = random(1, #TextsSay)
say(TextsSay[RANDOM_INDEX])
table.insert(IGNORED_PLAYERS, player.name)
end
reachlocation(LOCATION.X, LOCATION.Y, LOCATION.Z, true)
wait(500, 800)
while battlesigned() do
wait(1000, 2000)
end
logout()
end
break
end
end
else
IGNORED_PLAYERS = { }
end
This does the same, except that it will work with Cavebot wpt label instead of location and will not logout, so you can make waypoints to leave and reach some safe spot and make an Action wpt to logout or do something else.
local SafeList = { 'Player1', 'player2', 'friend'}
local TextsSay = { 'im leaving...', 'leaving', 'sup, im leaving', 'i am going out' }
local TimeToStartTalking = 1000 -- In milliseconds. Time to wait before START saying something.
local CAVEBOT_LABEL = 'leave_hunt' -- Cavebot waypoint label to go whne player appears.
local LeaveEvenIfPlayerLeft = true -- Leave even if player left screen while waiting time TimeToStartTalking?
--[[ DON'T EDIT BELOW THIS LINE --]]
--[[ DON'T EDIT BELOW THIS LINE --]]
if connected() then
table.lower(SafeList)
IGNORED_PLAYERS = IGNORED_PLAYERS or { }
local PlayersList = getcreatures('pfs')
local player_name = name()
local player_z = posz()
for _, player in ipairs(PlayersList) do
if player.name ~= player_name and player.visible and player.posz == player_z and table.find(IGNORED_PLAYERS, player.name) == nil and table.find(SafeList, player.name:lower()) == nil then
wait(TimeToStartTalking)
local pcount = paround(7, player.name)
if LeaveEvenIfPlayerLeft or pcount > 0 then
if pcount > 0 then
local RANDOM_INDEX = random(1, #TextsSay)
say(TextsSay[RANDOM_INDEX])
table.insert(IGNORED_PLAYERS, player.name)
end
gotolabel(CAVEBOT_LABEL)
end
break
end
end
else
IGNORED_PLAYERS = { }
end