Prevent server crash when a attacked player leaves the game
parent
f95ae96848
commit
aae3120fe7
8
api.lua
8
api.lua
|
@ -173,6 +173,10 @@ function mobs:register_mob(name, def)
|
||||||
self.object:setvelocity(v)
|
self.object:setvelocity(v)
|
||||||
end
|
end
|
||||||
elseif self.state == "attack" and self.attack_type == "dogfight" then
|
elseif self.state == "attack" and self.attack_type == "dogfight" then
|
||||||
|
if not self.attack.player or not self.attack.player:is_player() then
|
||||||
|
self.state = "stand"
|
||||||
|
return
|
||||||
|
end
|
||||||
local s = self.object:getpos()
|
local s = self.object:getpos()
|
||||||
local p = self.attack.player:getpos()
|
local p = self.attack.player:getpos()
|
||||||
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
||||||
|
@ -236,6 +240,10 @@ function mobs:register_mob(name, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif self.state == "attack" and self.attack_type == "shoot" then
|
elseif self.state == "attack" and self.attack_type == "shoot" then
|
||||||
|
if not self.attack.player or not self.attack.player:is_player() then
|
||||||
|
self.state = "stand"
|
||||||
|
return
|
||||||
|
end
|
||||||
local s = self.object:getpos()
|
local s = self.object:getpos()
|
||||||
local p = self.attack.player:getpos()
|
local p = self.attack.player:getpos()
|
||||||
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
|
||||||
|
|
Loading…
Reference in New Issue