mirror of
https://github.com/minetest-mods/throwing.git
synced 2025-01-09 09:40:26 +01:00
Fix a potential usebug
Avoid a player to crash the server by disconnecting after throwing the arrow and before it hits.
This commit is contained in:
parent
1e1424ab34
commit
cdafb81167
6
init.lua
6
init.lua
@ -49,7 +49,11 @@ local function arrow_step(self, dtime)
|
||||
return
|
||||
end
|
||||
|
||||
self.on_hit(pos, self.last_pos, node, obj, minetest.get_player_by_name(self.player))
|
||||
local player = minetest.get_player_by_name(self.player)
|
||||
if not player then -- Possible if the player disconnected
|
||||
return
|
||||
end
|
||||
self.on_hit(pos, self.last_pos, node, obj, player)
|
||||
if self.on_hit_sound then
|
||||
minetest.sound_play(self.on_hit_sound, {pos = pos, gain = 0.8})
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user