Balkan SA:MP

PAWN skriptanje, gamemodovi, filterskripte, include fajlovi, mape, pluginovi => Razgovor u vezi PAWN - skriptanja => Temu započeo: Quay_Alvarez poslato Septembar 13, 2024, 01:35:38 PRE PODNE

Naslov: Debug
Poruka od: Quay_Alvarez poslato Septembar 13, 2024, 01:35:38 PRE PODNE
Problem(error/warning): Imam problem evo dodah preko 300 vozila, i svaki id preko 300 izbacuje mi ovu gresku kad igrac hoce da udje u njega

[debug] #0 000df518 in ?? (1, 317, 0, 1, 0, 0, 12, 1, 317, 0, ... <1073741813 arguments>) from dmd.amx
[debug] #1 00037e18 in public OnPlayerEnterVehicle (1, 317, 0) from dmd.amx
[debug] Run time error 4: "Array index out of bounds"
[debug] AMX backtrace:

Na vrh skripte dodah
#undef MAX_VEHICLES
#define MAX_VEHICLES 1000
opet isto
Deo skripte: Vaš odgovor
Naslov: Odg: Debug
Poruka od: iv0dev poslato Septembar 13, 2024, 09:12:28 PRE PODNE
Pošalji dio koda sa callbackom OnPlayerEnterVehicle
Naslov: Odg: Debug
Poruka od: K ROSE poslato Septembar 13, 2024, 09:30:27 PRE PODNE
Greška "Run time error 4: Array index out of bounds" u Pawno znači da tvoj kod pokušava pristupiti indeksu niza (arraya) koji je izvan njegovih granica, odnosno da pokušavaš pristupiti elementu niza koji ne postoji.
Naslov: Odg: Debug
Poruka od: Quay_Alvarez poslato Septembar 13, 2024, 11:04:43 PRE PODNE
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(IgracUlogovan[playerid] == 0)
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Kikovani ste, server zahteva da se prijavite pre nego sto se spawnate.");
        KickEx(playerid,15);
        return 1;
    }
    TickCountAirBreak[playerid] = GetTickCount()+1000;
    if(!ispassenger) TrollVeh[playerid] = vehicleid;
    if(NosiWarShip[playerid] == true && (VoziloJeBicikla(GetVehicleModel(vehicleid)) || VoziloJeBrod(GetVehicleModel(vehicleid)) || VoziloJeMotor(GetVehicleModel(vehicleid)) || VoziloJeAvion(GetVehicleModel(vehicleid)) || VoziloJeKamion(GetVehicleModel(vehicleid))))
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        SafeSetPlayerPos(playerid, x, y, z);
        SendClientMessage(playerid, COLOR_GREY, "Sa paketom mozete uci samo u auto.");
        TrollVeh[playerid] = INVALID_VEHICLE_ID;
        return 0;
    }
    if(!ispassenger && UzeoSvercPaket[playerid] == true && ZapocetSverc[playerid] == true)
    {
        UzeoSvercPaket[playerid] = false;
        if(IsPlayerAttachedObjectSlotUsed(playerid, SLOT_SHIPMENT))
        {
            RemovePlayerAttachedObject(playerid, SLOT_SHIPMENT);
        }
        va_SendClientMessage(playerid, COLOR_WHITE, "Ispala ti je kutija.");
    }
    if(ShipmentPlayerData[playerid][CarryShip] == true && VoziloJeAvion(GetVehicleModel(vehicleid)))
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        SafeSetPlayerPos(playerid, x, y, z);
        SendClientMessage(playerid, COLOR_GREY, "Dok nosite shipment ne mozete uci u avion/helihopter.");
        TrollVeh[playerid] = INVALID_VEHICLE_ID;
        return 0;
    }
    if(KoristiBandage[playerid] == 1)
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        SafeSetPlayerPos(playerid, x, y, z);
        ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0, 1, 0, 0, 0, 0, 1);
        TrollVeh[playerid] = INVALID_VEHICLE_ID;
        return 0;
    }
    if(KoristiDrogu[playerid] == 1)
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        SafeSetPlayerPos(playerid, x, y, z);
        ApplyAnimation( playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0, 1);
        TrollVeh[playerid] = INVALID_VEHICLE_ID;
        return 0;
    }
    new Float:Poz[3];
    GetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
    if(NosiVoce[playerid] == true || DrziVoce[playerid] == true)
    {
        if(IsPlayerAttachedObjectSlotUsed(playerid, SLOT_VOCE))
        {
            RemovePlayerAttachedObject(playerid, SLOT_VOCE);
        }
        SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        SafeSetPlayerPos(playerid, x, y, z);
        SendClientMessage(playerid, COLOR_WHITE, "Bacili ste voce, jer ste usli u vozilo.");
        ApplyAnimation(playerid, "CARRY", "null", 0.0, 0, 0, 0, 0, 0);
        NosiVoce[playerid] = false;
        VocarCP[playerid] =
        PorukaVocar[playerid] = 0;
        TrollVeh[playerid] =INVALID_VEHICLE_ID;
        return 0;
    }
    if(!ispassenger)
    {
        if(ViljuskaristaVozilo(vehicleid))
        {
            new driver = GetVehicleDriverID(vehicleid);
            if(driver != -1)
            {
                if(PI[driver][pPosao] == 8)
                {
                    SendClientMessage(playerid, COLOR_GREY, "Ne mozete krasti vozilo dok neko radi posao!");
                    SafeSetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
                }
            }
        }
        if(BankarVozila(vehicleid))
        {
            new driver = GetVehicleDriverID(vehicleid);
            if(driver != -1)
            {
                if(PI[driver][pPosao] == 4)
                {
                    SendClientMessage(playerid, COLOR_GREY, "Ne mozete krasti vozilo dok neko radi posao!");
                    SafeSetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
                }
            }
        }
        if(FarmerVozila(vehicleid))
        {
            new driver = GetVehicleDriverID(vehicleid);
            if(driver != -1)
            {
                if(PI[driver][pPosao] == 5)
                {
                    SendClientMessage(playerid, COLOR_GREY, "Ne mozete krasti vozilo dok neko radi posao!");
                    SafeSetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
                }
            }
        }
        if(BusVozacVozila(vehicleid))
        {
            new driver = GetVehicleDriverID(vehicleid);
            if(driver != -1)
            {
                if(PI[driver][pPosao] == 3)
                {
                    SendClientMessage(playerid, COLOR_GREY, "Ne mozete krasti vozilo dok neko radi posao!");
                    SafeSetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
                }
            }
        }
    }
    if(!ispassenger)
    {
        if(AdminAuta(vehicleid))
        {
            if(PI[playerid][pAdmin] == 0 && PI[playerid][pGM] == 0)
            {
                SafeSetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
                SendClientMessage(playerid, COLOR_GREY, "Ne mozete uci u ovo vozilo (Admin/Gm vozilo)");
            }
        }
    }
    if(PI[playerid][pZatvor] != 0)
    {
        SafeSetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
        SendClientMessage(playerid, COLOR_GREY, "Ne mozete uci u ovo vozilo dok ste u zatvoru.");
    }
    return 1;
}
Naslov: Odg: Debug
Poruka od: Quay_Alvarez poslato Septembar 13, 2024, 11:05:02 PRE PODNE
Citat: K ROSE poslato Septembar 13, 2024, 09:30:27 PRE PODNEGreška "Run time error 4: Array index out of bounds" u Pawno znači da tvoj kod pokušava pristupiti indeksu niza (arraya) koji je izvan njegovih granica, odnosno da pokušavaš pristupiti elementu niza koji ne postoji.
Znam al nije mi jasno samo preko id 300
Naslov: Odg: Debug
Poruka od: twoblqck.art poslato Septembar 13, 2024, 11:57:32 PRE PODNE
#undef MAX_VEHICLES
#define MAX_VEHICLES 1000

Ovo pokusaj dodat ispod includea, mozda imas neki koji limitira na 300
Naslov: Odg: Debug
Poruka od: Quay_Alvarez poslato Septembar 13, 2024, 12:09:08 POSLE PODNE
Vec imam ispod includova

https://prnt.sc/4oHdc0UFhil0
Naslov: Odg: Debug
Poruka od: twoblqck.art poslato Septembar 13, 2024, 12:25:35 POSLE PODNE
Imas li kakvu filterscriptu?
Naslov: Odg: Debug
Poruka od: Quay_Alvarez poslato Septembar 13, 2024, 12:29:49 POSLE PODNE
Ne koristim filter skripte, samo evo sta od plugina imam

plugins pawnraknet crashdetect sscanf streamer mapandreas mysql SKY timerfix 
Naslov: Odg: Debug
Poruka od: iv0dev poslato Septembar 13, 2024, 12:58:21 POSLE PODNE
Citat: Quay_Alvarez poslato Septembar 13, 2024, 11:04:43 PRE PODNEpublic OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(IgracUlogovan[playerid] == 0)
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Kikovani ste, server zahteva da se prijavite pre nego sto se spawnate.");
        KickEx(playerid,15);
        return 1;
    }
    TickCountAirBreak[playerid] = GetTickCount()+1000;
    if(!ispassenger) TrollVeh[playerid] = vehicleid;
    if(NosiWarShip[playerid] == true && (VoziloJeBicikla(GetVehicleModel(vehicleid)) || VoziloJeBrod(GetVehicleModel(vehicleid)) || VoziloJeMotor(GetVehicleModel(vehicleid)) || VoziloJeAvion(GetVehicleModel(vehicleid)) || VoziloJeKamion(GetVehicleModel(vehicleid))))
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        SafeSetPlayerPos(playerid, x, y, z);
        SendClientMessage(playerid, COLOR_GREY, "Sa paketom mozete uci samo u auto.");
        TrollVeh[playerid] = INVALID_VEHICLE_ID;
        return 0;
    }
    if(!ispassenger && UzeoSvercPaket[playerid] == true && ZapocetSverc[playerid] == true)
    {
        UzeoSvercPaket[playerid] = false;
        if(IsPlayerAttachedObjectSlotUsed(playerid, SLOT_SHIPMENT))
        {
            RemovePlayerAttachedObject(playerid, SLOT_SHIPMENT);
        }
        va_SendClientMessage(playerid, COLOR_WHITE, "Ispala ti je kutija.");
    }
    if(ShipmentPlayerData[playerid][CarryShip] == true && VoziloJeAvion(GetVehicleModel(vehicleid)))
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        SafeSetPlayerPos(playerid, x, y, z);
        SendClientMessage(playerid, COLOR_GREY, "Dok nosite shipment ne mozete uci u avion/helihopter.");
        TrollVeh[playerid] = INVALID_VEHICLE_ID;
        return 0;
    }
    if(KoristiBandage[playerid] == 1)
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        SafeSetPlayerPos(playerid, x, y, z);
        ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0, 1, 0, 0, 0, 0, 1);
        TrollVeh[playerid] = INVALID_VEHICLE_ID;
        return 0;
    }
    if(KoristiDrogu[playerid] == 1)
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        SafeSetPlayerPos(playerid, x, y, z);
        ApplyAnimation( playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0, 1);
        TrollVeh[playerid] = INVALID_VEHICLE_ID;
        return 0;
    }
    new Float:Poz[3];
    GetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
    if(NosiVoce[playerid] == true || DrziVoce[playerid] == true)
    {
        if(IsPlayerAttachedObjectSlotUsed(playerid, SLOT_VOCE))
        {
            RemovePlayerAttachedObject(playerid, SLOT_VOCE);
        }
        SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        SafeSetPlayerPos(playerid, x, y, z);
        SendClientMessage(playerid, COLOR_WHITE, "Bacili ste voce, jer ste usli u vozilo.");
        ApplyAnimation(playerid, "CARRY", "null", 0.0, 0, 0, 0, 0, 0);
        NosiVoce[playerid] = false;
        VocarCP[playerid] =
        PorukaVocar[playerid] = 0;
        TrollVeh[playerid] =INVALID_VEHICLE_ID;
        return 0;
    }
    if(!ispassenger)
    {
        if(ViljuskaristaVozilo(vehicleid))
        {
            new driver = GetVehicleDriverID(vehicleid);
            if(driver != -1)
            {
                if(PI[driver][pPosao] == 8)
                {
                    SendClientMessage(playerid, COLOR_GREY, "Ne mozete krasti vozilo dok neko radi posao!");
                    SafeSetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
                }
            }
        }
        if(BankarVozila(vehicleid))
        {
            new driver = GetVehicleDriverID(vehicleid);
            if(driver != -1)
            {
                if(PI[driver][pPosao] == 4)
                {
                    SendClientMessage(playerid, COLOR_GREY, "Ne mozete krasti vozilo dok neko radi posao!");
                    SafeSetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
                }
            }
        }
        if(FarmerVozila(vehicleid))
        {
            new driver = GetVehicleDriverID(vehicleid);
            if(driver != -1)
            {
                if(PI[driver][pPosao] == 5)
                {
                    SendClientMessage(playerid, COLOR_GREY, "Ne mozete krasti vozilo dok neko radi posao!");
                    SafeSetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
                }
            }
        }
        if(BusVozacVozila(vehicleid))
        {
            new driver = GetVehicleDriverID(vehicleid);
            if(driver != -1)
            {
                if(PI[driver][pPosao] == 3)
                {
                    SendClientMessage(playerid, COLOR_GREY, "Ne mozete krasti vozilo dok neko radi posao!");
                    SafeSetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
                }
            }
        }
    }
    if(!ispassenger)
    {
        if(AdminAuta(vehicleid))
        {
            if(PI[playerid][pAdmin] == 0 && PI[playerid][pGM] == 0)
            {
                SafeSetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
                SendClientMessage(playerid, COLOR_GREY, "Ne mozete uci u ovo vozilo (Admin/Gm vozilo)");
            }
        }
    }
    if(PI[playerid][pZatvor] != 0)
    {
        SafeSetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
        SendClientMessage(playerid, COLOR_GREY, "Ne mozete uci u ovo vozilo dok ste u zatvoru.");
    }
    return 1;
}

Po ovome teško je reći, ajde još server.log daj
Naslov: Odg: Debug
Poruka od: twoblqck.art poslato Septembar 13, 2024, 13:06:12 POSLE PODNE
Probaj izbaciti sve iz onplayerentervehicle, ako je ne izbacuje nista, do njega je. I onda vracaj 1 po 1 dok ne izbaci ponovo i baziraj se na to
Naslov: Odg: Debug
Poruka od: markosimic poslato Septembar 13, 2024, 13:20:14 POSLE PODNE
Koja logika je da stavis undefined max vehicle da bi posle definisao nesto sto je po defaultu definisao.

Ovo ne mora da znaci da je OnPlayerEnterVehicle, moze biti bilo gde. Da li su u pitanju staticna ili dinamicna vozila, da li imas dinamicno vozilo preko ID 300 ? Da li, da li ? Moras dati sve potrebne informacije.

Napravi listu stvari, obrazlozi sve.