Skip to content
  • 0 Unread 0
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Releases & Resources
  3. Rank System From My Z-tavern Simpled

Rank System From My Z-tavern Simpled

Scheduled Pinned Locked Moved BO2 Modding Releases & Resources
13 Posts 5 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Eizekiels Eizekiels

    Rank System Code Explanation

    1️⃣ πŸ”§ System Initialization

    • Defines storage paths for balance, rank, and rank colors.
    • Checks if the directories exist; if not, creates them automatically.
    • Binds chat commands (.rank, .rankup) and sets up player event handlers.

    2️⃣ πŸ’¬ Handling Player Commands

    • .rank β†’ Displays current rank with a unique color.
    • .rankup β†’ Checks if the player has enough money, upgrades their rank, and displays the new rank along with the next rank’s price.

    3️⃣ πŸ› οΈ Player Spawn Event

    • When a player spawns, a log message appears to track their progress.

    4️⃣ πŸ“‚ File Management

    • Rank and balance data are stored in files using getGuid(), ensuring each player has a unique file.

    5️⃣ πŸ’° Fetching & Managing Player Balance

    • Retrieves the current balance from the file. If the file is missing or corrupted, it defaults to 100 credits.
    • Updates the balance whenever a rank-up happens.

    6️⃣ πŸ† Fetching & Updating Player Rank

    • Retrieves the player’s current rank from their file, defaulting to "A" if the file doesn’t exist.
    • When ranking up, the system updates the rank file and notifies the player.

    7️⃣ πŸ“Š Displaying Rank Information

    • When typing .rank, the script shows the player’s current rank, its color, and the next rank’s cost in an aesthetically pleasing format.

    8️⃣ πŸ“ˆ Ranking Up System

    • When using .rankup:
      πŸ”Ή Checks if the player has enough money to rank up.
      πŸ”Ή Deducts the required amount from their balance.
      πŸ”Ή Updates the player's rank in both files and the game.
      πŸ”Ή Displays a confirmation message with the new rank and next rank price.

    9️⃣ 🎨 Rank Progression & Colors

    • Each rank has a unique color, ensuring better visual clarity.
    • The final rank (-X-) costs 6 billion to achieve.

    πŸ”Ή This system ensures a smooth and dynamic ranking process for players, allowing seamless progression with stored data!

    Code : ```
    #include maps\mp_utility;
    #include common_scripts\utility;
    #include maps\mp\zombies_zm_utility;

    init()
    {
    level.bank_folder = "D:\bo2 ztavern town\storage\t6\bank";
    level.rank_folder = "D:\bo2 ztavern town\storage\t6\tag";
    level.color_folder = "D:\bo2 ztavern town\storage\t6\tagColor";

    if (!directoryExists(level.bank_folder))
        createDirectory(level.bank_folder);
    
    if (!directoryExists(level.rank_folder))
        createDirectory(level.rank_folder);
    
    if (!directoryExists(level.color_folder))
        createDirectory(level.color_folder);
    
    onPlayerSay(::player_say);
    level.onPlayerSpawned = ::onPlayerSpawned;
    

    }

    player_say(message, mode)
    {
    message = toLower(message);

    if (message == ".rank")
    {
        self display_rank();
        return false;
    }
    else if (message == ".rankup")
    {
        self rank_up();
        return false;
    }
    
    return true;
    

    }

    onPlayerSpawned()
    {
    self endon("disconnect");
    self waittill("spawned_player");

    print(va("πŸ› οΈ %s has spawned. Checking for available purchases...", self.name));
    

    }

    get_rank_filename() { return level.rank_folder + "\" + self getGuid() + ".txt"; }
    get_bank_filename() { return level.bank_folder + "\" + self getGuid() + ".txt"; }

    get_balance()
    {
    filename = get_bank_filename();
    if (fileExists(filename))
    {
    balance_str = readFile(filename);
    return balance_str ? parseInt(balance_str) : 100; // Default balance is 100 if file doesn't exist or invalid
    }
    return 100; // Default balance if no file exists
    }

    set_balance(new_balance)
    {
    filename = get_bank_filename();
    writeFile(filename, new_balance);
    }

    get_rank()
    {
    filename = get_rank_filename();
    return fileExists(filename) ? readFile(filename) : "A"; // Default rank is A if file doesn't exist
    }

    set_rank(new_rank)
    {
    filename = get_rank_filename();
    writeFile(filename, new_rank);
    }

    display_rank()
    {
    rank = self get_rank();
    self tell(va("Your current rank: %s", rank));

    next_rank = get_next_rank(rank);
    if (next_rank != "")
    {
        next_price = get_rank_price(next_rank);
        self tell(va("Next rank: %s | Price: %d", next_rank, next_price));
    }
    else
    {
        self tell("^1You have reached the highest rank!");
    }
    

    }

    rank_up()
    {
    rank = self get_rank();
    next_rank = get_next_rank(rank);

    if (next_rank == "")
    {
        self tell("^1You are already at the highest rank!");
        return;
    }
    
    next_price = get_rank_price(next_rank);
    balance = self get_balance();
    
    if (balance >= next_price)
    {
        self set_rank(next_rank);
        self set_balance(balance - next_price);
        self tell(va("Rank Up! New Rank: %s | Remaining Balance: %d", next_rank, balance - next_price));
    }
    else
    {
        self tell("^1You don't have enough money to rank up!");
    }
    

    }

    get_next_rank(current_rank)
    {
    switch (current_rank)
    {
    case "A": return "B";
    case "B": return "C";
    case "C": return "D";
    case "D": return "E";
    case "E": return "F";
    case "F": return "G";
    case "G": return "H";
    case "H": return "S";
    case "S": return "SS";
    case "SS": return "SSS";
    case "SSS": return "V";
    case "V": return "IV";
    case "IV": return "IIV";
    case "IIV": return "IIIV";
    case "IIIV": return "I";
    case "I": return "II";
    case "II": return "III";
    case "III": return "IX";
    case "IX": return "IIX";
    case "IIX": return "IIIX";
    case "IIIX": return "-X-"; // Max rank
    default: return "";
    }
    }

    get_rank_price(rank)
    {
    switch (rank)
    {
    case "A": return 1000;
    case "B": return 5000;
    case "C": return 15000;
    case "D": return 20000;
    case "E": return 45000;
    case "F": return 60000;
    case "G": return 120000;
    case "H": return 500000;
    case "S": return 1000000;
    case "SS": return 2000000;
    case "SSS": return 3000000;
    case "V": return 4000000;
    case "IV": return 5000000;
    case "IIV": return 10000000;
    case "IIIV": return 15000000;
    case "I": return 20000000;
    case "II": return 25000000;
    case "III": return 30000000;
    case "IX": return 40000000;
    case "IIX": return 50000000;
    case "IIIX": return 100000000;
    case "-X-": return 6000000000; // Max rank price (6 billion)
    default: return 0;
    }
    }

    Note : it needs this plugin to work (t6-gsc-utils)
    Note : This code old version from my rank system it is the first ranking system.
    Note : The code have some bugs.
    I cannot share the full code because it is private for my Z-Tavern server.
    DirkRockface Offline
    DirkRockface Offline
    DirkRockface
    Contributor
    wrote on last edited by
    #2

    Eizekiels I have a similar system... mine does bank, rank, kills, and high rounds

    I also wrote i python script that sorts and ranks them so you can also do a leaderboard call.

    let me know if you would like me to help you with any bugs, or make it so you don't need the t6-utils anymore. Data collection and display is one of my nerdy passions πŸ˜„

    Dec Eizekiels mahmodhalah2 3 Replies Last reply
    0
    • DirkRockface DirkRockface

      Eizekiels I have a similar system... mine does bank, rank, kills, and high rounds

      I also wrote i python script that sorts and ranks them so you can also do a leaderboard call.

      let me know if you would like me to help you with any bugs, or make it so you don't need the t6-utils anymore. Data collection and display is one of my nerdy passions πŸ˜„

      Dec Offline
      Dec Offline
      Dec
      Contributor
      wrote on last edited by
      #3

      DirkRockface can you add me on discord?, would like to speak with you.

      weedliketosmoke

      1 Reply Last reply
      1
      • DirkRockface DirkRockface

        Eizekiels I have a similar system... mine does bank, rank, kills, and high rounds

        I also wrote i python script that sorts and ranks them so you can also do a leaderboard call.

        let me know if you would like me to help you with any bugs, or make it so you don't need the t6-utils anymore. Data collection and display is one of my nerdy passions πŸ˜„

        Eizekiels Offline
        Eizekiels Offline
        Eizekiels
        wrote on last edited by
        #4

        DirkRockface I retired from the game and turned off my servers. I moved to the game Rust and created servers in it under the name S-Tavern

        DirkRockface 1 Reply Last reply
        0
        • Eizekiels Eizekiels

          DirkRockface I retired from the game and turned off my servers. I moved to the game Rust and created servers in it under the name S-Tavern

          DirkRockface Offline
          DirkRockface Offline
          DirkRockface
          Contributor
          wrote on last edited by
          #5

          Eizekiels aaaa gotcha, you just donating old code before you erase all your bo2 stuff πŸ˜„

          Rhyan 1 Reply Last reply
          0
          • DirkRockface DirkRockface

            Eizekiels I have a similar system... mine does bank, rank, kills, and high rounds

            I also wrote i python script that sorts and ranks them so you can also do a leaderboard call.

            let me know if you would like me to help you with any bugs, or make it so you don't need the t6-utils anymore. Data collection and display is one of my nerdy passions πŸ˜„

            mahmodhalah2 Offline
            mahmodhalah2 Offline
            mahmodhalah2
            wrote on last edited by
            #6

            DirkRockface we're can I find it I need it

            DirkRockface 1 Reply Last reply
            0
            • mahmodhalah2 mahmodhalah2

              DirkRockface we're can I find it I need it

              DirkRockface Offline
              DirkRockface Offline
              DirkRockface
              Contributor
              wrote on last edited by
              #7

              mahmodhalah2 find me on discord! happy to help you with yours.

              mahmodhalah2 1 Reply Last reply
              0
              • DirkRockface DirkRockface

                mahmodhalah2 find me on discord! happy to help you with yours.

                mahmodhalah2 Offline
                mahmodhalah2 Offline
                mahmodhalah2
                wrote on last edited by
                #8

                DirkRockface this my dis user : abo_al_7alah

                1 Reply Last reply
                0
                • DirkRockface DirkRockface referenced this topic on
                • Rhyan Offline
                  Rhyan Offline
                  Rhyan
                  wrote on last edited by
                  #9
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • DirkRockface DirkRockface

                    Eizekiels aaaa gotcha, you just donating old code before you erase all your bo2 stuff πŸ˜„

                    Rhyan Offline
                    Rhyan Offline
                    Rhyan
                    wrote on last edited by
                    #10
                    This post is deleted!
                    DirkRockface Eizekiels 2 Replies Last reply
                    0
                    • Rhyan Rhyan

                      This post is deleted!

                      DirkRockface Offline
                      DirkRockface Offline
                      DirkRockface
                      Contributor
                      wrote on last edited by DirkRockface
                      #11

                      @Reincernated no, i'm good. fake accounts can't hurt me... thanks though!

                      1 Reply Last reply
                      0
                      • Rhyan Rhyan

                        This post is deleted!

                        Eizekiels Offline
                        Eizekiels Offline
                        Eizekiels
                        wrote on last edited by
                        #12

                        @Reincernated why report i just got the user πŸ™‚ who say to him delete his acc?

                        1 Reply Last reply
                        0
                        • Rhyan Offline
                          Rhyan Offline
                          Rhyan
                          wrote on last edited by
                          #13
                          This post is deleted!
                          1 Reply Last reply
                          0

                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                          With your input, this post could be even better πŸ’—

                          Register Login
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Unread 0
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Donate