bei onplayerdead und bei onvhiclecheck ist ein fehler?

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

  • Console
    [20:10:59] [debug] Run time error 4: "Array index out of bounds"
    [20:10:59] [debug] Accessing element at negative index -400
    [20:10:59] [debug] AMX backtrace:
    [20:10:59] [debug] #0 0005a5e8 in public VehStateCheck () from gfl.amx
    [19:57:11] [debug] Run time error 4: "Array index out of bounds"
    [19:57:11] [debug] Accessing element at index 65535 past array upper bound 499
    [19:57:11] [debug] AMX backtrace:
    [19:57:11] [debug] #0 0001cf54 in public OnPlayerDeath (2, 65535, 255) from gfl.amx
    [19:57:11] [death] Jason_Belschner died 255





    public OnPlayerDeath(playerid, killerid, reason)
    {
    M_OnPlayerDeath(playerid,killerid,reason);
    new name[MAX_PLAYER_NAME];
    new string[256];
    new playercash;
    new victimteam;
    new Float:px,Float:py,Float:pz;
    new killerteam;
    InCargo[playerid] = 0; InLevi[playerid] = 0;
    if((AtRegestration[playerid] == 0 && PlayerPaintballing[playerid] == 0) && FirstSpawn[playerid] == 0)
    {
    PlayerInfo[playerid][pTot] = 1;
    new Float:pX,Float:pY,Float:pZ;
    GetPlayerPos(playerid, pX, pY, pZ);
    TotenKopf[playerid][0] = CreatePickup(1254,1, pX, pY, pZ);
    PlayerInfo[playerid][pTx] = pX;
    PlayerInfo[playerid][pTy] = pY;
    PlayerInfo[playerid][pTz] = pZ;
    GetPlayerName(playerid, name, sizeof(name));
    SendClientMessage(playerid,COLOR_LIGHTBLUE, "Du wurdest schwer verletzt ins Krankenhaus gebracht!");
    // SendClientMessage(playerid,COLOR_LIGHTBLUE, "Möchtest du einen Arzt?(/needmedic)");
    if(GetPlayerInterior(playerid) == 0)
    {
    for(new i=0; i<MAX_PLAYERS; i++)
    {
    if(PlayerInfo[i][pMember] == 4 || PlayerInfo[i][pLeader] == 4)
    {
    // SendClientMessage(i,COLOR_LIGHTBLUE,"[Funk:]Eine Person wurde als schwer verletzt gemeldet!");
    // SendClientMessage(i,COLOR_LIGHTBLUE,"Achtung eine Person wurde als schwerverletzt gemeldet!");
    // SendClientMessage(i,COLOR_LIGHTBLUE,"Die Position wurde auf dem HUD markiert!(/rmarker zum löschen)");
    // SetPlayerCheckpoint(i,PlayerInfo[playerid][pTx],PlayerInfo[playerid][pTy],PlayerInfo[playerid][pTz],5.0);
    }
    }
    }
    }
    if(FirstSpawn[playerid] == 1)
    {
    FirstSpawn[playerid] = 0;
    }




    victimteam = gTeam[playerid];
    killerteam = gTeam[killerid];
    gPlayerSpawned[playerid] = 0;
    GetPlayerName(playerid, name, sizeof(name));
    PlayerInfo[playerid][pLocal] = 255;
    GetPlayerPos(playerid, px, py, pz);
    if(killerid != 255)
    if(reason == 38)
    {
    new kstring[128];
    new kickname[MAX_PLAYER_NAME];
    if(IsPlayerConnected(killerid))
    {
    GetPlayerName(killerid, kickname, sizeof(kickname));
    format(string, 256, "Warnung: [%d]%s hat einen Spieler mit einer Minigun gekillt. ACHTUNG [CheatVerdacht].",killerid,kickname);
    ABroadCast(COLOR_YELLOW,string,1);
    printf("%s", kstring);
    }
    }
    if (gPlayerCheckpointStatus[playerid] > 4 && gPlayerCheckpointStatus[playerid] < 11)
    {
    DisablePlayerCheckpoint(playerid);
    gPlayerCheckpointStatus[playerid] = CHECKPOINT_NONE;
    }
    new caller = Mobile[playerid];
    if(caller != 255)
    {
    if(caller < 255)
    {
    SendClientMessage(caller, COLOR_GRAD2, " Die Verbindung wurde unterbrochen....");
    CellTime[caller] = 0;
    CellTime[playerid] = 0;
    Mobile[caller] = 255;
    }
    Mobile[playerid] = 255;
    CellTime[playerid] = 0;
    }
    ClearCrime(playerid);
    if(PlayerPaintballing[playerid] != 0)
    {
    PlayerPaintballKills[killerid] ++;
    if(PlayerPaintballKills[killerid] > PaintballWinnerKills)
    {
    new killer[MAX_PLAYER_NAME];
    PaintballWinner = killerid;
    PaintballWinnerKills = PlayerPaintballKills[killerid];
    GetPlayerName(killerid, killer, sizeof(killer));
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i))
    {
    if(PlayerPaintballing[i] != 0)
    {
    format(string, sizeof(string), "* %s ist mit %d Kills in Führung.",killer,PaintballWinnerKills);
    SendClientMessage(i, COLOR_WHITE, string);
    }
    }
    }
    }
    return 1;
    }
    if(IsBlacklist[playerid]==1)
    {
    ClearBlack(playerid);
    IsBlacklist[playerid]=0;
    }
    if(GettingCK[playerid] < 999 || OnCK[playerid] < 999)
    {
    if(IsPlayerConnected(killerid))
    {
    if(GettingCK[killerid] < 999 || OnCK[playerid] < 999)
    {
    new killer[MAX_PLAYER_NAME];
    new dier[MAX_PLAYER_NAME];
    GetPlayerName(playerid, dier, sizeof(dier));
    GetPlayerName(killerid, killer, sizeof(killer));
    format(string, sizeof(string), "* %s hat deinen Charakter gesperrt, du kannst nun mit diesem Charakter nicht mehr Spielen.",killer);
    SendClientMessage(playerid, COLOR_LIGHTRED, string);
    format(string, sizeof(string), "** %s hat den Spieler %s erledigt**",killer,dier);
    CKLog(string);
    PlayerInfo[playerid][pCK] = 1;
    if(GettingCK[playerid] < 999) { GettingCK[playerid] = 999; }
    else if(OnCK[playerid] < 999) { OnCK[playerid] = 999; }
    if(GettingCK[killerid] < 999) { GettingCK[killerid] = 999; }
    else if(OnCK[killerid] < 999) { OnCK[killerid] = 999; }
    KickPlayer[playerid] = 1;
    }
    }
    }
    if(PlayerInfo[playerid][pHeadValue] > 0)
    {
    if(IsPlayerConnected(killerid))
    {
    if(PlayerInfo[killerid][pMember] == 8 || PlayerInfo[killerid][pLeader] == 8)
    {
    if(GoChase[killerid] == playerid)
    {
    ConsumingMoney[killerid] = 1;
    new killer[MAX_PLAYER_NAME];
    GetPlayerName(killerid, killer, sizeof(killer));
    GivePlayerMoney(killerid, PlayerInfo[playerid][pHeadValue]);
    format(string,128,"<< Hitman %s hat den Auftrag an %s erfüllt und bekommt: $%d >>",killer,name,PlayerInfo[playerid][pHeadValue]);
    SendFamilyMessage(8, COLOR_YELLOW, string);
    PlayerInfo[playerid][pHeadValue] = 0;
    GotHit[playerid] = 0;
    GetChased[playerid] = 999;
    GoChase[killerid] = 999;
    }
    }
    }
    }
    if(victimteam >= 4)
    {
    if(IsPlayerConnected(killerid))
    {
    new slice = 100; //$100
    playercash = GetPlayerMoney(playerid);
    if(gTeam[killerid] != 2 && PlayerInfo[killerid][pMember] != 7) { WantedPoints[killerid] += 2; } //+ 2 wanted points
    if(SafeTime[playerid] <= 0)
    {
    if(gTeam[killerid] != gTeam[playerid])
    {
    if(GetPlayerState(killerid) == 1)
    {
    PlayerInfo[killerid][pKills] = PlayerInfo[killerid][pKills] + 2;
    }
    else
    {
    PlayerInfo[killerid][pKills]++;
    }
    PlayerInfo[playerid][pKills]--;
    }
    }
    if (((gTeam[killerid]) == 1) || ((gTeam[killerid]) == 3 && civnokill) || (gTeam[killerid] == gTeam[playerid] && gTeam[playerid] != 4))
    {
    slice = 0;
    }
    if (((gTeam[killerid]) != 4) && ((gTeam[killerid]) == gTeam[playerid]))//no team kill
    {
    slice = 0;
    }
    if (playercash > 0)
    {
    GivePlayerMoney(playerid, -slice);
    }
    else
    {
    slice = slice+500;
    }
    GivePlayerMoney(killerid, slice);
    PlayerPlaySound(killerid, 1083, 0.0, 0.0, 0.0);
    if (((gTeam[killerid]) == 3) && reason != 49)
    {
    SetPlayerCriminal(killerid,255, "Vorsätzlicher Mord");
    }
    else if (((gTeam[killerid]) == 3) && reason == 49)
    {
    SetPlayerCriminal(killerid,255, "Fahrerflucht");
    }
    }
    }
    else if (victimteam == 2)
    {
    if(IsPlayerConnected(killerid))
    {
    // Cop kill
    PlayerInfo[playerid][pKills]--;
    if (gTeam[killerid] == 2)//cops kill cop
    {
    PlayerPlaySound(killerid, 1084, 0.0, 0.0, 0.0);
    GivePlayerMoney(killerid, -suecost);
    GivePlayerMoney(playerid, suecost+100);//+100pays hospital bill
    }
    if (gTeam[killerid] >= 3)
    {
    WantedPoints[killerid] += 2; //+ 2 wanted points
    if(reason != 49)
    {
    SetPlayerCriminal(killerid,255, "Vorsätzlicher Mord");
    }
    else if (reason == 49)
    {
    SetPlayerCriminal(killerid,255, "Fahrerflucht");
    }
    }
    if(gTeam[killerid] >= 5 && SafeTime[playerid] <= 0)
    {
    if(GetPlayerState(killerid) == 1)
    {
    PlayerInfo[killerid][pKills] = PlayerInfo[killerid][pKills]+2;
    }
    else
    {
    PlayerInfo[killerid][pKills]++;
    }
    WantedPoints[killerid]+=2;
    }
    }
    }
    else if (victimteam == 3)
    {
    if(IsPlayerConnected(killerid))
    {
    // Civ kill
    if ((gTeam[killerid]) == 2 || PlayerInfo[killerid][pMember] == 7)//cops kill civ
    {
    if(WantedLevel[playerid] < 1)
    {
    PlayerPlaySound(killerid, 1084, 0.0, 0.0, 0.0);
    GivePlayerMoney(killerid, -suecost);
    GivePlayerMoney(playerid, suecost+100);//+100pays hospital bill
    }
    }
    else
    {
    WantedPoints[killerid] += 2;
    }
    if (((gTeam[killerid]) >= 3 || (gTeam[killerid]) == 1) && reason != 49)
    {
    SetPlayerCriminal(killerid,255, "Vorsätzlicher Mord");
    }
    else if (((gTeam[killerid]) >= 3 || (gTeam[killerid]) == 1) && reason == 49)
    {
    SetPlayerCriminal(killerid,255, "Fahrerflucht");
    }
    }
    }
    else if (victimteam == 1)
    {
    if(IsPlayerConnected(killerid))
    {
    // Civ kill
    if ((gTeam[killerid]) == 2)//cops kill civ
    {
    PlayerPlaySound(killerid, 1084, 0.0, 0.0, 0.0);
    GivePlayerMoney(killerid, -suecost);
    GivePlayerMoney(playerid, suecost+100);//+100pays hospital bill
    }
    else if ((gTeam[killerid]) == 1)//med kill civ
    {
    PlayerPlaySound(killerid, 1084, 0.0, 0.0, 0.0);
    GivePlayerMoney(killerid, -suecost);
    GivePlayerMoney(playerid, suecost+100);//+100pays hospital bill
    }
    if (((gTeam[killerid]) == 4) && reason != 49)
    {
    SetPlayerCriminal(killerid,255, "Vorsätzlicher Mord");
    }
    else if (((gTeam[killerid]) == 3) && reason == 49)
    {
    SetPlayerCriminal(killerid,255, "Fahrerflucht");
    }
    }
    }
    if (victimteam >= 3 && WantedPoints[playerid] > 0 && killerteam == 2)
    {
    SetPlayerFree(playerid,killerid, "Gekillt");
    }
    killerid = INVALID_PLAYER_ID;
    SetPlayerColor(playerid,COLOR_GRAD2);
    return 1;
    }




    public VehStateCheck()
    {
    for(new i=0;i<MAX_PLAYERS;i++)
    {
    if(IsPlayerConnected(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && !IsANoTachoVehicle(GetPlayerVehicleID(i)))
    {
    if(M_Bot[i][PAFK] == 0)
    {
    new veh = GetPlayerVehicleID(i);
    new Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,final_speed_int;
    GetVehicleVelocity(veh, speed_x, speed_y, speed_z);
    final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667; // 136.666667 = kmph // 85.4166672= mph
    final_speed_int = floatround(final_speed,floatround_round);
    new kmh_anzahl = final_speed_int;
    new Float:health,vehicleid = GetPlayerVehicleID(i),Float:x,Float:y,Float:z;//,Float:distance.Float:value
    GetPlayerPos(i, x, y, z);
    GetVehicleHealth(vehicleid,health);



    new str1[200],str2[200],str21[200],str22[200],str23[200],str3[200],str4[200];



    TextDrawShowForPlayer(i, tank[i]);
    TextDrawShowForPlayer(i, kmh[i]);
    TextDrawShowForPlayer(i, Fahrzeugmodel[i]);
    TextDrawShowForPlayer(i, Fahrzeug[i]);



    TextDrawShowForPlayer(i, trennung[i]);
    TextDrawShowForPlayer(i, batterie[i]);
    TextDrawShowForPlayer(i, radio[i]);
    TextDrawShowForPlayer(i, zustand[i]);
    TextDrawShowForPlayer(i, Autostatus[i]);



    format(str1,sizeof(str1),"%s",VehicleName[GetVehicleModel(vehicleid)-400]);
    TextDrawSetString(Fahrzeug[i], str1);



    format(str2,sizeof(str2),"Km/h: %d",kmh_anzahl);
    TextDrawSetString(kmh[i], str2);
    switch(radiozustand[i])
    {
    case 0:
    {
    format(str21,sizeof(str21),"Radio: Aus");
    TextDrawSetString(radio[i], str21);
    }
    case 1:
    {
    format(str21,sizeof(str21),"Radio: Ein");
    TextDrawSetString(radio[i], str21);
    }
    }
    for(new v=0;v<MAX_CARS;v++)
    {
    if(vehicleid == Frakcar[v])
    {
    switch(FCInfo[v][open])
    {
    case 1:
    {
    format(str23,sizeof(str23),"Autostatus: Zu");
    TextDrawSetString(Autostatus[i], str23);
    }
    case 0:
    {
    format(str23,sizeof(str23),"Autostatus: Auf");
    TextDrawSetString(Autostatus[i], str23);
    }
    }
    }
    }
    format(str22,sizeof(str22),"Batterie: %d%",Bat[vehicleid],GetBatMax(GetVehicleModel(vehicleid)));
    TextDrawSetString(batterie[i], str22);





    format(str3,sizeof(str3),"Benzin: %d/%d", Gas[vehicleid],GetGasMax(GetVehicleModel(vehicleid)));
    TextDrawSetString(tank[i], str3);



    format(str4,sizeof(str4),"Zustand: %.2f", health);
    TextDrawSetString(zustand[i], str4);
    format(str23,sizeof(str23),"Autostatus: Wartung");
    TextDrawSetString(Autostatus[i], str23);
    PCarPos[i][PCarX] = x;
    PCarPos[i][PCarY] = y;
    PCarPos[i][PCarZ] = z;
    }
    }
    else
    {
    TextDrawHideForPlayer(i, tank[i]);
    TextDrawHideForPlayer(i, kmh[i]);
    TextDrawHideForPlayer(i, Fahrzeugmodel[i]);
    TextDrawHideForPlayer(i,Fahrzeug[i]);
    TextDrawHideForPlayer(i, trennung[i]);
    TextDrawHideForPlayer(i, batterie[i]);
    TextDrawHideForPlayer(i, radio[i]);
    TextDrawHideForPlayer(i,zustand[i]);
    TextDrawHideForPlayer(i,Autostatus[i]);
    }
    }
    return 1;
    }



    was ist da fürn fehler?
    man stirbt auch ohne grunfd meinchmal?

  • was ist da fürn fehler?

    Also, stell dir vor du fällst von einer Klippe und stirbst.


    Dann hat dich ja keiner umgebracht, dann ist killerid = INVALID_PLAYER_ID.


    und INVALID_PLAYER_ID hat nun mal einen Wert von 2^16 - 1 = 65535


    So, da aber MAX_PLAYERS nur 500 groß ist gibt es ein Problem wenn du blabla[killerid] machst, da die maximale Größe auf 500 begrenzt ist und du hier aber 2^16 -1 reinschreibst.
    Somit ist dein Array out of bounds.
    Um diesen Fehler zu vermeiden musst du einfach folgendes machen, bevor du einen Array mit killerid setzt und zwar:


    C
    if(killerid != INVALID_PLAYER_ID)
    {
        //Hier darfst du es setzen: also hier kommt xx[killerid]...bla bla rein
        //Andernfalls kannst du ja nichts für killerid setzen 
    }


    //Edit:
    Bei deinem 2. Fehler...schreib die if-Abfrage mal so:


    if(IsPlayerConnected(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && !IsANoTachoVehicle(GetPlayerVehicleID(i)) && GetPlayerVehicleID(i) != 0)


    mfg. :thumbup:

    ast2ufdyxkb1.png


    Leute, lernt scripten und versucht mal lieber etwas selber zu schreiben, als es aus einem GF zu kopieren. :S

    Einmal editiert, zuletzt von Kaliber ()