Advertisement
Rochet2

Untitled

Oct 31st, 2012
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. -- Dont save variables that are only used in a function here.
  2. math.randomseed(os.time())
  3.  
  4. local function randomed(unit)
  5.     local x = math.random(1,7) -- get a random number
  6.    
  7.     -- move the unit according to the random number
  8.     if(x == 1) then
  9.         unit:MoveTo(2979.748535, -715.599365, 199.985168, 4.919563)
  10.     elseif(x == 2) then
  11.         unit:MoveTo(2987.003418, -713.099976, 200.049011, 3.668829)
  12.     elseif(x == 3) then
  13.         unit:MoveTo(2994.281250, -738.047302, 199.494217, 2.432610)
  14.     elseif(x == 4) then
  15.         unit:MoveTo(2985.814941,  -740.546997, 199.494217, 1.363672)
  16.     elseif(x == 5) then
  17.         unit:MoveTo(2987.078125, -727.422546, 198.364029, 3.47735)
  18.     elseif(x == 6) then
  19.         unit:MoveTo(2984.369873, -717.506409, 199.514359, 5.063842)
  20.     elseif(x == 7) then
  21.         unit:MoveTo(2993.147949, -725.345764, 198.382935, 5.574349)
  22.     end
  23. end
  24.  
  25. local function RunningCitizens(unit, event)
  26.     -- On spawn add aura and move to a random point every 3 seconds.
  27.     unit:AddAura(15661, 99999999999999) -- use 0 for infinite
  28.     randomed(unit) -- Since the timed event runs the first time after 3 seconds from spawning, the function should be ran instantly on spawn once
  29.     CreateLuaEvent(function() randomed(unit) end, 3000, 0) -- 0 instead of 1. This way they will do it every 3 seconds forever. When the water spell hits the NPC, use unit:RemoveEvents() to stop the running.
  30.    
  31. end
  32.  
  33. RegisterUnitEvent(63007, 18, RunningCitizens)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement