debug error
#1

[10:57:40] [debug] Run time error 4: "Array index out of bounds"
[10:57:40] [debug] Accessing element at negative index -1
[10:57:40] [debug] AMX backtrace:
[10:57:40] [debug] #0 000be480 in public OnStoreLoad () at C:\Users\jaz\Desktop\SAMP\gamemodes\CNR/store/store.pwn:296
PHP код:
Function OnStoreLoad()
{
    new 
        
0,
        
s[64]
    ;
    for(new 
0xx cache_num_rows(); xxx++) 
    {
        
Iter_Free(Stores);
        
Store[i][StoreID] = cache_get_field_content_int(x"id");
        
Store[i][StoreX] = cache_get_field_content_float(x"x");
        
Store[i][StoreY] = cache_get_field_content_float(x"y");
        
Store[i][StoreZ] = cache_get_field_content_float(x"z");
        
Store[i][StoreA] = cache_get_field_content_float(x"angle");
        
Store[i][StoreInteriorID] = cache_get_field_content_int(x"interiorid");
        
cache_get_field_content(x"name"s);
        
format(Store[i][StoreName], 64"%s"s);
        
Store[i][StoreMoney] = cache_get_field_content_int(x"money");
        
Store[i][StoreMoneyPerDay] = cache_get_field_content_int(x"mpd");
        
Store[i][StorePrice] = cache_get_field_content_int(x"price");
        
Store[i][StoreLevel] = cache_get_field_content_int(x"level");
        
Store[i][StoreIconID] = cache_get_field_content_int(x"mapicon");
        
Store[i][StoreOwner] = cache_get_field_content_int(x"owner");
        
Store[i][StoreIcon] = CreateDynamicMapIcon(Store[i][StoreX], Store[i][StoreY], Store[i][StoreZ], Store[i][StoreIconID], -100, .style MAPICON_GLOBAL);
        
Store[i][StoreEnterPickup] = CreateDynamicPickup(13181Store[i][StoreX], Store[i][StoreY], Store[i][StoreZ], 00, -135.0);
        new 
intid IsInteriorExist(Store[i][StoreInteriorID]), label[256];
        if(
Store[i][StorePrice] == 1337)
            
format(label256"{FF0000}[%s]\n{FFFFFF}{FFFF66}ID: {FFFFFF}%d\n{FFFF66}Owner: {FFFFFF}The Government"Store[i][StoreName], Store[i][StoreID]);
        else if(
Store[i][StoreOwner] == 0)
            
format(label256"{FF0000}[%s]\n{FFFFFF}{FFFF66}ID: {FFFFFF}%d\n{FFFF66}Owner: {FFFFFF}Unowned\n{FFFF66}Price: {FFFFFF}$%m\n{FFFF66}Level: {FFFFFF}%d\n{FFFF66}$%m per gameday"Store[i][StoreName], Store[i][StoreID], Store[i][StorePrice], Store[i][StoreLevel], Store[i][StoreMoneyPerDay]);
        else
            
format(label256"{FF0000}[%s]\n{FFFFFF}{FFFF66}ID: {FFFFFF}%d\n{FFFF66}Owner: {FFFFFF}%s\n{FFFF66}Price: {FFFFFF}$%m\n{FFFF66}Level: {FFFFFF}%d\n{FFFF66}$%m per gameday"Store[i][StoreName], Store[i][StoreID], ReturnNameFromID(Store[i][StoreOwner]), Store[i][StorePrice], Store[i][StoreLevel], Store[i][StoreMoneyPerDay]);
        
Store[i][StoreStatus] = STORE_IDLE;
        
Store[i][StoreSafe] = CreateSafe(Interior[intid][InteriorSafeID], Store[i][StoreID]);
        
Store[i][StoreExitCP] = CreateDynamicCP(Interior[intid][InteriorX], Interior[intid][InteriorY], Interior[intid][InteriorZ], 1.0Store[i][StoreID], Interior[intid][InteriorIntID]);
        
Store[i][StoreEnterLabel] = CreateDynamic3DTextLabel(label, -1Store[i][StoreX], Store[i][StoreY], Store[i][StoreZ], 10.0, .worldid 0, .interiorid 0);
        
UpdateDynamic3DTextLabelText(Store[i][StoreEnterLabel], -1label);
        
Store[i][StoreRobberyCP] = CreateSafeCP(Interior[intid][InteriorSafeID], Store[i][StoreID]);
        
Store[i][StoreRobberyLabel] = CreateRobberyLabel(Interior[intid][InteriorSafeID], Store[i][StoreID]);
        
Store[i][StoreActor] = CreateActor(Interior[intid][InteriorActorSkin], Interior[intid][InteriorActorX], Interior[intid][InteriorActorY], Interior[intid][InteriorActorZ], Interior[intid][InteriorActorA]);
        switch(
random(4))
        {
            case 
0:
                
ApplyActorAnimation(Store[i][StoreActor], "PED""roadcross"4.111110);
            case 
1:
                
ApplyActorAnimation(Store[i][StoreActor], "PED""roadcross_female"4.111110);
            case 
2:
                
ApplyActorAnimation(Store[i][StoreActor], "PED","roadcross_gang"4.111110);
            case 
3:
                
ApplyActorAnimation(Store[i][StoreActor], "PED","roadcross_old"4.111110);
        }
        
SetActorVirtualWorld(Store[i][StoreActor], Store[i][StoreID]);
        
Iter_Add(Storesi);
    }
    return 
1;

Reply
#2

Try to use "x" instead "i"
Reply
#3

not working
Reply
#4

Line 296, please
Reply
#5

Store[i][StoreStatus] = STORE_IDLE;
Reply
#6

I advice you to write this load anew
Reply
#7

Код:
Function OnStoreLoad() 
{ 
    new  
        i = 0, 
        s[64] 
    ; 
    for(new x = 0, xx = cache_num_rows(); x < xx; x++)  
    { 
        Store[i][StoreID] = cache_get_field_content_int(x, "id"); 
        Store[i][StoreX] = cache_get_field_content_float(x, "x"); 
        Store[i][StoreY] = cache_get_field_content_float(x, "y"); 
        Store[i][StoreZ] = cache_get_field_content_float(x, "z"); 
        Store[i][StoreA] = cache_get_field_content_float(x, "angle"); 
        Store[i][StoreInteriorID] = cache_get_field_content_int(x, "interiorid"); 
        cache_get_field_content(x, "name", s); 
        format(Store[i][StoreName], 64, "%s", s); 

        Store[i][StoreMoney] = cache_get_field_content_int(x, "money"); 
        Store[i][StoreMoneyPerDay] = cache_get_field_content_int(x, "mpd"); 
        Store[i][StorePrice] = cache_get_field_content_int(x, "price"); 
        Store[i][StoreLevel] = cache_get_field_content_int(x, "level"); 
        Store[i][StoreIconID] = cache_get_field_content_int(x, "mapicon"); 
        Store[i][StoreOwner] = cache_get_field_content_int(x, "owner"); 
        Store[i][StoreIcon] = CreateDynamicMapIcon(Store[i][StoreX], Store[i][StoreY], Store[i][StoreZ], Store[i][StoreIconID], -1, 0, 0, .style = MAPICON_GLOBAL); 

        Store[i][StoreEnterPickup] = CreateDynamicPickup(1318, 1, Store[i][StoreX], Store[i][StoreY], Store[i][StoreZ], 0, 0, -1, 35.0); 

        new intid = IsInteriorExist(Store[i][StoreInteriorID]), label[256]; 
        if(Store[i][StorePrice] == 1337) 
            format(label, 256, "{FF0000}[%s]\n{FFFFFF}{FFFF66}ID: {FFFFFF}%d\n{FFFF66}Owner: {FFFFFF}The Government", Store[i][StoreName], Store[i][StoreID]); 
        else if(Store[i][StoreOwner] == 0) 
            format(label, 256, "{FF0000}[%s]\n{FFFFFF}{FFFF66}ID: {FFFFFF}%d\n{FFFF66}Owner: {FFFFFF}Unowned\n{FFFF66}Price: {FFFFFF}$%m\n{FFFF66}Level: {FFFFFF}%d\n{FFFF66}$%m per gameday", Store[i][StoreName], Store[i][StoreID], Store[i][StorePrice], Store[i][StoreLevel], Store[i][StoreMoneyPerDay]); 
        else 
            format(label, 256, "{FF0000}[%s]\n{FFFFFF}{FFFF66}ID: {FFFFFF}%d\n{FFFF66}Owner: {FFFFFF}%s\n{FFFF66}Price: {FFFFFF}$%m\n{FFFF66}Level: {FFFFFF}%d\n{FFFF66}$%m per gameday", Store[i][StoreName], Store[i][StoreID], ReturnNameFromID(Store[i][StoreOwner]), Store[i][StorePrice], Store[i][StoreLevel], Store[i][StoreMoneyPerDay]); 

        Store[i][StoreStatus] = STORE_IDLE; 
        Store[i][StoreSafe] = CreateSafe(Interior[intid][InteriorSafeID], Store[i][StoreID]); 
        Store[i][StoreExitCP] = CreateDynamicCP(Interior[intid][InteriorX], Interior[intid][InteriorY], Interior[intid][InteriorZ], 1.0, Store[i][StoreID], Interior[intid][InteriorIntID]); 
        Store[i][StoreEnterLabel] = CreateDynamic3DTextLabel(label, -1, Store[i][StoreX], Store[i][StoreY], Store[i][StoreZ], 10.0, .worldid = 0, .interiorid = 0); 
        UpdateDynamic3DTextLabelText(Store[i][StoreEnterLabel], -1, label); 
        Store[i][StoreRobberyCP] = CreateSafeCP(Interior[intid][InteriorSafeID], Store[i][StoreID]); 
        Store[i][StoreRobberyLabel] = CreateRobberyLabel(Interior[intid][InteriorSafeID], Store[i][StoreID]); 
        Store[i][StoreActor] = CreateActor(Interior[intid][InteriorActorSkin], Interior[intid][InteriorActorX], Interior[intid][InteriorActorY], Interior[intid][InteriorActorZ], Interior[intid][InteriorActorA]); 
        switch(random(4)) 
        { 
            case 0: 
                ApplyActorAnimation(Store[i][StoreActor], "PED", "roadcross", 4.1, 1, 1, 1, 1, 0); 
            case 1: 
                ApplyActorAnimation(Store[i][StoreActor], "PED", "roadcross_female", 4.1, 1, 1, 1, 1, 0); 
            case 2: 
                ApplyActorAnimation(Store[i][StoreActor], "PED","roadcross_gang", 4.1, 1, 1, 1, 1, 0); 
            case 3: 
                ApplyActorAnimation(Store[i][StoreActor], "PED","roadcross_old", 4.1, 1, 1, 1, 1, 0); 
        } 
        SetActorVirtualWorld(Store[i][StoreActor], Store[i][StoreID]); 
    } 
    return 1; 
}
Try this for me please and see if the error shows!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)