stoneharry

Untitled

Apr 2nd, 2011
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. local players = {}
  2. local welcome_back = {}
  3.  
  4. function OnSpawn(pUnit, Event)
  5.   pUnit:RegisterEvent("CheckForPlayers", 2000, 0)
  6. end
  7.  
  8. function CheckForPlayers(pUnit)
  9.         print("function called")
  10.     for place,plr in pairs(pUnit:GetInRangePlayers()) do
  11.         if plr ~= nil then
  12. print("plr not nil")
  13.             if pUnit:GetDistanceYards(plr) < 10 then
  14. print("plr close enough")
  15.                 for plce,plrs in pairs(players) do
  16.                     if plrs ~= plr:GetName() then
  17. print("plr is new")
  18.                         pUnit:SendChatMessage(12,0,"Welcome To The Alliance Mall "..pPlayer:GetName().."!")
  19.                         table.insert(players, plr:GetName())
  20.                     else
  21. print("plr not new")
  22.                         for plc, plas in pairs(welcome_back) do
  23. print("preparing to send message saying welcome back")
  24.                             if plas ~= plr:GetName() then
  25. print("sending message welcome back")
  26.                                 pUnit:SendChatMessage(12,0,"Welcome back "..pPlayer:GetName().."!")
  27.                                 table.insert(welcome_back, plr:GetName())
  28.                             end
  29.                         end
  30.                     end
  31.                 end
  32.             end
  33.         end
  34.     end
  35. end
  36.  
  37. RegisterUnitEvent(80051, 18, "OnSpawn")
Advertisement
Add Comment
Please, Sign In to add comment