Index problem
#1

Okay so Im getting this error. I probably overlooked something...
PHP код:
[03:01:41] [debugRun time error 4"Array index out of bounds"
[03:01:41] [debug]  Accessing element at index 4996 past array upper bound 999
[03:01:41] [debugAMX backtrace:
[
03:01:41] [debug#0 001280b8 in ?? (0, 9015868, 0) from LeetHackz.amx
[03:01:41] [debug#1 00044d30 in ?? (0, 9015812, 0) from LeetHackz.amx
[03:01:41] [debug#2 00046bec in ?? (0, 9015812, 0, 0, 0, 8, 0, 9015812, 0, 0, ... <1073741813 arguments>) from LeetHackz.amx
[03:01:41] [debug#3 000096c0 in public OnPlayerCommandText (0, 9015812) from LeetHackz.amx 
PHP код:
CMD:buyfurniture(playerid,params[]) {
    
#pragma unused params
    
new fid;
    if(
sscanf(params,"i",fid)) return SendClientMessage(playerid,COLOR_RED,"Usage: /buyfurniture [ID]");
    if(
GetPlayerCash(playerid) < GetFurniturePrice(fid)) return SendClientMessage(playerid,COLOR_RED,"Not enough money");
    if(
AccInfo[playerid][HouseOwner] == 0) return SendClientMessage(playerid,COLOR_RED,"You dont own a house");
    for(new 
0MAX_HOUSES;x++) {
        if(
HouseInfo[x][Owned] == 1) {
            if(
AccInfo[playerid][HouseOwner] == HouseInfo[x][HID]) {
                
                
HouseInfo[x][HouseFurniture] += 1;
                
                new 
furnitureid CreateDynamicObject(fidHouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ], 0,0,0HouseInfo[x][VirtualWorld],HouseInfo[x][Interior]);
                
FurnitureData[furnitureid][FurnitureSlot] = HouseInfo[x][HouseFurniture];
                
FurnitureData[furnitureid][FurnitureMaster] = x;
                
FurnitureData[furnitureid][FurnitureModel] = fid;
                
FurnitureData[furnitureid][FurnitureX] = HouseInfo[x][ExitX];
                
FurnitureData[furnitureid][FurnitureY] = HouseInfo[x][ExitY];
                
FurnitureData[furnitureid][FurnitureZ] = HouseInfo[x][ExitZ];
                
FurnitureData[furnitureid][FurnitureInterior] = HouseInfo[x][Interior];
                
FurnitureData[furnitureid][FurnitureWorld] = HouseInfo[x][VirtualWorld];
                
                new 
query[512];
                
mysql_format(mysqlquerysizeof(query),"INSERT INTO `furniture` (`Master`,`Slot`,`Model`,`X`,`Y`,`Z`,`RX`,`RY`,`RZ`,`Interior`,`World`) VALUES ('%i','%i','%i','%f','%f','%f','%f','%f','%f','%i','%i')",\
                
HouseInfo[x][HID],HouseInfo[x][HouseFurniture],fid,HouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ],0.0,0.0,0.0,HouseInfo[x][Interior],HouseInfo[x][VirtualWorld]);
                
mysql_tquery(mysqlquery"OnFurnitureCreation""i"furnitureid);
                print(
query);
                
            }
        }
    }
    return 
true;

Reply
#2

I believe the problem is here:

PHP код:
new furnitureid CreateDynamicObject(fidHouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ], 0,0,0HouseInfo[x][VirtualWorld],HouseInfo[x][Interior]); 
FurnitureData[furnitureid][FurnitureSlot] = HouseInfo[x][HouseFurniture]; 
FurnitureData[furnitureid][FurnitureMaster] = x
FurnitureData[furnitureid][FurnitureModel] = fid
FurnitureData[furnitureid][FurnitureX] = HouseInfo[x][ExitX]; 
FurnitureData[furnitureid][FurnitureY] = HouseInfo[x][ExitY]; 
FurnitureData[furnitureid][FurnitureZ] = HouseInfo[x][ExitZ]; 
FurnitureData[furnitureid][FurnitureInterior] = HouseInfo[x][Interior]; 
FurnitureData[furnitureid][FurnitureWorld] = HouseInfo[x][VirtualWorld]; 
Why don't you print the furnitureid variable value just to be sure?
Reply
#3

Quote:
Originally Posted by zPain
Посмотреть сообщение
I believe the problem is here:

PHP код:
new furnitureid CreateDynamicObject(fidHouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ], 0,0,0HouseInfo[x][VirtualWorld],HouseInfo[x][Interior]); 
FurnitureData[furnitureid][FurnitureSlot] = HouseInfo[x][HouseFurniture]; 
FurnitureData[furnitureid][FurnitureMaster] = x
FurnitureData[furnitureid][FurnitureModel] = fid
FurnitureData[furnitureid][FurnitureX] = HouseInfo[x][ExitX]; 
FurnitureData[furnitureid][FurnitureY] = HouseInfo[x][ExitY]; 
FurnitureData[furnitureid][FurnitureZ] = HouseInfo[x][ExitZ]; 
FurnitureData[furnitureid][FurnitureInterior] = HouseInfo[x][Interior]; 
FurnitureData[furnitureid][FurnitureWorld] = HouseInfo[x][VirtualWorld]; 
Why don't you print the furnitureid variable value just to be sure?
Actually I just tested that, Ive found out that the problem is in this for some awkward reason
PHP код:
if(HouseInfo[x][Owned] >= 1) { // It was == now its >=1 
Basically it checks of the house is set as owned and its whats causing the error. I tried removing the code, no error but in that case it wont basically get the correct results



EDIT: no no wait, you are actually correct, the furnitureid is casuing the issue, I wonder why tho, any ideas? I tried printing out the stuff, but no results since it displays the crash detect results first
Reply
#4

Print the value right after you declare the variable.

PHP код:
new furnitureid CreateDynamicObject(fidHouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ], 0,0,0HouseInfo[x][VirtualWorld],HouseInfo[x][Interior]); 
printf("furnitureid = %d"furnitureid); 
Reply
#5

Quote:
Originally Posted by zPain
Посмотреть сообщение
Print the value right after you declare the variable.

PHP код:
new furnitureid CreateDynamicObject(fidHouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ], 0,0,0HouseInfo[x][VirtualWorld],HouseInfo[x][Interior]); 
printf("furnitureid = %d"furnitureid); 
Yeah sorry couldnt respond till now, well I did and the output for /buyfurniture 2880 is
PHP код:
[05:16:34furnitureid4996 
Reply
#6

The highest index allowed by FurnitureData is 999, so 4996 won't work.
Reply
#7

PHP код:
CMD:buyfurniture(playerid,params[]) { 
    
#pragma unused params 
    
new fid
    if(
sscanf(params,"i",fid)) return SendClientMessage(playerid,COLOR_RED,"Usage: /buyfurniture [ID]"); 
    if(
GetPlayerCash(playerid) < GetFurniturePrice(fid)) return SendClientMessage(playerid,COLOR_RED,"Not enough money"); 
    if(
AccInfo[playerid][HouseOwner] == 0) return SendClientMessage(playerid,COLOR_RED,"You dont own a house"); 

    for(new 
0MAX_HOUSES;x++) { 
        if(
HouseInfo[x][Owned] == 1) { 
            if(
AccInfo[playerid][HouseOwner] == HouseInfo[x][HID]) { 
                 
                
HouseInfo[x][HouseFurniture] += 1
                 
                new 
furnitureid CreateDynamicObject(fidHouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ], 0,0,0HouseInfo[x][VirtualWorld],HouseInfo[x][Interior]); 
                
FurnitureData[furnitureid][FurnitureSlot] = HouseInfo[x][HouseFurniture]; 
                
FurnitureData[furnitureid][FurnitureMaster] = x
                
FurnitureData[furnitureid][FurnitureModel] = fid
                
FurnitureData[furnitureid][FurnitureX] = HouseInfo[x][ExitX]; 
                
FurnitureData[furnitureid][FurnitureY] = HouseInfo[x][ExitY]; 
                
FurnitureData[furnitureid][FurnitureZ] = HouseInfo[x][ExitZ]; 
                
FurnitureData[furnitureid][FurnitureInterior] = HouseInfo[x][Interior]; 
                
FurnitureData[furnitureid][FurnitureWorld] = HouseInfo[x][VirtualWorld]; 
                 
                new 
query[512]; 
                
mysql_format(mysqlquerysizeof(query),"INSERT INTO `furniture` (`Master`,`Slot`,`Model`,`X`,`Y`,`Z`,`RX`,`RY`,`RZ`,`Interior`,`World`) VALUES ('%i','%i','%i','%f','%f','%f','%f','%f','%f','%i','%i')",\ 
                
HouseInfo[x][HID],HouseInfo[x][HouseFurniture],fid,HouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ],0.0,0.0,0.0,HouseInfo[x][Interior],HouseInfo[x][VirtualWorld]); 
                
mysql_tquery(mysqlquery"OnFurnitureCreation""i"furnitureid); 
                print(
query); 
                 
            } 
        } 
    } 
    return 
true

Why are you using #pragma unused params if you are using parameter at your command?
Reply
#8

Quote:
Originally Posted by vassilis
Посмотреть сообщение
PHP код:
CMD:buyfurniture(playerid,params[]) { 
    
#pragma unused params 
    
new fid
    if(
sscanf(params,"i",fid)) return SendClientMessage(playerid,COLOR_RED,"Usage: /buyfurniture [ID]"); 
    if(
GetPlayerCash(playerid) < GetFurniturePrice(fid)) return SendClientMessage(playerid,COLOR_RED,"Not enough money"); 
    if(
AccInfo[playerid][HouseOwner] == 0) return SendClientMessage(playerid,COLOR_RED,"You dont own a house"); 
    for(new 
0MAX_HOUSES;x++) { 
        if(
HouseInfo[x][Owned] == 1) { 
            if(
AccInfo[playerid][HouseOwner] == HouseInfo[x][HID]) { 
                 
                
HouseInfo[x][HouseFurniture] += 1
                 
                new 
furnitureid CreateDynamicObject(fidHouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ], 0,0,0HouseInfo[x][VirtualWorld],HouseInfo[x][Interior]); 
                
FurnitureData[furnitureid][FurnitureSlot] = HouseInfo[x][HouseFurniture]; 
                
FurnitureData[furnitureid][FurnitureMaster] = x
                
FurnitureData[furnitureid][FurnitureModel] = fid
                
FurnitureData[furnitureid][FurnitureX] = HouseInfo[x][ExitX]; 
                
FurnitureData[furnitureid][FurnitureY] = HouseInfo[x][ExitY]; 
                
FurnitureData[furnitureid][FurnitureZ] = HouseInfo[x][ExitZ]; 
                
FurnitureData[furnitureid][FurnitureInterior] = HouseInfo[x][Interior]; 
                
FurnitureData[furnitureid][FurnitureWorld] = HouseInfo[x][VirtualWorld]; 
                 
                new 
query[512]; 
                
mysql_format(mysqlquerysizeof(query),"INSERT INTO `furniture` (`Master`,`Slot`,`Model`,`X`,`Y`,`Z`,`RX`,`RY`,`RZ`,`Interior`,`World`) VALUES ('%i','%i','%i','%f','%f','%f','%f','%f','%f','%i','%i')",\ 
                
HouseInfo[x][HID],HouseInfo[x][HouseFurniture],fid,HouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ],0.0,0.0,0.0,HouseInfo[x][Interior],HouseInfo[x][VirtualWorld]); 
                
mysql_tquery(mysqlquery"OnFurnitureCreation""i"furnitureid); 
                print(
query); 
                 
            } 
        } 
    } 
    return 
true

Why are you using #pragma unused params if you are using parameter at your command?
That doesnt really affect anything mate
Quote:
Originally Posted by iPLEOMAX
Посмотреть сообщение
pawn Код:
new myvar;
#pragma unused myvar
What it basically does it that, it marks "myvar" as 'USED' so you don't get compiler warnings.

Nothing more/nothing less.

If you see warnings because of unused variables, you either need to use this or delete the variable.

In case of ZCMD, it's not necessary to add the "unused" symbol at all..
But yeah, the problem remains, im aware that furnitureid is causing the problem, just not sure how to fix it.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)