Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This function creates a speedcamera (store data and create the objects)
- SetupSpeedCamera(Float:x, Float:y, Float:z, Float:rot, MaxSpeed)
- {
- // Setup local variables
- new Msg[128], SpeedMph;
- // Loop through all speed-camera slots
- for (new Slot; Slot < MAX_CAMERAS; Slot++)
- {
- // Check if this slot is available
- if (ACameras[Slot][CamSpeed] == 0)
- {
- // Store all the given values
- ACameras[Slot][CamX] = x;
- ACameras[Slot][CamY] = y;
- ACameras[Slot][CamZ] = z;
- ACameras[Slot][CamAngle] = rot;
- ACameras[Slot][CamSpeed] = MaxSpeed;
- // Calculate the speed in mph as well
- SpeedMph = floatround((float(MaxSpeed) / 1.6), floatround_round);
- // Create both camera objects and store their reference
- ACameras[Slot][CamObj1] = CreateDynamicObject(18880, x, y, z, 0.0, 0.0, rot);
- ACameras[Slot][CamObj2] = CreateDynamicObject(18880, x, y, z, 0.0, 0.0, rot + 180.0);
- // Update the draw distance of each camera to 300m, otherwise they could be invisible until you're standing right next to them
- // By default, dynamic objects have a draw distance of 0m, meaning they're only visible when you're very close to them
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ACameras[Slot][CamObj1], E_STREAMER_DRAW_DISTANCE, 300.0);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, ACameras[Slot][CamObj2], E_STREAMER_DRAW_DISTANCE, 300.0);
- format(Msg, 128, "Max-speed: %i kph / %i mph", MaxSpeed, SpeedMph);
- ACameras[Slot][Cam3DText] = CreateDynamic3DTextLabel(Msg, 0x008080FF, x, y, z + 5.0, 150.0);
- // Exit the function (speed-camera has been added succesfully)
- return Slot;
- }
- }
- // If no speed-camera could be added (no free slots), return -1 to indicate adding a speed-camera has failed
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment