A
A
aid1755308142020-11-04 01:45:27
PHP
aid175530814, 2020-11-04 01:45:27

I don't understand what is wrong, can you help?

at

$playerName = RankIds::PREFIX_LIST[$rank] . ($isPlayer ? "§7" : " ") . DataStorage::getValue($playerName, DataStorage::REAL_NAMES, $playerName);

gives an error message
ErrorException: "Undefined offset: 8" (EXCEPTION) in "plugins/StatisticsAPI/src/statisticsapi/StatisticsAPI" at line 226.


Self RankIds
<?php

declare(strict_types=1);

namespace core\utils\types;

interface RankIds{
  public const PLAYER = 0;
  public const RECRUIT = 1;
  public const PRIME = 2;
  public const YT = 3;
  public const IMMORTAL = 4;
  public const EXPERIENCED = 5;
  public const HELPER = 6;
  public const OWNER = 0xff;
  
  public const PREFIX_LIST = [
    RankIds::PLAYER => "",
    RankIds::RECRUIT => RankIds::COLOR_LIST[RankIds::RECRUIT] ."§lRecruit§r",
    RankIds::PRIME => RankIds::COLOR_LIST[RankIds::PRIME] ."§lPrime§r",
    RankIds::YT => RankIds::COLOR_LIST[RankIds::YT] ."§l§fYou§сTube§r",
    RankIds::IMMORTAL => RankIds::COLOR_LIST[RankIds::IMMORTAL] ."§lImmortal§r",
    RankIds::EXPERIENCED => RankIds::COLOR_LIST[RankIds::EXPERIENCED] ."§lExperienced§r",
    RankIds::HELPER => RankIds::COLOR_LIST[RankIds::HELPER] ."§lHelper§r",
    RankIds::OWNER => RankIds::COLOR_LIST[RankIds::OWNER] ."§lOwner§r"
  ];

  public const COLOR_LIST = [
    RankIds::PLAYER => "§7",
    RankIds::RECRUIT => "§6",
    RankIds::PRIME => "§c",
    RankIds::YT => "§f",
    RankIds::IMMORTAL => "§d",
    RankIds::EXPERIENCED => "§b",
    RankIds::HELPER => "§b",
    RankIds::OWNER => "§6"
  ];

  public const LIST = [
    RankIds::PLAYER => "player",
    RankIds::RECRUIT => "recruit",
    RankIds::PRIME => "prime",
    RankIds::YT => "yt",
    RankIds::IMMORTAL => "immortal",
    RankIds::EXPERIENCED => "experienced",
    RankIds::HELPER => "helper",
    RankIds::OWNER => "owner"
  ];
}

I'm sure there is some bug in RankIds but I can't find it

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2020-11-04
@aid175530814

Your $rank is 8 when the valid values ​​are 0..7. And you are accessing at an invalid index in an array that has 8 elements.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question