Advertisement
Guest User

Untitled

a guest
Apr 6th, 2013
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.13 KB | None | 0 0
  1. #include a_samp
  2.  
  3. /*
  4. Testing the smooth movement of arrows using sin()
  5.  
  6. Obviously the timer is very rapid, so to compensate, I would have to make them
  7. 'streamed' - i.e. only animated if players are near (perhaps within 100 meters)
  8. */
  9.  
  10. #define ARROW_MODEL 19198
  11. #define ANIMATION_FPS 30 // Timer calls per second
  12.  
  13. new arrow, step;
  14. new arrow2, step2;
  15.  
  16. public OnFilterScriptInit()
  17. {
  18.     arrow = CreateObject(ARROW_MODEL, 0, 0, 4, 0, 0, 0);
  19.     SetTimer("DoAnimFrame", 1000/ANIMATION_FPS, true);
  20.    
  21.     arrow2 = CreateObject(ARROW_MODEL, 0, 2, 4, 0, 0, 0);
  22.     CallLocalFunction("OnObjectMoved", "i", arrow2);
  23. }
  24.  
  25. public OnFilterScriptExit()
  26. {
  27.     DestroyObject(arrow);
  28.     DestroyObject(arrow2);
  29.     return 1;
  30. }
  31.  
  32. forward DoAnimFrame();
  33. public DoAnimFrame()
  34. {
  35.     SetObjectPos(arrow, 0.0, 0.0, 4.0+(floatsin(float(step), degrees)/2));
  36.     step += 5;
  37.     if(step == 360) step = 0;
  38.     return 1;
  39. }
  40.  
  41. public OnObjectMoved(objectid)
  42. {
  43.     if(objectid == arrow2)
  44.     {
  45.         if(step2 == 0) // First move - UP
  46.         {
  47.             MoveObject(arrow2, 0, 2, 3.5+1, 0.85);
  48.         }
  49.         else // DOWN
  50.         {
  51.             MoveObject(arrow2, 0, 2, 3.5, 0.85);
  52.         }
  53.  
  54.         step2 = !step2;
  55.     }
  56.     return 1;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement