Jump to content

Question

Posted

Salutare am incercat sa fac o comanda cu care sa creez casele direct din joc, cu un interior random. In gamemode nu primesc nicio eroare, dar cand tastez comanda in joc nu functioneaza si primesc in consola urmatoarea eroare:
 

[debug] Run time error 4: "Array index out of bounds"
[debug]  Attempted to read/write array element at index 1 in array of size 1
[debug] AMX backtrace:
[debug] #0 0005410c in public cmd_createhouse (0, 1126740) in servername.amx
[debug] #1 native CallLocalFunction () in samp-server.exe
[debug] #2 0002e224 in public OnPlayerCommandText (0, 1126596) in servername.amx

Codul:

new Float:SmallHouseInterior[][] = {
    {223.0797, 1287.7438, 1082.1406, 1.000},             // 1
    {2282.7927, -1139.3999, 1050.8984, 11.000},         // 11
    {328.0025, 1478.5465, 1084.4375, 15.000},            // 15
    {-42.5438, 1406.3199, 1084.4297, 8.000},            // 8
    {2308.8101, -1212.2432, 1049.0234, 6.000},            // 6
    {2233.6196, -1114.5808, 1050.8828, 5.000},            // 5
    {2259.8242, -1135.7554, 1050.6328, 10.000},            // 10
    {2217.8169, -1076.1425, 1050.4844, 1.000},            // 1
    {267.1584, 305.2281, 999.1484, 2.000},                // 2
    {244.1047, 304.9235, 999.1484, 1.000},                // 1
    {2468.4509, -1698.2510, 1013.5078, 2.000},            // 2
    {-68.7771, 1351.9674, 1080.2109, 6.000},            // 6
    {221.9701, 1140.8445, 1082.6094, 4.000},            // 4
    {295.0533, 1473.0192, 1080.2578, 15.000},            // 15
    {2237.6023, -1080.8840, 1049.0234, 2.000},            // 2
    {2365.3372, -1134.8403, 1050.8750, 8.000},            // 8
    {22.8908, 1403.7777, 1084.4297, 5.000},                // 5
    {386.5427, 1471.8826, 1080.1875, 15.000},            // 15
    {376.2806, 1417.5321, 1081.3281, 15.000},            // 15
    {447.3249, 1397.5758, 1084.3047, 2.000}                // 2
};
new Float:MediumHouseInterior[][] = {
    {24.0680, 1340.5543, 1084.3750, 10.000},            // 10
    {83.0025, 1322.8451, 1083.8662, 9.000},                // 9
    {490.8654, 1399.1970, 1080.2578, 2.000},            // 2
    {226.7048, 1114.2527, 1080.9950, 5.000},            // 5
    {260.8823, 1237.9570, 1084.2578, 9.000},             // 9
    {235.4070, 1187.3690, 1080.2578, 3.000},            // 3
    {-261.2778, 1456.7443, 1084.3672, 4.000},            // 4
    {2269.6677, -1210.3624, 1047.5625, 10.000},            // 10
    {2196.0349, -1204.3772, 1049.0234, 6.000},            // 6
    {2496.0198, -1692.6827, 1014.7422, 3.000},            // 3
    {2317.9451, -1026.1736, 1050.2178, 9.000},            // 9
    {235.340652, 1187.027343, 1080.257812, 3.000},      // 3
    {2495.914062, -1692.474853, 1014.742187, 3.000}     // 3
};
new Float:BigHouseInterior[][] = {
    {234.2033, 1064.1516, 1084.2117, 6.000},            // 6
    {140.1820, 1366.4713, 1083.8594, 5.000},            // 5
    {225.630997, 1022.479980, 1084.069946, 7.000},      // 7
    {1261.296386, -785.447937, 1091.906250, 5.000},     // 5
    {2324.479248, -1148.910644, 1050.710083, 12.000}     // 12
};

CMD:createhouse(playerid, params[]) {
    new lQuery[500], size, price, level, rent, id = houses+1, Float:x, Float:y, Float:z, randomint;
    if(PlayerInfo[playerid][pAdmin] < 6) return NotAdmin;
    if(PlayerInfo[playerid][IsLoggedIn] == false) return NotConnected;
    if(sscanf(params, "iiii", size, price, level, rent)) return SendClientMessage(playerid, COLOR_MEDIUMBLUE, "(Syntax): {FFFFFF}/createhouse <size 0 / 1 / 2> <price> <level> <rent>");
    if(size >= 4) return SendClientMessage(playerid, COLOR_RED, "(Error): {FFFFFF}Invalid size.");
    GetPlayerPos(playerid, x, y, z);
    switch(size) {
        case 0: {
            randomint = random(sizeof(SmallHouseInterior));
            HouseInfo[id][hInterior] = floatround(SmallHouseInterior[randomint][3], floatround_round);
            HouseInfo[id][hExitX] = SmallHouseInterior[randomint][0]; HouseInfo[id][hExitY] = SmallHouseInterior[randomint][1]; HouseInfo[id][hExitZ] = SmallHouseInterior[randomint][2];
            format(HouseInfo[id][hSize], 8, "Small");
            mysql_format(g_SQL, lQuery, sizeof(lQuery), "INSERT INTO `houses` (`Size`, `Entrance X`, `Entrance Y`, `Entrance Z`, `Exit X`, `Exit Y`, `Exit Z`, `Price`, `Level needed`, `Rent Price`, `Interior`, `Virtual world`) VALUES ('Small', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d', '%d')", x, y, z, HouseInfo[id][hExitX], HouseInfo[id][hExitY], HouseInfo[id][hExitZ], price, level, HouseInfo[id][hInterior], id);
        }
        case 1: {
            randomint = random(sizeof(MediumHouseInterior));
            HouseInfo[id][hInterior] = floatround(MediumHouseInterior[randomint][3], floatround_round);
            HouseInfo[id][hExitX] = MediumHouseInterior[randomint][0]; HouseInfo[id][hExitY] = MediumHouseInterior[randomint][1]; HouseInfo[id][hExitZ] = MediumHouseInterior[randomint][2];
            format(HouseInfo[id][hSize], 8, "Medium");
            mysql_format(g_SQL, lQuery, sizeof(lQuery), "INSERT INTO `houses` (`Size`, `Entrance X`, `Entrance Y`, `Entrance Z`, `Exit X`, `Exit Y`, `Exit Z`, `Price`, `Level needed`, `Rent Price`, `Interior`, `Virtual world`) VALUES ('Medium', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d', '%d')", x, y, z, HouseInfo[id][hExitX], HouseInfo[id][hExitY], HouseInfo[id][hExitZ], price, level, HouseInfo[id][hInterior], id);
        }
        case 2: {
            randomint = random(sizeof(BigHouseInterior));
            HouseInfo[id][hInterior] = floatround(BigHouseInterior[randomint][3], floatround_round);
            HouseInfo[id][hExitX] = BigHouseInterior[randomint][0]; HouseInfo[id][hExitY] = BigHouseInterior[randomint][1]; HouseInfo[id][hExitZ] = BigHouseInterior[randomint][2];
            format(HouseInfo[id][hSize], 8, "Big");
            mysql_format(g_SQL, lQuery, sizeof(lQuery), "INSERT INTO `houses` (`Size`, `Entrance X`, `Entrance Y`, `Entrance Z`, `Exit X`, `Exit Y`, `Exit Z`, `Price`, `Level needed`, `Rent Price`, `Interior`, `Virtual world`) VALUES ('Big', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d', '%d')", x, y, z, HouseInfo[id][hExitX], HouseInfo[id][hExitY], HouseInfo[id][hExitZ], price, level, HouseInfo[id][hInterior], id);
        }
    }
    mysql_tquery(g_SQL, lQuery);
    HouseInfo[id][hEntranceX] = x; HouseInfo[id][hEntranceY] = y; HouseInfo[id][hEntranceZ] = z;
    HouseInfo[id][hPrice] = price; HouseInfo[id][hLevelNeeded] = level; HouseInfo[id][hRent] = rent;
    HouseInfo[id][hVirtualWorld] = id;

    CreateDynamicPickup(1272, 1, HouseInfo[id][hEntranceX], HouseInfo[id][hEntranceY], HouseInfo[id][hEntranceZ]);
    UpdateHouseLabel(id), houses++;
    SendClientMessage(playerid, COLOR_ANNO, "SERVER: {FFFFFF}House successfully created.");
    return 1;
}

Tin sa precizez ca sunt oarecum la inceput, si daca m-ati putea ajuta cu alte sfaturi inafara de aceasta problema v-as fi recunoscator.
Multumesc.

4 answers to this question

Recommended Posts

  • 0
Posted
15 hours ago, SebastianAdv said:

Salutare am incercat sa fac o comanda cu care sa creez casele direct din joc, cu un interior random. In gamemode nu primesc nicio eroare, dar cand tastez comanda in joc nu functioneaza si primesc in consola urmatoarea eroare:
 


[debug] Run time error 4: "Array index out of bounds"
[debug]  Attempted to read/write array element at index 1 in array of size 1
[debug] AMX backtrace:
[debug] #0 0005410c in public cmd_createhouse (0, 1126740) in servername.amx
[debug] #1 native CallLocalFunction () in samp-server.exe
[debug] #2 0002e224 in public OnPlayerCommandText (0, 1126596) in servername.amx

Codul:


new Float:SmallHouseInterior[][] = {
    {223.0797, 1287.7438, 1082.1406, 1.000},             // 1
    {2282.7927, -1139.3999, 1050.8984, 11.000},         // 11
    {328.0025, 1478.5465, 1084.4375, 15.000},            // 15
    {-42.5438, 1406.3199, 1084.4297, 8.000},            // 8
    {2308.8101, -1212.2432, 1049.0234, 6.000},            // 6
    {2233.6196, -1114.5808, 1050.8828, 5.000},            // 5
    {2259.8242, -1135.7554, 1050.6328, 10.000},            // 10
    {2217.8169, -1076.1425, 1050.4844, 1.000},            // 1
    {267.1584, 305.2281, 999.1484, 2.000},                // 2
    {244.1047, 304.9235, 999.1484, 1.000},                // 1
    {2468.4509, -1698.2510, 1013.5078, 2.000},            // 2
    {-68.7771, 1351.9674, 1080.2109, 6.000},            // 6
    {221.9701, 1140.8445, 1082.6094, 4.000},            // 4
    {295.0533, 1473.0192, 1080.2578, 15.000},            // 15
    {2237.6023, -1080.8840, 1049.0234, 2.000},            // 2
    {2365.3372, -1134.8403, 1050.8750, 8.000},            // 8
    {22.8908, 1403.7777, 1084.4297, 5.000},                // 5
    {386.5427, 1471.8826, 1080.1875, 15.000},            // 15
    {376.2806, 1417.5321, 1081.3281, 15.000},            // 15
    {447.3249, 1397.5758, 1084.3047, 2.000}                // 2
};
new Float:MediumHouseInterior[][] = {
    {24.0680, 1340.5543, 1084.3750, 10.000},            // 10
    {83.0025, 1322.8451, 1083.8662, 9.000},                // 9
    {490.8654, 1399.1970, 1080.2578, 2.000},            // 2
    {226.7048, 1114.2527, 1080.9950, 5.000},            // 5
    {260.8823, 1237.9570, 1084.2578, 9.000},             // 9
    {235.4070, 1187.3690, 1080.2578, 3.000},            // 3
    {-261.2778, 1456.7443, 1084.3672, 4.000},            // 4
    {2269.6677, -1210.3624, 1047.5625, 10.000},            // 10
    {2196.0349, -1204.3772, 1049.0234, 6.000},            // 6
    {2496.0198, -1692.6827, 1014.7422, 3.000},            // 3
    {2317.9451, -1026.1736, 1050.2178, 9.000},            // 9
    {235.340652, 1187.027343, 1080.257812, 3.000},      // 3
    {2495.914062, -1692.474853, 1014.742187, 3.000}     // 3
};
new Float:BigHouseInterior[][] = {
    {234.2033, 1064.1516, 1084.2117, 6.000},            // 6
    {140.1820, 1366.4713, 1083.8594, 5.000},            // 5
    {225.630997, 1022.479980, 1084.069946, 7.000},      // 7
    {1261.296386, -785.447937, 1091.906250, 5.000},     // 5
    {2324.479248, -1148.910644, 1050.710083, 12.000}     // 12
};

CMD:createhouse(playerid, params[]) {
    new lQuery[500], size, price, level, rent, id = houses+1, Float:x, Float:y, Float:z, randomint;
    if(PlayerInfo[playerid][pAdmin] < 6) return NotAdmin;
    if(PlayerInfo[playerid][IsLoggedIn] == false) return NotConnected;
    if(sscanf(params, "iiii", size, price, level, rent)) return SendClientMessage(playerid, COLOR_MEDIUMBLUE, "(Syntax): {FFFFFF}/createhouse <size 0 / 1 / 2> <price> <level> <rent>");
    if(size >= 4) return SendClientMessage(playerid, COLOR_RED, "(Error): {FFFFFF}Invalid size.");
    GetPlayerPos(playerid, x, y, z);
    switch(size) {
        case 0: {
            randomint = random(sizeof(SmallHouseInterior));
            HouseInfo[id][hInterior] = floatround(SmallHouseInterior[randomint][3], floatround_round);
            HouseInfo[id][hExitX] = SmallHouseInterior[randomint][0]; HouseInfo[id][hExitY] = SmallHouseInterior[randomint][1]; HouseInfo[id][hExitZ] = SmallHouseInterior[randomint][2];
            format(HouseInfo[id][hSize], 8, "Small");
            mysql_format(g_SQL, lQuery, sizeof(lQuery), "INSERT INTO `houses` (`Size`, `Entrance X`, `Entrance Y`, `Entrance Z`, `Exit X`, `Exit Y`, `Exit Z`, `Price`, `Level needed`, `Rent Price`, `Interior`, `Virtual world`) VALUES ('Small', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d', '%d')", x, y, z, HouseInfo[id][hExitX], HouseInfo[id][hExitY], HouseInfo[id][hExitZ], price, level, HouseInfo[id][hInterior], id);
        }
        case 1: {
            randomint = random(sizeof(MediumHouseInterior));
            HouseInfo[id][hInterior] = floatround(MediumHouseInterior[randomint][3], floatround_round);
            HouseInfo[id][hExitX] = MediumHouseInterior[randomint][0]; HouseInfo[id][hExitY] = MediumHouseInterior[randomint][1]; HouseInfo[id][hExitZ] = MediumHouseInterior[randomint][2];
            format(HouseInfo[id][hSize], 8, "Medium");
            mysql_format(g_SQL, lQuery, sizeof(lQuery), "INSERT INTO `houses` (`Size`, `Entrance X`, `Entrance Y`, `Entrance Z`, `Exit X`, `Exit Y`, `Exit Z`, `Price`, `Level needed`, `Rent Price`, `Interior`, `Virtual world`) VALUES ('Medium', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d', '%d')", x, y, z, HouseInfo[id][hExitX], HouseInfo[id][hExitY], HouseInfo[id][hExitZ], price, level, HouseInfo[id][hInterior], id);
        }
        case 2: {
            randomint = random(sizeof(BigHouseInterior));
            HouseInfo[id][hInterior] = floatround(BigHouseInterior[randomint][3], floatround_round);
            HouseInfo[id][hExitX] = BigHouseInterior[randomint][0]; HouseInfo[id][hExitY] = BigHouseInterior[randomint][1]; HouseInfo[id][hExitZ] = BigHouseInterior[randomint][2];
            format(HouseInfo[id][hSize], 8, "Big");
            mysql_format(g_SQL, lQuery, sizeof(lQuery), "INSERT INTO `houses` (`Size`, `Entrance X`, `Entrance Y`, `Entrance Z`, `Exit X`, `Exit Y`, `Exit Z`, `Price`, `Level needed`, `Rent Price`, `Interior`, `Virtual world`) VALUES ('Big', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d', '%d', '%d', '%d')", x, y, z, HouseInfo[id][hExitX], HouseInfo[id][hExitY], HouseInfo[id][hExitZ], price, level, HouseInfo[id][hInterior], id);
        }
    }
    mysql_tquery(g_SQL, lQuery);
    HouseInfo[id][hEntranceX] = x; HouseInfo[id][hEntranceY] = y; HouseInfo[id][hEntranceZ] = z;
    HouseInfo[id][hPrice] = price; HouseInfo[id][hLevelNeeded] = level; HouseInfo[id][hRent] = rent;
    HouseInfo[id][hVirtualWorld] = id;

    CreateDynamicPickup(1272, 1, HouseInfo[id][hEntranceX], HouseInfo[id][hEntranceY], HouseInfo[id][hEntranceZ]);
    UpdateHouseLabel(id), houses++;
    SendClientMessage(playerid, COLOR_ANNO, "SERVER: {FFFFFF}House successfully created.");
    return 1;
}

Tin sa precizez ca sunt oarecum la inceput, si daca m-ati putea ajuta cu alte sfaturi inafara de aceasta problema v-as fi recunoscator.
Multumesc.

Ai incercat sa maresti limita la houseinfo?

  • Like 1
  • 0
Posted

Creeaza in folderul pawno un fisier pawno.cfg. in el scrie -d3. Salveaza si compileaza gamemodeul, apoi porneste-l si folossste comanda ca sa vezi exact linia la care este eroarea.

  • Like 1
  • 0

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.