YCMD:nkucu(playerid, params[],help) { #pragma unused help if(P_Enum[playerid][pe_GameAdmin] != 6) return GRESKA( playerid, "Nemate ovlastenje za koriscenje ove komande!"); new idkuce = GetHouseEmptyID(MAX_KUCA), vrsta, Float:X,Float:Y,Float:Z,fkuce[80],string[300]; GetPlayerPos(playerid,X,Y,Z); if(sscanf(params, "i",vrsta)) { INFO( playerid, "/nkucu (vrsta)"); SCM(playerid,-1,"0) Mala kuca 1) Srednja kuca 2) Vila"); return 1; } format(fkuce, sizeof(fkuce), KUCE_FILE, idkuce); if(fexist(fkuce)) return SCM(playerid,-1, "ID te kuce vec postoji!"); if(vrsta < 0 || vrsta > 2) return GRESKA(playerid, "Pogresna vrsta!"); if(vrsta == 0) // MALA KUCA { K_Enum[idkuce][ke_ExitX] = -125.9703; K_Enum[idkuce][ke_ExitY] = 1316.7201; K_Enum[idkuce][ke_ExitZ] = -25.3044; K_Enum[idkuce][ke_interijer] = 0; strmid(K_Enum[idkuce][ke_Vrsta],"Mala Kuca",0,strlen("Mala Kuca"),255); K_Enum[idkuce][ke_Intpromjena] = 1; K_Enum[idkuce][ke_Level] = 5; K_Enum[idkuce][ke_Cijena] = 50000; } else if(vrsta == 1) // SREDNJA KUCA { K_Enum[idkuce][ke_ExitX] = 463.2021; K_Enum[idkuce][ke_ExitY] = 507.4315; K_Enum[idkuce][ke_ExitZ] = 999.6569; K_Enum[idkuce][ke_interijer] = 0; strmid(K_Enum[idkuce][ke_Vrsta],"Srednja Kuca",0,strlen("Srednja Kuca"),255); K_Enum[idkuce][ke_Intpromjena] = 2; K_Enum[idkuce][ke_Level] = 7; K_Enum[idkuce][ke_Cijena] = 90000; } else if(vrsta == 2) // Vila { K_Enum[idkuce][ke_ExitX] = 1140.6886; K_Enum[idkuce][ke_ExitY] = -840.4586; K_Enum[idkuce][ke_ExitZ] = 1086.5728; K_Enum[idkuce][ke_interijer] = 0; strmid(K_Enum[idkuce][ke_Vrsta],"Vila",0,strlen("Vila"),255); K_Enum[idkuce][ke_Intpromjena] = 3; K_Enum[idkuce][ke_Level] = 10; K_Enum[idkuce][ke_Cijena] = 130000; } K_Enum[idkuce][ke_EnterX] = X; K_Enum[idkuce][ke_EnterY] = Y; K_Enum[idkuce][ke_EnterZ] = Z; K_Enum[idkuce][ke_Kupljena] = 0; K_Enum[idkuce][ke_Pari] = 0; K_Enum[idkuce][ke_Mats] = 0; K_Enum[idkuce][ke_LSD] = 0; K_Enum[idkuce][ke_Kokain] = 0; K_Enum[idkuce][ke_Mara] = 0; K_Enum[idkuce][ke_Oruzje1] = 0; K_Enum[idkuce][ke_Oruzje2] = 0; K_Enum[idkuce][ke_Oruzje3] = 0; K_Enum[idkuce][ke_Oruzje4] = 0; K_Enum[idkuce][ke_Metkovi1] = 0; K_Enum[idkuce][ke_Metkovi2] = 0; K_Enum[idkuce][ke_Metkovi3] = 0; K_Enum[idkuce][ke_Metkovi4] = 0; K_Enum[idkuce][ke_VrataLevel] = 0; K_Enum[idkuce][ke_Alarm] = 0; K_Enum[idkuce][ke_BravaLevel] = 0; K_Enum[idkuce][ke_Locked] = 1; K_Enum[idkuce][ke_VW] = idkuce; strmid(K_Enum[idkuce][ke_Vlasnik],"Niko",0,strlen("Niko"),255); format(string,sizeof(string),""col_kuca"Kuca na Prodaju("COL_WHITE"%d"col_kuca")\nVrsta: "COL_WHITE"%s\n"col_kuca"Cijena: "COL_WHITE"%d\n"col_kuca"Level: "COL_WHITE"%d\n"col_kuca"Adresa: "COL_WHITE"%s\n"col_kuca"Za kupovinu "COL_WHITE"/kupikucu",idkuce, K_Enum[idkuce][ke_Vrsta],K_Enum[idkuce][ke_Cijena],K_Enum[idkuce][ke_Level], UlicaKuce(idkuce)); KucaLabel[idkuce] = Create3DTextLabel(string ,0x33CCFFAA,X,Y,Z,25,0,1); KucaPickup[idkuce] = CreatePickup(1273, 1, K_Enum[idkuce][ke_EnterX], K_Enum[idkuce][ke_EnterY], K_Enum[idkuce][ke_EnterZ]); SCM(playerid,-1,"Kuca je uspjesno kreirana!"); SacuvajKucu(idkuce); return 1; }
stock GetHouseEmptyID(const len) { new id = (1); for(new loop = (0), provjera = (1), Data_[64] = "\0"; loop != len; ++ loop) { provjera = (loop+1); format(Data_, (sizeof Data_), KUCE_FILE, provjera); if(!fexist(Data_)) { id = (provjera); break; } } return (id); }
for(new loop = (0), provjera = (1), Data_[64] = "\0"; loop < len; ++ loop)
Apart from seeing that you check files for existing house (that's stupid) i can see that you will always return valid id ( new id = (1); )
Also you start counting houses from 1, while they should start from 0. Every array start from 0. Код:
for(new loop = (0), provjera = (1), Data_[64] = "\0"; loop < len; ++ loop) |
Compile with -d3 flag and post index at witch it overflows. (Crash detect should tell you that)
Meanwhile you can also comment code and test block by block and line by line to find where it overflows (but compiling with -d3 would be easier as it will tell you max array length and last accessed element. |