SA-MP Forums Archive
OnFilterScriptInit doesn't get fully executed. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnFilterScriptInit doesn't get fully executed. (/showthread.php?tid=425292)



OnFilterScriptInit doesn't get fully executed. - Denying - 25.03.2013

Hey there, first of all thank you for reading this.


Alright, so I've this code:
pawn Код:
public OnFilterScriptInit()
{
    for(new i = 0; i <= MAX_HOUSES; i++)
    {
        new sale = 1272;
        format(file1, sizeof(file1), "Houses/House_%d.ini", i);
        if(fexist(file1))
        {
            format(HouseText, sizeof(HouseText), "{31A353}[ {FFFFFF}House ID: %d {31A353}]", i);
            if(HouseInfo[i][Owned] == true)
            {
                format(name1, sizeof(name1), "%s", dini_Get(file1, "Owner"));
                rreplace(name1, '_', ' ');
                format(HouseTextAdd, sizeof(HouseTextAdd), "\n{31A353}Owner: {FFFFFF}%s", name1);
                strcat(HouseText, HouseTextAdd);
            }
            if(HouseInfo[i][ForSale] == true)
            {
                format(HouseTextAdd, sizeof(HouseTextAdd), "\n{31A353}Price: {FFFFFF}%d", HouseInfo[i][Price]);
                strcat(HouseText, HouseTextAdd);
                sale = 1273;
            }
            if(HouseInfo[i][ForRent] == true)
            {
                format(HouseTextAdd, sizeof(HouseTextAdd), "\n{31A353}Rent: {FFFFFF}%d\n{31A353}Commands: {FFFFFF}/rentroom, /unrent", dini_Int(file1, "RentPrice"));
                strcat(HouseText, HouseTextAdd);
            }
            HouseLabel[i] = Create3DTextLabel(HouseText, 0xFFFFFFFF, HouseInfo[i][EnterX], HouseInfo[i][EnterY], HouseInfo[i][EnterZ], 20.0, 0, 0);
            HousePickup[i] = CreatePickup(sale, 1, HouseInfo[i][EnterX], HouseInfo[i][EnterY], HouseInfo[i][EnterZ], 0);
        }
    }
    print("haha");
    for(new hloop = 0; hloop <= MAX_PLAYERS; hloop++)
    {
        print("haha");
        HouseID[hloop] = -1;
        InHouseID[hloop] = -1;
    }
    print("haha");
    for(new houseloop = 0; houseloop <= MAX_HOUSES; houseloop++)
    {
        format(file1, 128, "Houses/House_%d.ini", houseloop);
        HouseInfo[houseloop][EnterX] = dini_Float(file1, "EnterX");
        HouseInfo[houseloop][EnterY] = dini_Float(file1, "EnterY");
        HouseInfo[houseloop][EnterZ] = dini_Float(file1, "EnterZ");
        HouseInfo[houseloop][ExitX] = dini_Float(file1, "ExitX");
        HouseInfo[houseloop][ExitY] = dini_Float(file1, "ExitY");
        HouseInfo[houseloop][ExitZ] = dini_Float(file1, "ExitZ");
        HouseInfo[houseloop][Price] = dini_Int(file1, "Price");
        HouseInfo[houseloop][RentPrice] = dini_Int(file1, "RentPrice");
        HouseInfo[houseloop][Interior] = dini_Int(file1, "Interior");
        HouseInfo[houseloop][Owned] = dini_Bool(file1, "Owned") ? true : false;
        HouseInfo[houseloop][ForRent] = dini_Bool(file1, "ForRent") ? true : false;
        HouseInfo[houseloop][Locked] = dini_Bool(file1, "Locked") ? true : false;
        HouseInfo[houseloop][ForSale] = dini_Bool(file1, "ForSale") ? true : false;
    }
    print(" It should work gsdgsdhsdgsdgsgsdgsdg. ");
    return 1;
}
And it looks like not all of it gets executed.
I debugged it and only the first print is shown.. What may stop the code from working after the first print?
( NOTE: I tried printing inside the second loop just after the first print and nothing. )

Thank you in advance.


AW: OnFilterScriptInit doesn't get fully executed. - Nero_3D - 25.03.2013

The only logical solution is that hloop isnt small equal than MAX_PLAYERS :S

Check what that prints
pawn Код:
//
    for(new hloop = 0; !printf("%d <= %d", hloop, MAX_PLAYERS) && hloop <= MAX_PLAYERS; hloop++)
    {
        HouseID[hloop] = -1;
        InHouseID[hloop] = -1;
    }



Re: OnFilterScriptInit doesn't get fully executed. - Denying - 25.03.2013

Well, it printed every number above -1 and lower than 501 like you told it to do.
So yeah it gets executed, but the other parts of code ( under it ) doesn't.. I tried doing the same but nothing helped, I really can't understand what you done there to make it work. You only added prints..


Re: OnFilterScriptInit doesn't get fully executed. - iggy1 - 25.03.2013

Like nero suggested its most likely your accessing the houseinfo out of bounds.

Try changing

pawn Код:
for(new i = 0; i <= MAX_HOUSES; i++)
To
pawn Код:
for(new i = 0; i < MAX_HOUSES; i++)
Use less than, not less than or equal. Remember array indexes start from zero so the max array slot will always be MAX_HOUSES-1.

EDIT: Just as an example try using houseinfo[MAX_HOUSES][Owned] and compile, you will get an error message. That is what is happening at runtime.


Re: OnFilterScriptInit doesn't get fully executed. - Denying - 25.03.2013

I see what you did there.
One little problem.. my MAX_HOUSES is defined as 50.. but when I loop with the printf it shows 500.. why would it do that? xD