GMS 2 Turn Based Players

Trying to set up a simple system that says after 10 turns (or whatever) it goes to the next player in line. Here is what I have. But the number doesn't seem to be updating when I click the button.

create...
Code:
pNo = 0;
pSelected = "P" + string(pNo);
step...
Code:
if (mouse_check_button(mb_left)) {
    pNo++;
    show_message(pSelected);
}
draw...
Code:
switch (pSelected) {
    case "P1": draw_text_transformed(x, y, "Player 1", 1, 1, 90); break;
    case "P2": draw_text_transformed(x, y, "Player 2", 1, 1, 90); break;
    case "P3": draw_text_transformed(x, y, "Player 3", 1, 1, 90); break;
    case "P4": draw_text_transformed(x, y, "Player 4", 1, 1, 90); break;
    case "P5": draw_text_transformed(x, y, "Player 5", 1, 1, 90); break;
    case "P6": draw_text_transformed(x, y, "Player 6", 1, 1, 90); break;
    default: draw_text_transformed(x, y, "Player Unknown", 1, 1, 90); break;
}
It only ever remains the original "P0"
 
Trying to set up a simple system that says after 10 turns (or whatever) it goes to the next player in line. Here is what I have. But the number doesn't seem to be updating when I click the button.

create...
Code:
pNo = 0;
pSelected = "P" + string(pNo);
step...
Code:
if (mouse_check_button(mb_left)) {
    pNo++;
    show_message(pSelected);
}
draw...
Code:
switch (pSelected) {
    case "P1": draw_text_transformed(x, y, "Player 1", 1, 1, 90); break;
    case "P2": draw_text_transformed(x, y, "Player 2", 1, 1, 90); break;
    case "P3": draw_text_transformed(x, y, "Player 3", 1, 1, 90); break;
    case "P4": draw_text_transformed(x, y, "Player 4", 1, 1, 90); break;
    case "P5": draw_text_transformed(x, y, "Player 5", 1, 1, 90); break;
    case "P6": draw_text_transformed(x, y, "Player 6", 1, 1, 90); break;
    default: draw_text_transformed(x, y, "Player Unknown", 1, 1, 90); break;
}
It only ever remains the original "P0"

Okay, I got it solved. Thank Goodness... Here is what I did...

create...
Code:
ply[5] = "P6";
ply[4] = "P5";
ply[3] = "P4";
ply[2] = "P3";
ply[1] = "P2";
ply[0] = "P1";

pCtrl = true;
pCursor = 5;
pCount = array_length_1d(ply);
draw gui...
Code:
switch (pCursor) {
    case 0: draw_text_transformed(x, y, "Player 1", 1, 1, 90); break;
    case 1: draw_text_transformed(x, y, "Player 2", 1, 1, 90); break;
    case 2: draw_text_transformed(x, y, "Player 3", 1, 1, 90); break;
    case 3: draw_text_transformed(x, y, "Player 4", 1, 1, 90); break;
    case 4: draw_text_transformed(x, y, "Player 5", 1, 1, 90); break;
    case 5: draw_text_transformed(x, y, "Player 6", 1, 1, 90); break;
    default: draw_text_transformed(x, y, "Player Unknown", 1, 1, 90); break;
}
step...
Code:
if (pCtrl) {
    if (mouse_check_button_pressed(mb_left)) {
        pCursor++;
        if (pCursor >= pCount) pCursor = 0;
    }
}
 
Top