浏览代码

Client side slots;

Bjorn 11 年之前
父节点
当前提交
c81a0f8b79
共有 2 个文件被更改,包括 7 次插入3 次删除
  1. 2 0
      lib/player.lua
  2. 5 3
      lib/players.lua

+ 2 - 0
lib/player.lua

@@ -135,10 +135,12 @@ function Player:slot(input)
   end
   
   if input.l and weapon:canFire(self) then
+    weapon:fire(self)
     ctx.net:emit(evtFire, {id = self.id, slot = self.weapon})
   end
   
   if input.r and skill:canFire(self) then
+    skill:fire(self)
     ctx.net:emit(evtFire, {id = self.id, slot = self.skill})
   end
 

+ 5 - 3
lib/players.lua

@@ -19,9 +19,11 @@ function Players:init()
   end)
   
   ctx.event:on(evtFire, function(data)
-    local p = self:get(data.id)
-    local slot = p.slots[data.slot]
-    slot:fire(p)
+    if data.id ~= ctx.id then
+      local p = self:get(data.id)
+      local slot = p.slots[data.slot]
+      slot:fire(p)
+    end
   end)
   
   ctx.event:on(evtDamage, function(data)