COMMAND:createcamera(playerid, params[]){// Setup local variablesnew Float:x, Float:y, Float:z, Float:Angle, MaxSpeed, file[100], File:PFile, LineForFile[100], Msg[128];// Send the command to all admins so they can see itSendAdminText(playerid, \"/createcamera\", params);// Check if the player has logged inif (APlayerData[playerid][LoggedIn] == true){// Check if the player\'s admin-level is at least 5if (APlayerData[playerid][PlayerLevel] >= 5){ if (sscanf(params, \"i\", MaxSpeed)) SendClientMessage(playerid, 0xFF0000AA, \"[Használat]: \\\"/createcamera <max_sebesség>\\\"\"); else { // Get player\'s position and facing angle GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, Angle); z = z - 1.0; // Adjust camera Z-coordinate 1m lower than normal (otherwise the camera floats in the air) // Move the player a bit, otherwise he could get stuck inside the camera-object SetPlayerPos(playerid, x, y + 1.0, z + 1.0); // Save the camera to a file for (new CamID; CamID < MAX_CAMERAS; CamID++) { // Check if this index is free if (ACameras[CamID][CamSpeed] == 0) { // Setup this camera (create the objects and store the data) SetupSpeedCamera(CamID, x, y, z, Angle, MaxSpeed); // Save the file format(file, sizeof(file), CameraFile, CamID); // Construct the complete filename for this camera-file PFile = fopen(file, io_write); // Open the camera-file for writing format(LineForFile, 100, \"CamX %f\\r\\n\", x); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"CamY %f\\r\\n\", y); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"CamZ %f\\r\\n\", z); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"CamAngle %f\\r\\n\", Angle); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"CamSpeed %i\\r\\n\", MaxSpeed); fwrite(PFile, LineForFile); // And save it to the file fclose(PFile); // Close the file // Let the player know he created a new camera format(Msg, 128, \"Sikeresen leraktál egy traffipaxot, ID: %i\", CamID); SendClientMessage(playerid, 0x00FF00FF, Msg); // Exit the function return 1; } } // In case all camera-slots are occupied (100 camera\'s have been created already), let the player know about it format(Msg, 128, \"{FF0000}Nem birsz több traffipaxot lerakni, maximális traffipaxok száma: %i\", MAX_CAMERAS); SendClientMessage(playerid, 0xFFFFFFFF, Msg); }}else return 0;}else return 0;// Let the server know that this was a valid commandreturn 1;}
enum TSpeedCamera{Float:CamX, // Holds the X-coordinate of the cameraFloat:CamY, // Holds the Y-coordinate of the cameraFloat:CamZ, // Holds the Z-coordinate of the cameraFloat:CamAngle, // Holds the Angle of the cameraCamSpeed, // Holds the maximum speed allowed to pass this camera without being caughtCamObj1, // Holds the reference to the first camera objectText3D:SpeedText, // Sebbeség mutatásaOwned, // Lerakó neveCamObj2 // Holds the reference to the second camera object}
// This function loads all speedcamerasCamera_LoadAll(){// Loop through all cameras and try to load themfor (new CamID; CamID < MAX_CAMERAS; CamID++){ // Try to load the file and check if it was succesfully loaded (file exists)if (CameraFile_Load(CamID) == 1){ // Save the number of camera\'s that have been loaded, so it can be displayed TotalCameras++;}}return 1;} // This function will load the speedcamera\'s datafile (used when the server is started to load all cameras)CameraFile_Load(CamID){// Setup local variablesnew file[100], File:CFile, LineFromFile[100], ParameterName[50], ParameterValue[50];new Float:x, Float:y, Float:z, Float:rot, MaxSpeed;format(file, sizeof(file), CameraFile, CamID); // Construct the complete filename for this camera-fileif (fexist(file)){CFile = fopen(file, io_read); // Open the camerafile for readingfread(CFile, LineFromFile); // Read the first line of the file// Keep reading until the end of the file is found (no more data)while (strlen(LineFromFile) > 0){ StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile sscanf(LineFromFile, \"s[50]s[50]\", ParameterName, ParameterValue); // Extract parametername and parametervalue // Store the proper value in the proper place if (strcmp(ParameterName, \"CamX\", false) == 0) // If the parametername is correct (\"CamX\") x = floatstr(ParameterValue); // Store the CamX if (strcmp(ParameterName, \"CamY\", false) == 0) // If the parametername is correct (\"CamY\") y = floatstr(ParameterValue); // Store the CamY if (strcmp(ParameterName, \"CamZ\", false) == 0) // If the parametername is correct (\"CamZ\") z = floatstr(ParameterValue); // Store the CamZ if (strcmp(ParameterName, \"CamAngle\", false) == 0) // If the parametername is correct (\"CamAngle\") rot = floatstr(ParameterValue); // Store the CamAngle if (strcmp(ParameterName, \"CamSpeed\", false) == 0) // If the parametername is correct (\"CamSpeed\") MaxSpeed = strval(ParameterValue); // Store the CamSpeed fread(CFile, LineFromFile); // Read the next line of the file}fclose(CFile); // Close the file// All data has been read about the camera, now setup the cameraSetupSpeedCamera(CamID, x, y, z, rot, MaxSpeed);return 1; // Return that the file was read correctly}else return 0; // Return 0 if the file couldn\'t be read (doesn\'t exist)}
COMMAND:createcamera(playerid, params[]){ // Setup local variables new Float:x, Float:y, Float:z, Float:Angle, MaxSpeed, file[100], File:PFile, LineForFile[100], Msg[128]; // Send the command to all admins so they can see it SendAdminText(playerid, \"/createcamera\", params); // Check if the player has logged in if (APlayerData[playerid][LoggedIn] == true) { // Check if the player\'s admin-level is at least 5 if (APlayerData[playerid][PlayerLevel] >= 5) { if (sscanf(params, \"i\", MaxSpeed)) SendClientMessage(playerid, 0xFF0000AA, \"[Használat]: \\\"/createcamera <max_sebesség>\\\"\"); else { // Get player\'s position and facing angle GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, Angle); z = z - 1.0; // Adjust camera Z-coordinate 1m lower than normal (otherwise the camera floats in the air) // Move the player a bit, otherwise he could get stuck inside the camera-object SetPlayerPos(playerid, x, y + 1.0, z + 1.0); // Save the camera to a file for (new CamID; CamID < MAX_CAMERAS; CamID++) { // Check if this index is free if (ACameras[CamID][CamSpeed] == 0) { // Setup this camera (create the objects and store the data) SetupSpeedCamera(CamID, x, y, z, Angle, MaxSpeed); new str[256]; format(str, sizeof(str), \"Megengedett sebesség: %d km/h!\", MaxSpeed); Create3DTextLabel(str, 0xff0000aa, x, y, z, 80, 0, 0); // Save the file format(file, sizeof(file), CameraFile, CamID); // Construct the complete filename for this camera-file PFile = fopen(file, io_write); // Open the camera-file for writing format(LineForFile, 100, \"CamX %f\\r\\n\", x); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"CamY %f\\r\\n\", y); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"CamZ %f\\r\\n\", z); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"CamAngle %f\\r\\n\", Angle); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"CamSpeed %i\\r\\n\", MaxSpeed); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"Megengedett sebesség: %dkm/h!\", MaxSpeed); fwrite(PFile,LineForFile); fclose(PFile); // Close the file // Let the player know he created a new camera format(Msg, 128, \"Sikeresen leraktál egy traffipaxot, ID: %i\", CamID); SendClientMessage(playerid, 0x00FF00FF, Msg); // Exit the function return 1; } } // In case all camera-slots are occupied (100 camera\'s have been created already), let the player know about it format(Msg, 128, \"{FF0000}Nem birsz több traffipaxot lerakni, maximális traffipaxok száma: %i\", MAX_CAMERAS); SendClientMessage(playerid, 0xFFFFFFFF, Msg); } } else return 0; } else return 0; // Let the server know that this was a valid command return 1;}// This function will load the speedcamera\'s datafile (used when the server is started to load all cameras)CameraFile_Load(CamID){ // Setup local variables new file[100], File:CFile, LineFromFile[100], ParameterName[50], ParameterValue[50],text[100]; new Float:x, Float:y, Float:z, Float:rot, MaxSpeed; format(file, sizeof(file), CameraFile, CamID); // Construct the complete filename for this camera-file if (fexist(file)) { CFile = fopen(file, io_read); // Open the camerafile for reading fread(CFile, LineFromFile); // Read the first line of the file // Keep reading until the end of the file is found (no more data) while (strlen(LineFromFile) > 0) { StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile sscanf(LineFromFile, \"s[50]s[50]\", ParameterName, ParameterValue); // Extract parametername and parametervalue // Store the proper value in the proper place if (strcmp(ParameterName, \"CamX\", false) == 0) // If the parametername is correct (\"CamX\") x = floatstr(ParameterValue); // Store the CamX if (strcmp(ParameterName, \"CamY\", false) == 0) // If the parametername is correct (\"CamY\") y = floatstr(ParameterValue); // Store the CamY if (strcmp(ParameterName, \"CamZ\", false) == 0) // If the parametername is correct (\"CamZ\") z = floatstr(ParameterValue); // Store the CamZ if (strcmp(ParameterName, \"CamAngle\", false) == 0) // If the parametername is correct (\"CamAngle\") rot = floatstr(ParameterValue); // Store the CamAngle if (strcmp(ParameterName, \"CamSpeed\", false) == 0) // If the parametername is correct (\"CamSpeed\") MaxSpeed = strval(ParameterValue); // Store the CamSpeed if (strcmp(ParameterName, \"Megengedett\", false) == 0) // If the parametername is correct (\"CamSpeed\") format(text, sizeof(text), \"%s\",ParameterValue); fread(CFile, LineFromFile); // Read the next line of the file } fclose(CFile); // Close the file // All data has been read about the camera, now setup the camera SetupSpeedCamera(CamID, x, y, z, rot, MaxSpeed); Create3DTextLabel(text, 0xff0000aa, x,y,z, 80, 0, 0); return 1; // Return that the file was read correctly } else return 0; // Return 0 if the file couldn\'t be read (doesn\'t exist)}
COMMAND:createcamera(playerid, params[]){ // Setup local variables new Float:x, Float:y, Float:z, Float:Angle, MaxSpeed, file[100], File:PFile, LineForFile[100], Msg[128]; // Send the command to all admins so they can see it SendAdminText(playerid, \"/createcamera\", params); // Check if the player has logged in if (APlayerData[playerid][LoggedIn] == true) { // Check if the player\'s admin-level is at least 5 if (APlayerData[playerid][PlayerLevel] >= 5) { if (sscanf(params, \"i\", MaxSpeed)) SendClientMessage(playerid, 0xFF0000AA, \"[Használat]: \\\"/createcamera <max_sebesség>\\\"\"); else { // Get player\'s position and facing angle GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, Angle); z = z - 1.0; // Adjust camera Z-coordinate 1m lower than normal (otherwise the camera floats in the air) // Move the player a bit, otherwise he could get stuck inside the camera-object SetPlayerPos(playerid, x, y + 1.0, z + 1.0); // Save the camera to a file for (new CamID; CamID < MAX_CAMERAS; CamID++) { // Check if this index is free if (ACameras[CamID][CamSpeed] == 0) { // Setup this camera (create the objects and store the data) SetupSpeedCamera(CamID, x, y, z, Angle, MaxSpeed); new str[256]; format(str, sizeof(str), \"Megengedett sebesség: %d km/h!\", MaxSpeed); ACameras[CamID][speedText] = Create3DTextLabel(str, 0xff0000aa, x, y, z, 80, 0, 0); // Save the file format(file, sizeof(file), CameraFile, CamID); // Construct the complete filename for this camera-file PFile = fopen(file, io_write); // Open the camera-file for writing format(LineForFile, 100, \"CamX %f\\r\\n\", x); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"CamY %f\\r\\n\", y); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"CamZ %f\\r\\n\", z); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"CamAngle %f\\r\\n\", Angle); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"CamSpeed %i\\r\\n\", MaxSpeed); fwrite(PFile, LineForFile); // And save it to the file format(LineForFile, 100, \"Megengedett sebesség: %dkm/h!\", MaxSpeed); fwrite(PFile,LineForFile); fclose(PFile); // Close the file // Let the player know he created a new camera format(Msg, 128, \"Sikeresen leraktál egy traffipaxot, ID: %i\", CamID); SendClientMessage(playerid, 0x00FF00FF, Msg); // Exit the function return 1; } } // In case all camera-slots are occupied (100 camera\'s have been created already), let the player know about it format(Msg, 128, \"{FF0000}Nem birsz több traffipaxot lerakni, maximális traffipaxok száma: %i\", MAX_CAMERAS); SendClientMessage(playerid, 0xFFFFFFFF, Msg); } } else return 0; } else return 0; // Let the server know that this was a valid command return 1;}
Delete3DTextLabel(ACameras[CamID][speedText]);