Problem with cycles in OnGameModeInit()
#1

Hello, I have problem with cycles. When my gamemode start - all function start with him but
PHP код:
   for(new b2;b++) {
    
chickfree[b] = CreateDynamicPickup(1318,23,chickinfree[b][0],chickinfree[b][1],chickinfree[b][2]);
    
CreateDynamic3DTextLabel("Íàçâàíèå: {ffffff}Ïèööåðèÿ\n{03c03c}Âëàäåëåö: {ffffff}Ïðàâèòåëüñòâî\n{03c03c}Òèï: {ffffff}Çàêóñî÷íàÿ",0x03c03cFFchickinfree[b][0],chickinfree[b][1],chickinfree[b][2]+0.904,15.0);
    
CreateDynamicMapIcon(chickinfree[b][0],chickinfree[b][1],chickinfree[b][2],29,COLOR_WHITE);
 }
for(new 
h2;h++) {
   new 
str[128];
   
fermarazd[h] = CreateDynamicPickup(1275,23,ferma[h][0],ferma[h][1],ferma[h][2],-1,-1,-1,100.0);
   
fermainfo[h] = CreateDynamicPickup(1239,23,ferma[h][3],ferma[h][4],ferma[h][5],-1,-1,-1,100.0);
   
CreateDynamicMapIcon(ferma[h][3],ferma[h][4],ferma[h][5],56,COLOR_WHITE);
   
format(str,sizeof(str),"{ffcc00}Ôåðìà ID: {ffffff}%d\n{ffcc00}Ñòîèìîñòü: {ffffff}500000\n{ffcc00}Èíôîðìàöèÿ: {ffffff}/finfo",h);
   
CreateDynamic3DTextLabel(str,COLOR_ORANGEferma[h][3],ferma[h][4],ferma[h][5]+1,10.0);
   } 
after these cycles other functions do not work, in particular LoadProperty();(also uses a cycles)
Reply
#2

Debug your code like the following
pawn Код:
print("1");
//code here
print("2");
//code here
//etc...
This will show you the exact point where the code is stopping. Post your LoadProperty code too so we can see if that's the issue.
Reply
#3

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
Debug your code like the following
pawn Код:
print("1");
//code here
print("2");
//code here
//etc...
This will show you the exact point where the code is stopping. Post your LoadProperty code too so we can see if that's the issue.
I already do this. After this
PHP код:
for(new b2;b++) {
    
chickfree[b] = CreateDynamicPickup(1318,23,chickinfree[b][0],chickinfree[b][1],chickinfree[b][2]);
    
CreateDynamic3DTextLabel("Название: {ffffff}Пиццерия\n{03c03c}Владелец: {ffffff}Правительство\n{03c03c}Тип: {ffffff}Закусочная",0x03c03cFFchickinfree[b][0],chickinfree[b][1],chickinfree[b][2]+0.904,15.0);
    
CreateDynamicMapIcon(chickinfree[b][0],chickinfree[b][1],chickinfree[b][2],29,COLOR_WHITE);
 }
for(new 
h2;h++) {
   new 
str[128];
   
fermarazd[h] = CreateDynamicPickup(1275,23,ferma[h][0],ferma[h][1],ferma[h][2],-1,-1,-1,100.0);
   
fermainfo[h] = CreateDynamicPickup(1239,23,ferma[h][3],ferma[h][4],ferma[h][5],-1,-1,-1,100.0);
   
CreateDynamicMapIcon(ferma[h][3],ferma[h][4],ferma[h][5],56,COLOR_WHITE);
   
format(str,sizeof(str),"{ffcc00}Ферма ID: {ffffff}%d\n{ffcc00}Стоимость: {ffffff}500000\n{ffcc00}Информация: {ffffff}/finfo",h);
   
CreateDynamic3DTextLabel(str,COLOR_ORANGEferma[h][3],ferma[h][4],ferma[h][5]+1,10.0);
   } 
functions a not work
Reply
#4

this my LoadProperty()
PHP код:
stock LoadProperty()
{
     print(
"LoadProp funct started[DEBUG]");
                new 
HOUSE;
                new 
q[128];
                new 
res[256];
                new 
idx;
                while(
idx 665)
   {
                
format(q,sizeof(q),"SELECT * FROM DOM_server WHERE ID_h = %d",idx);
                
mysql_query(q);
                
mysql_store_result();
                new 
ss;
                if(
mysql_fetch_row(res))
                {
                
sscanf(res,"p<|>dffffffs[24]dddddddddddffffdd",
                
ss,
                
HouseInfo[idx][hEntrancex],
                
HouseInfo[idx][hEntrancey],
                
HouseInfo[idx][hEntrancez],
                
HouseInfo[idx][hExitx],
                
HouseInfo[idx][hExity],
                
HouseInfo[idx][hExitz],
                
HouseInfo[idx][hOwner],
                
HouseInfo[idx][hValue],
                
HouseInfo[idx][hHel],
                
HouseInfo[idx][hInt],
                
HouseInfo[idx][hLock] ,
                
HouseInfo[idx][hOwned] ,
                
HouseInfo[idx][hTakings] ,
                
HouseInfo[idx][hVec],
                
HouseInfo[idx][hVcol1],
                
HouseInfo[idx][hVcol2] ,
                
HouseInfo[idx][hKlass],
                
HouseInfo[idx][hVehSost] ,
                
HouseInfo[idx][hCarx],
                
HouseInfo[idx][hCary],
                
HouseInfo[idx][hCarz],
                
HouseInfo[idx][hCarc],
                
HouseInfo[idx][hNarko],
                
HouseInfo[idx][hMoney]);
                
HOUSE++;
                
HouseInfo[idx][hPickup] = CreateDynamicPickup(1273,23,HouseInfo[idx][hEntrancex],HouseInfo[idx][hEntrancey],HouseInfo[idx][hEntrancez]);
                
HouseInfo[idx][hMIcon] = CreateDynamicMapIcon(HouseInfo[idx][hEntrancex],HouseInfo[idx][hEntrancey],HouseInfo[idx][hEntrancez],31,COLOR_WHITE);
                
mysql_free_result();
                }
            }
            print(
"Property LOAD");
            return 
true;
     } 
Reply
#5

Make sure you didn't return 1 anywhere before this code.

EDIT:
Remove this:

pawn Код:
return true;
return true/1 will make your code stop by there.
Reply
#6

Quote:
Originally Posted by ricardo178
Посмотреть сообщение
Make sure you didn't return 1 anywhere before this code.

EDIT:
Remove this:

pawn Код:
return true;
return true/1 will make your code stop by there.
Ok,but in console print only - "LoadProp funct started[DEBUG]" and print("Property LOAD") is not work and function too. But Houses loaded
Reply
#7

Please don't use a loop with mysql_query, fetch all the data at once with one query and then you won't need a loop. The function you have at the moment won't work anyway because you do not increase idx.

pawn Код:
stock LoadProperty()
{
    print("LoadProp funct started[DEBUG]");
    new idx, ss, res[256];
    mysql_query("SELECT * FROM DOM_server");
    mysql_store_result();
    while(mysql_retrieve_row())
    {
                sscanf(res,"p<|>dffffffs[24]dddddddddddffffdd",
                ss,
                HouseInfo[idx][hEntrancex],
                HouseInfo[idx][hEntrancey],
                HouseInfo[idx][hEntrancez],
                HouseInfo[idx][hExitx],
                HouseInfo[idx][hExity],
                HouseInfo[idx][hExitz],
                HouseInfo[idx][hOwner],
                HouseInfo[idx][hValue],
                HouseInfo[idx][hHel],
                HouseInfo[idx][hInt],
                HouseInfo[idx][hLock] ,
                HouseInfo[idx][hOwned] ,
                HouseInfo[idx][hTakings] ,
                HouseInfo[idx][hVec],
                HouseInfo[idx][hVcol1],
                HouseInfo[idx][hVcol2] ,
                HouseInfo[idx][hKlass],
                HouseInfo[idx][hVehSost] ,
                HouseInfo[idx][hCarx],
                HouseInfo[idx][hCary],
                HouseInfo[idx][hCarz],
                HouseInfo[idx][hCarc],
                HouseInfo[idx][hNarko],
                HouseInfo[idx][hMoney]);
                idx++;
                HouseInfo[idx][hPickup] = CreateDynamicPickup(1273,23,HouseInfo[idx][hEntrancex],HouseInfo[idx][hEntrancey],HouseInfo[idx][hEntrancez]);
                HouseInfo[idx][hMIcon] = CreateDynamicMapIcon(HouseInfo[idx][hEntrancex],HouseInfo[idx][hEntrancey],HouseInfo[idx][hEntrancez],31,COLOR_WHITE);
             
    }
    mysql_free_result();
    print("Property LOAD");
    return 1;
}
That should work now.
Reply
#8

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
This may not be your issue, but please don't use a loop with mysql_query, fetch all the data at once with one query and then you won't need a loop. The function you have at the moment won't work anyway because you do not increase idx.

pawn Код:
stock LoadProperty()
{
    print("LoadProp funct started[DEBUG]");
    new idx;
    new res[256];  
    mysql_query("SELECT * FROM DOM_server");
    mysql_store_result();
    new ss;
    while(mysql_retrieve_row())
    {
                sscanf(res,"p<|>dffffffs[24]dddddddddddffffdd",
                ss,
                HouseInfo[idx][hEntrancex],
                HouseInfo[idx][hEntrancey],
                HouseInfo[idx][hEntrancez],
                HouseInfo[idx][hExitx],
                HouseInfo[idx][hExity],
                HouseInfo[idx][hExitz],
                HouseInfo[idx][hOwner],
                HouseInfo[idx][hValue],
                HouseInfo[idx][hHel],
                HouseInfo[idx][hInt],
                HouseInfo[idx][hLock] ,
                HouseInfo[idx][hOwned] ,
                HouseInfo[idx][hTakings] ,
                HouseInfo[idx][hVec],
                HouseInfo[idx][hVcol1],
                HouseInfo[idx][hVcol2] ,
                HouseInfo[idx][hKlass],
                HouseInfo[idx][hVehSost] ,
                HouseInfo[idx][hCarx],
                HouseInfo[idx][hCary],
                HouseInfo[idx][hCarz],
                HouseInfo[idx][hCarc],
                HouseInfo[idx][hNarko],
                HouseInfo[idx][hMoney]);
                idx++;
                HouseInfo[idx][hPickup] = CreateDynamicPickup(1273,23,HouseInfo[idx][hEntrancex],HouseInfo[idx][hEntrancey],HouseInfo[idx][hEntrancez]);
                HouseInfo[idx][hMIcon] = CreateDynamicMapIcon(HouseInfo[idx][hEntrancex],HouseInfo[idx][hEntrancey],HouseInfo[idx][hEntrancez],31,COLOR_WHITE);
             
    }
    mysql_free_result();
    print("Property LOAD");
    return 1;
}
If the Property debug isn't even printing, can you post your whole OnGameModeInit?
O,sorry( I'am really forgot post in code
PHP код:
idx++ 
thx all!FIXED
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)