slp13at420

WD 3100 kill drop script

Jan 2nd, 2013 (edited)
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. -- by Black Wolf of blackwolfsden aka Grumbo of EmuDevs.com aka slp13at420 of ac-web.org
  2. -- custom item drop for creature 3100
  3. -- when npc dies this script will act as auto looting
  4. -- generates a random number between 1 n 25 then applies to variable a
  5. -- adds item 44209 x a
  6. -- adds to mg column in db +3 mg
  7. -- completely reworked to function for individual player or group members by Rochet2 of ac-web.org
  8. local NPCID = 3100
  9.  
  10. local function reward(player)
  11.  
  12.         player:AddItem(44209, math.random(1, 25))
  13.  
  14.         WorldDBQuery("UPDATE logon.accounts SET `mg` = `mg` + '3' WHERE `login` = '"..player:GetAccountName().."' LIMIT 1; ")
  15.  
  16.         player:SendBroadcastMessage("+3 mg earned")
  17. end
  18.  
  19. local function Mottledboar_Unit_EVENT_ON_DIED(pUnit, event, player)
  20.  
  21.         if(player:IsInGroup()) then
  22.  
  23.                 for _, v in pairs(player:GetGroupPlayers()) do
  24.  
  25.                         if(v and v:IsInWorld()) then
  26.  
  27.                                reward(v)
  28.                        end
  29.                 end
  30.  
  31.         else -- I assume GetGroupPlayers includes the killer also
  32.  
  33.                 reward(player)
  34.          end
  35.  end
  36.  
  37.  
  38. RegisterUnitEvent(NPCID, 4, Mottledboar_Unit_EVENT_ON_DIED)
Add Comment
Please, Sign In to add comment