summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/Core/onkilling.lua
blob: b3361355f60da7de5657da0e51ef8f0dc4be4bbf (plain) (blame)
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
function OnKilling(Victim, Killer)
	if Victim:IsPlayer() == true then
		Server = cRoot:Get():GetServer()
		if Killer == nil then
			if Victim:IsOnFire() then
				Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " burned away." )
				CheckHardcore(Victim)
				return false
			end
			if Victim:GetWorld():GetBlock(Victim:GetPosX(), Victim:GetPosY(), Victim:GetPosZ()) == 10 or Victim:GetWorld():GetBlock(Victim:GetPosX(), Victim:GetPosY(), Victim:GetPosZ()) == 11 then
				Server:SendMessage( cChatColor.Red ..  Victim:GetName() .. " tried to swim in lava" )
				CheckHardcore(Victim)
				return false
			end
		else
			if Killer:IsPlayer() == true then
				Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by " .. Killer:GetName() )
				CheckHardcore(Victim)
				return false
			elseif Killer:IsMob() == true then
				if Killer:IsA("cZombie") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is eaten by a zombie")
					CheckHardcore(Victim)
					return false
				elseif Killer:IsA("cSkeleton") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a skeleton" )
					CheckHardcore(Victim)
					return false
				elseif Killer:IsA("cCreeper") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a creeper")
					CheckHardcore(Victim)
					return false
				elseif Killer:IsA("cSpider") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a spider")
					CheckHardcore(Victim)
					return false
				elseif Killer:IsA("cCaveSpider") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a cavespider")
					CheckHardcore(Victim)
					return false
				elseif Killer:IsA("cBlaze") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a blaze")
					CheckHardcore(Victim)
					return false
				elseif Killer:IsA("cEnderman") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is slain by a enderman")
					CheckHardcore(Victim)
					return false
				elseif Killer:IsA("cSilverfish") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a silverfish")
					CheckHardcore(Victim)
					return false
				elseif Killer:IsA("cSlime") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a slime")
					CheckHardcore(Victim)
					return false
				elseif Killer:IsA("cWitch") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a witch")
					CheckHardcore(Victim)
					return false
				elseif Killer:IsA("cZombiepigman") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is slain by a zombiepigman")
					CheckHardcore(Victim)
					return false
				elseif Killer:IsA("cMagmacube") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a magmacube")
					CheckHardcore(Victim)
					return false
				elseif Killer:IsA("cWolf") then
					Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a wolf")
					CheckHardcore(Victim)
					return false
				end
			end
		end
		Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " Died")
	end
end

function CheckHardcore(Victim)
	if HardCore == "true" then
		if Victim:IsPlayer() == true then
			local KilledPlayer = tolua.cast(Victim, "cPlayer")
			BanPlayer(KilledPlayer:GetName(), "You Died")
		end
	end
end