Stops processing after the 2nd debug (house command)
#1

Well, as it's debugged below it stops processing after the 2nd debug, any idea why?

pawn Код:
new Float:RandomInts[][]=
{
    {223.20,1287.08,1082.14},
    {2283.04,-1140.28,1050.90},
    {328.05,1477.73,1084.44},
    {223.20,1287.08,1082.14},
    {2233.64,-1115.26,1050.88},
    {2259.38,-1135.77,1050.64}
};
//1
//11
//15
//1
//5
//10
CMD:createhouse(playerid,params[])
{
    if(PlayerInfo[playerid][pAdmin] == 4)
    {
        new price,Float:x,Float:y,Float:z,id,file[40],inside = random(sizeof(RandomInts))
        ,randomvw = 100000 + random(99999),interior;
        if(sscanf(params,"i",price)) return MSG(playerid,COLOR_RED,"SERVER: /createhouse [house price]");
        if(inside == 0){interior = 1;}
        if(inside == 1){interior = 11;}
        if(inside == 2){interior = 15;}
        if(inside == 3){interior = 1;}
        if(inside == 4){interior =5;}
        if(inside == 5){interior =10;}
        id = GetHouseSlot();
        print("until now1");
        GetPlayerPos(playerid,x,y,z);
        print("until now2"); // --> stops here
        H[id][Price] = price;
        print("until now1");
        H[id][hX] = x;
        H[id][hY] = y;
        H[id][hZ] = z;
        print("until now3");
        H[id][hiX] = RandomInts[inside][0];
        H[id][hiY] = RandomInts[inside][1];
        H[id][hiZ] = RandomInts[inside][2];
        print("until now4");
        H[id][hiInt] = interior;
        H[id][hVW] = GetPlayerVirtualWorld(playerid);
        print("until now5");
        H[id][hiVW] = randomvw;
        print("until now6");
        format(H[id][Owner],24,"The State");
        MSG(playerid,WHITE,"SERVER: House created.");
        print("until now7");
        HouseEnter[id] = CreateDynamicCP(x,y,z,1.0,GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid),-1,5);
        print("until now8");
        HouseExit[id] = CreateDynamicCP(RandomInts[inside][0],RandomInts[inside][1],RandomInts[inside][2],1.0,randomvw,interior,-1,5);
        print("until now9");
        format(file,sizeof(file),HOUSE,id);
        print("until now10");
        new INI:File = INI_Open(file);
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Price",price);
        INI_WriteInt(File,"Owned",0);
        INI_WriteInt(File,"VW",GetPlayerVirtualWorld(playerid));
        INI_WriteFloat(File,"X",x);
        INI_WriteFloat(File,"Y",y);
        INI_WriteFloat(File,"Z",z);
        INI_WriteFloat(File,"Xin",RandomInts[inside][0]);
        INI_WriteFloat(File,"Yin",RandomInts[inside][1]);
        INI_WriteFloat(File,"Zin",RandomInts[inside][2]);
        INI_WriteInt(File,"VWin",randomvw);
        INI_WriteInt(File,"hiInt",interior);
        INI_WriteString(File,"Owner","The State");
        INI_Close(File);
        print("until now11");
        validhouse[id] = 1;
        print("until now12");
        printf("%f %f %f %i",RandomInts[inside][0],RandomInts[inside][1],RandomInts[inside][2],interior);
        print("until now13");
    }
    return 1;
}
stock GetHouseSlot()
{
    for(new i = 0; i < MAX_HOUSES;i++)
    {
        if(validhouse[i] == 0) return i;
        else continue;
    }
    return -1;
}
Thanks.
Reply
#2

Figured out that the GetHouseSlot is returning -1 after house ID 0 is being used, why's that?
Reply
#3

And can we see GetHouseSlot function ?
Reply
#4

It's at the bottom of my code. Incase you didn't see it, here it is.

pawn Код:
stock GetHouseSlot()
{
    for(new i = 0; i < MAX_HOUSES;i++)
    {
        if(validhouse[i] == 0) return i;
        else continue;
    }
    return -1;
}
Reply
#5

Well if it returns -1 then it means it has gone through the entire loop without finding a 0 in "validhouse". So you'll need to look at the code that populates that array.
Reply
#6

Oh, right. I was looping and setting every validhouse value to true without checking if that house exists or not when loading, thanks for your time lads.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)