forked from Ascerr/Lua-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExit Game if player.lua
More file actions
100 lines (73 loc) · 3.14 KB
/
Exit Game if player.lua
File metadata and controls
100 lines (73 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
--[[
Script Name: Exit Game If Player
Description: Close game process when player detected on screen.
Author: Ascer - example
]]
local FRIENDS = {"friend1","friend2"} -- list of friends we avoid.
local LOGS = "C:\\logs.txt" -- path to file with logs.txt
local BATCH = "C:\\batch.bat" -- path to file with batch.bat to run kill process.
-- DON'T EDIT BELOW THIS LINE.
-- convert table to lower strings.
FRIENDS = table.lower(FRIENDS)
---------------------------------------------------------------------------------------------------------------------------------------------------------
--> Function: getCreature()
--> Description: Get creature monster or player on screen.
--> Class: Self
--> Params: None
--> Return: boolean false or string name
----------------------------------------------------------------------------------------------------------------------------------------------------------
function getCreature()
-- inside loop for all found creatures on multiple floors do:
for i, c in pairs(Creature.iPlayers(7, false)) do
-- when we can not find a friends..
if not table.find(FRIENDS, string.lower(c.name)) then
-- return creature.
return os.date("%X") .. " " .. c.name .. " just appear on screen."
end
end
-- return false noone player found.
return false
end
----------------------------------------------------------------------------------------------
--> Function: createBatchFile(path)
--> Description: Create batch file with command to close specific process pid.
--> Params:
--> @pid - number id of process to kill
--> Returns: void nothing.
----------------------------------------------------------------------------------------------
function createBatchFile(pid)
file = io.open(BATCH, 'w')
file:write("taskkill /F /PID " .. pid .. "\n")
file:write("start " .. LOGS)
return file:close()
end
----------------------------------------------------------------------------------------------
--> Function: showLogs(path, data)
--> Description: Creates Logs.txt file and display it.
--> Params:
--> @data - what we write to file.
--> Returns: void nothing.
----------------------------------------------------------------------------------------------
function showLogs(data)
file = io.open(LOGS, 'w')
file:write(data)
file:close()
end
-- mod execute delay.
Module.New("Exit Game If Player", function ()
-- load creature
local player = getCreature()
-- when creature detected.
if player ~= false then
-- show who entered to screen.
showLogs(player)
-- load game client stats
local client = Rifbot.getClientInfo()
-- create batch file
createBatchFile(client.pid)
-- run batch file
os.execute(BATCH)
-- wait some time
wait(1000)
end
end)