Arrays Must Be Indexed

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Hallo,
    ich habe mehrere Errors die ich nicht wegbekomme.


    Hier sind die Errors:


    Code
    A:\Mark\Desktop\Stunt\gamemodes\gamemode.pwn(1440) : error 033: array must be indexed (variable "PlayersInDeagle")
    A:\Mark\Desktop\Stunt\gamemodes\gamemode.pwn(1463) : error 033: array must be indexed (variable "PlayersInDeagle")
    A:\Mark\Desktop\Stunt\gamemodes\gamemode.pwn(1502) : error 033: array must be indexed (variable "PlayersInDeagle")


    Hier ist der Code:
    if (strcmp("/deagle", cmdtext, true, 10) == 0)
    {
    if(PlayerInDM == 0)
    {
    new name[MAX_PLAYER_NAME], germanstring[100], englishstring[100];
    GetPlayerName(playerid, name, sizeof(name));
    if(PlayersInDeagle < 10)
    {
    for(new i=0;i<GetMaxPlayers();i++)
    {
    if(PlayerInDeagle == 1) //Zeile 1440
    {
    switch(i)
    {
    case 1: { SetPlayerPos(playerid,4945.6430700,-4108.7656300,328.4060400);/*unten*/ }
    case 2: { SetPlayerPos(playerid,4945.6430700,-4108.7656300,328.4060400);/*unten*/ }
    case 3: { SetPlayerPos(playerid,4945.6430700,-4108.7656300,328.4060400);/*unten*/ }
    case 4: { SetPlayerPos(playerid,4945.6430700,-4108.7656300,328.4060400);/*unten*/ }
    case 5: { SetPlayerPos(playerid,4945.6430700,-4108.7656300,328.4060400);/*unten*/ }
    case 6: { SetPlayerPos(playerid,4945.6430700,-4108.7656300,528.4060400);/*weiter oben*/ }
    case 7: { SetPlayerPos(playerid,4945.6430700,-4108.7656300,528.4060400);/*weiter oben*/ }
    case 8: { SetPlayerPos(playerid,4945.6430700,-4108.7656300,528.4060400);/*weiter oben*/ }
    case 9: { SetPlayerPos(playerid,4945.6430700,-4108.7656300,528.4060400);/*weiter oben*/ }
    case 10: { SetPlayerPos(playerid,4945.6430700,-4108.7656300,528.4060400);/*weiter oben*/ }
    }
    }
    }
    PlayerInDM = 1;
    PlayerInDeagle = 1;
    PlayersInDeagle + 1; // Zeile 1463
    SendPlayerMessage(playerid, GREEN, "Zur Deagle Arena teleportiert.", "Teleported to deagle cage.");
    format(germanstring,sizeof(germanstring),"%s hat sich zur Deagle Arena teleportiert. (/deagle)",name);
    format(englishstring,sizeof(englishstring),"%s teleported to deagle cage. (/deagle)",name);
    SendAllPlayerMessage(LIGHTBLUE, germanstring, englishstring);
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 0);
    GivePlayerWeapon(playerid, 24, 500);
    }
    else { SendPlayerMessage(playerid, RED, "Du bist schon im DM!", "You already in dm!"); }
    }
    else { SendPlayerMessage(playerid, RED, "Die Deagle Arena ist voll!", "The deagle cage is full!"); }
    return 1;
    }


    if (strcmp("/exit", cmdtext, true, 10) == 0)
    {
    if(PlayerInDM == 1)
    {
    PlayerInDM = 0;
    SpawnPlayer(playerid);
    if(PlayerInDeagle == 1) { PlayerInDeagle = 0; PlayersInDeagle - 1; } // Zeile 1502
    else if(PlayerInMinigun == 1) { PlayerInMinigun = 0; }
    }
    else { SendPlayerMessage(playerid, RED, "Du bist nicht im DM oder Rennen!", "You are not in dm or race!"); }
    return 1;
    }
    return 0;
    }


    Hier definiere ich die Arrays(müsste der Fehler sein):


    Code
    new PlayerInDM;
    new PlayerInDeagle;
    new PlayersInDeagle[MAX_PLAYERS];
    new PlayerInMinigun;


    Danke im voraus.


    Grüße
    Mark

  • Der Code muss so aussehen:
    if (strcmp("/deagle", cmdtext, true) == 0)
    {
    if(PlayerInDM[playerid] == 0)
    {
    new name[MAX_PLAYER_NAME], germanstring[100], englishstring[100];
    GetPlayerName(playerid, name, sizeof(name));
    if(PlayersInDeagle < 10)
    {
    if(PlayerInDeagle[playerid] == 0) //Zeile 1440
    {
    switch(random(10)+1)
    {
    case 1:
    {
    SetPlayerPos(playerid,4945.6430700,-4108.7656300,328.4060400);/*unten*/
    }
    case 2:
    {
    SetPlayerPos(playerid,4945.6430700,-4108.7656300,328.4060400);/*unten*/
    }
    case 3:
    {
    SetPlayerPos(playerid,4945.6430700,-4108.7656300,328.4060400);/*unten*/
    }
    case 4:
    {
    SetPlayerPos(playerid,4945.6430700,-4108.7656300,328.4060400);/*unten*/
    }
    case 5:
    {
    SetPlayerPos(playerid,4945.6430700,-4108.7656300,328.4060400);/*unten*/
    }
    case 6:
    {
    SetPlayerPos(playerid,4945.6430700,-4108.7656300,528.4060400);/*weiter oben*/
    }
    case 7:
    {
    SetPlayerPos(playerid,4945.6430700,-4108.7656300,528.4060400);/*weiter oben*/
    }
    case 8:
    {
    SetPlayerPos(playerid,4945.6430700,-4108.7656300,528.4060400);/*weiter oben*/
    }
    case 9:
    {
    SetPlayerPos(playerid,4945.6430700,-4108.7656300,528.4060400);/*weiter oben*/
    }
    case 10:
    {
    SetPlayerPos(playerid,4945.6430700,-4108.7656300,528.4060400);/*weiter oben*/
    }
    }
    PlayerInDM[playerid] = 1;
    PlayerInDeagle[playerid] = 1;
    PlayersInDeagle ++; // Zeile 1463
    SendPlayerMessage(playerid, GREEN, "Zur Deagle Arena teleportiert.", "Teleported to deagle cage.");
    format(germanstring,sizeof(germanstring),"%s hat sich zur Deagle Arena teleportiert. (/deagle)",name);
    format(englishstring,sizeof(englishstring),"%s teleported to deagle cage. (/deagle)",name);
    SendAllPlayerMessage(LIGHTBLUE, germanstring, englishstring);
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 0);
    GivePlayerWeapon(playerid, 24, 500);
    }
    }
    else
    {
    SendPlayerMessage(playerid, RED, "Die Deagle Arena ist voll!", "The deagle cage is full!");
    }
    }
    else
    {
    SendPlayerMessage(playerid, RED, "Du bist schon im DM!", "You already in dm!");
    }
    return 1;
    }


    if (strcmp("/exit", cmdtext, true) == 0)
    {
    if(PlayerInDM[playerid] == 1)
    {
    PlayerInDM[playerid] = 0;
    if(PlayerInDeagle[playerid] == 1)
    {
    PlayersInDeagle --;
    PlayerInDeagle[playerid] = 0;
    }
    else if(PlayerInMinigun[playerid] == 1)
    {
    PlayerInMinigun[playerid] = 0;
    PlayersInMinigun --;
    }
    SpawnPlayer(playerid);
    }
    else
    {
    SendPlayerMessage(playerid, RED, "Du bist nicht im DM oder Rennen!", "You are not in dm or race!");
    }
    return 1;
    }
    return 0;
    }


    Und die Deklarationen so:
    new PlayerInDM[MAX_PLAYERS];
    new PlayerInDeagle[MAX_PLAYERS];
    new PlayerInMinigun[MAX_PLAYERS];
    new PlayersInDeagle;
    new PlayersInMinigun;