Szerző Téma: PPC Traffipax  (Megtekintve 1306 alkalommal)

PPC Traffipax
« Dátum: 2014. Szeptember 24. - 22:10:06 »
0 Show voters
Sziasztok!
Hogy tudnám meg irni a ppc módomba azt hogy traffipax kreálásakor hozzon létre egy textlabelt amiben irja a sebességkorlátott?
Köszönöm.
 
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);
             // 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 command
return 1;
}

 

enum TSpeedCamera
{
Float:CamX, // Holds the X-coordinate of the camera
Float:CamY, // Holds the Y-coordinate of the camera
Float:CamZ, // Holds the Z-coordinate of the camera
Float:CamAngle, // Holds the Angle of the camera
CamSpeed, // Holds the maximum speed allowed to pass this camera without being caught
CamObj1, // Holds the reference to the first camera object
Text3D:SpeedText, // Sebbeség mutatása
Owned, // Lerakó neve
CamObj2 // Holds the reference to the second camera object
}

 

// This function loads all speedcameras
Camera_LoadAll()
{
// Loop through all cameras and try to load them
for (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 variables
new 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-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
   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);
return 1; // Return that the file was read correctly
}
else
    return 0; // Return 0 if the file couldn\'t be read (doesn\'t exist)
}
« Utoljára szerkesztve: 2014. Szeptember 25. - 22:32:39 írta [SDW]BlackJack »

Nem elérhető huhboy

  • 894
  • huhboy
    • Profil megtekintése
PPC Traffipax
« Válasz #1 Dátum: 2014. Szeptember 25. - 10:15:46 »
0 Show voters
a parancshoz, ahol a traffit létrehozod, az object koordinátáira rakod....stringgel pedig megformázod a traffi értékével.

Nem elérhető ZSOLTI99

  • 1827
    • Profil megtekintése
PPC Traffipax
« Válasz #2 Dátum: 2014. Szeptember 25. - 18:21:04 »
0 Show voters

Nem elérhető huhboy

  • 894
  • huhboy
    • Profil megtekintése
PPC Traffipax
« Válasz #3 Dátum: 2014. Szeptember 25. - 22:37:25 »
+1 Show voters
ezeket cseréld le, jónak kell lennie...
 

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)
}
« Utoljára szerkesztve: 2014. Szeptember 25. - 22:48:49 írta JustaCube »

Nem elérhető Flash

  • 5726
  • (っ◕‿◕)っ
    • Profil megtekintése
PPC Traffipax
« Válasz #4 Dátum: 2014. Október 09. - 15:33:19 »
0 Show voters
[mod]Ha megoldódott a problémád, zárd a témát![/mod]

PPC Traffipax
« Válasz #5 Dátum: 2014. Október 10. - 06:35:56 »
0 Show voters
Egyenlõre még nem szeretném zárni mivel nem akarja a textlabelt el tüntetni kamera törlésénél..

Nem elérhető ZSOLTI99

  • 1827
    • Profil megtekintése
PPC Traffipax
« Válasz #6 Dátum: 2014. Október 10. - 16:47:32 »
0 Show voters
http://wiki.sa-mp.com/wiki/Delete3DTextLabel segítségével lehet törölni

PPC Traffipax
« Válasz #7 Dátum: 2014. Október 10. - 17:51:59 »
0 Show voters
Köszönöm, most töröl de csak azt amit elsõnek leteszel...  :confused:
https://www.youtube.com/watch?v=-Pd5dfdR8_k&feature=youtu.be - Videó

PPC Traffipax
« Válasz #8 Dátum: 2014. Október 10. - 19:52:21 »
0 Show voters
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;
}

 
Törlésnél pedig:
 
Delete3DTextLabel(ACameras[CamID][speedText]);

PPC Traffipax
« Válasz #9 Dátum: 2014. Október 10. - 20:31:20 »
0 Show voters
Tökéletes!
Amúgy a törlésnél én is azt irtam, szóval JustaCube irta hibásan.
Köszönöm mindenkinek, zárok!

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal