Advertisement
Guest User

Untitled

a guest
Aug 13th, 2015
244
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Weather simulation resource by vovo4ka
  2. -- ver 1.0
  3. -- e-mail: zolotayapipka@gmail.com
  4. --
  5. -- server side script
  6. -- cyclone sync
  7. cyclones = {{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}}
  8. --blips = {} --debug
  9.  
  10. function cyc_init()
  11. math.randomseed(getTickCount()/2)
  12. for i, cyc in pairs(cyclones) do
  13. cyclones[i][1]=math.random(4000)-2000 --posX
  14. cyclones[i][2]=math.random(4000)-2000 --posY
  15. cyclones[i][4]=math.random(60)-30 -- trend dx
  16. cyclones[i][5]=math.random(60)-30 -- dy
  17. cyclones[i][3]=math.random(1000)+100 -- radius of cyclone
  18. --blips[i]=createBlip ( cyclones[i][1], cyclones[i][2], 0, 41, 2)
  19. end
  20. end
  21.  
  22. cyc_init()
  23.  
  24. function cyc_process()
  25. for i, cyc in pairs(cyclones) do
  26. -- movin cyclones
  27. cyclones[i][1] = cyclones[i][1] + math.random(30)-15+cyclones[i][4]
  28. cyclones[i][2] = cyclones[i][2] + math.random(30)-15+cyclones[i][5]
  29. cyclones[i][3] = cyclones[i][3] - math.random(60)
  30. --destroyElement(blips[i]) --debug
  31. if (cyclones[i][3]<=200) then -- new cyclone
  32. cyclones[i][1]=math.random(4000)-2000
  33. cyclones[i][2]=math.random(4000)-2000
  34. cyclones[i][3]=math.random(1000)+100
  35. cyclones[i][4]=math.random(60)-30 -- dx
  36. cyclones[i][5]=math.random(60)-30 -- dy
  37. end
  38.  
  39. end
  40. -- sync with all players
  41. triggerClientEvent ( "AcceptCyclones", getRootElement(), cyclones[1][1], cyclones[1][2], cyclones[1][3],cyclones[2][1], cyclones[2][2], cyclones[2][3],cyclones[3][1], cyclones[3][2], cyclones[3][3])
  42. end
  43.  
  44. setTimer ( cyc_process, 5000, 0, 0)
Advertisement
RAW Paste Data Copied
Advertisement