Viny_Tecchio

Untitled

Jan 15th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1.  
  2. // This function creates a speedcamera (store data and create the objects)
  3. SetupSpeedCamera(Float:x, Float:y, Float:z, Float:rot, MaxSpeed)
  4. {
  5. // Setup local variables
  6. new Msg[128], SpeedMph;
  7.  
  8. // Loop through all speed-camera slots
  9. for (new Slot; Slot < MAX_CAMERAS; Slot++)
  10. {
  11. // Check if this slot is available
  12. if (ACameras[Slot][CamSpeed] == 0)
  13. {
  14. // Store all the given values
  15. ACameras[Slot][CamX] = x;
  16. ACameras[Slot][CamY] = y;
  17. ACameras[Slot][CamZ] = z;
  18. ACameras[Slot][CamAngle] = rot;
  19. ACameras[Slot][CamSpeed] = MaxSpeed;
  20. // Calculate the speed in mph as well
  21. SpeedMph = floatround((float(MaxSpeed) / 1.6), floatround_round);
  22. // Create both camera objects and store their reference
  23. ACameras[Slot][CamObj1] = CreateDynamicObject(18880, x, y, z, 0.0, 0.0, rot);
  24. ACameras[Slot][CamObj2] = CreateDynamicObject(18880, x, y, z, 0.0, 0.0, rot + 180.0);
  25.  
  26. // Update the draw distance of each camera to 300m, otherwise they could be invisible until you're standing right next to them
  27. // By default, dynamic objects have a draw distance of 0m, meaning they're only visible when you're very close to them
  28. Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ACameras[Slot][CamObj1], E_STREAMER_DRAW_DISTANCE, 300.0);
  29. Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ACameras[Slot][CamObj2], E_STREAMER_DRAW_DISTANCE, 300.0);
  30.  
  31. format(Msg, 128, "Max-speed: %i kph / %i mph", MaxSpeed, SpeedMph);
  32. ACameras[Slot][Cam3DText] = CreateDynamic3DTextLabel(Msg, 0x008080FF, x, y, z + 5.0, 150.0);
  33.  
  34. // Exit the function (speed-camera has been added succesfully)
  35. return Slot;
  36. }
  37. }
  38.  
  39. // If no speed-camera could be added (no free slots), return -1 to indicate adding a speed-camera has failed
  40. return -1;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment