Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include a_samp
- /*
- Testing the smooth movement of arrows using sin()
- Obviously the timer is very rapid, so to compensate, I would have to make them
- 'streamed' - i.e. only animated if players are near (perhaps within 100 meters)
- */
- #define ARROW_MODEL 19198
- #define ANIMATION_FPS 30 // Timer calls per second
- new arrow, step;
- new arrow2, step2;
- public OnFilterScriptInit()
- {
- arrow = CreateObject(ARROW_MODEL, 0, 0, 4, 0, 0, 0);
- SetTimer("DoAnimFrame", 1000/ANIMATION_FPS, true);
- arrow2 = CreateObject(ARROW_MODEL, 0, 2, 4, 0, 0, 0);
- CallLocalFunction("OnObjectMoved", "i", arrow2);
- }
- public OnFilterScriptExit()
- {
- DestroyObject(arrow);
- DestroyObject(arrow2);
- return 1;
- }
- forward DoAnimFrame();
- public DoAnimFrame()
- {
- SetObjectPos(arrow, 0.0, 0.0, 4.0+(floatsin(float(step), degrees)/2));
- step += 5;
- if(step == 360) step = 0;
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- if(objectid == arrow2)
- {
- if(step2 == 0) // First move - UP
- {
- MoveObject(arrow2, 0, 2, 3.5+1, 0.85);
- }
- else // DOWN
- {
- MoveObject(arrow2, 0, 2, 3.5, 0.85);
- }
- step2 = !step2;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement