0

So

std::vector<std::string> spectators;

and

// this is calling multiple times
g_Visuals.spectators.push_back(format("LocalPlayer index %i", g_Local.iIndex).c_str());
g_Visuals.spectators.push_back(format("ent index %i", ent->index).c_str());
g_Visuals.spectators.push_back(format("User1 obs mode %i", g_Store.g_iUser1).c_str());
g_Visuals.spectators.push_back(format("User2 index %i", g_Store.g_iUser2).c_str());
g_Visuals.spectators.push_back(format("User3 index %i", g_Store.g_iUser3).c_str());

Here is how I draw every element in "spectators" I want to draw it after 5th element to side so i "w += 100"

int w = g_Screen.iWidth / 10;
int newline = 180;

for (auto v : spectators) {
    g_Drawing.DrawString(ESP, (g_Screen.iWidth / 10) + w, (g_Screen.iHeight / 100) + newline, 240, 240, 240, cvar.esp_alpha, FONT_LEFT, "%s", v.c_str());
    newline += 15;
    // if its 5th element, set newline to 180 again
}

I tried this but im dumb

for (int i = 0; i < spectators.size(); i += 5) // i tried this, but im dumb, this is for is number power of
    if (pow(5, (int)(log(i) / log(5))) == i) { w += 100; if (i == spectators.size()) i = 0; };

How it looks now img

and what I want img

Matej P
  • 3
  • 4

1 Answers1

0

I am not sure if i understand your question, but are you not looking for the modulos operator?

(n % 5 == 0) will be true for each 5th element?

batman567
  • 642
  • 1
  • 5
  • 17
  • Okay, but now How do I get current element index using loop for (v : spectators) ? – Matej P Sep 05 '20 at 15:18
  • perhaps look at https://stackoverflow.com/questions/43021/how-do-you-get-the-index-of-the-current-iteration-of-a-foreach-loop – batman567 Sep 05 '20 at 15:50