OnGameModeInit stops or something.
#1

So i have
pawn Code:
if(!fexist(DOORS_FILE))
    {
        print("NO DOOR FILE! CREATING A NEW ONE!");
        fcreate(DOORS_FILE);
        return 1;
    }
    else
    {
        for(new d=0;d<MAX_DOORS;d++)
        {
            new string[128];
            format(string, sizeof(string),"Door_%d",d);
            if(djIsSet(DOORS_FILE, string))
            {
                LoadDoor(d);
                return 1;
            }
            return 1;
        }
    }
Under OnGameModeInit, and after that i'm adding player classes, setting mode name etc.
The problem is, that anything that should be loaded after this code just doesn't load and my mode is set to Unknown.
LoadDoor function.
pawn Code:
public LoadDoor(id)
{
    new string2[128], name[128];
    DestroyDynamicPickup(DoorInfo[id][dPp]);
    format(string2, sizeof(string2),"Door_%d/ExteriorX", id); DoorInfo[id][dExteriorX] = djFloat(DOORS_FILE, string2);
    format(string2, sizeof(string2),"Door_%d/ExteriorY", id); DoorInfo[id][dExteriorY] = djFloat(DOORS_FILE, string2);
    format(string2, sizeof(string2),"Door_%d/ExteriorZ", id); DoorInfo[id][dExteriorZ] = djFloat(DOORS_FILE, string2);
    format(string2, sizeof(string2),"Door_%d/ExteriorInt", id); DoorInfo[id][dExteriorInt] = djInt(DOORS_FILE, string2);
    format(string2, sizeof(string2),"Door_%d/InteriorX", id); DoorInfo[id][dInteriorX] = djFloat(DOORS_FILE, string2);
    format(string2, sizeof(string2),"Door_%d/InteriorY", id); DoorInfo[id][dInteriorY] = djFloat(DOORS_FILE, string2);
    format(string2, sizeof(string2),"Door_%d/InteriorZ", id); DoorInfo[id][dInteriorZ] = djFloat(DOORS_FILE, string2);
    format(string2, sizeof(string2),"Door_%d/InteriorInt", id); DoorInfo[id][dInteriorInt] = djInt(DOORS_FILE, string2);
    format(string2, sizeof(string2),"Door_%d/Type", id); DoorInfo[id][dType] = djInt(DOORS_FILE, string2);
    format(string2, sizeof(string2),"Door_%d/Team", id); DoorInfo[id][dTeam] = djInt(DOORS_FILE, string2);
    format(string2, sizeof(string2),"Door_%d/Owned", id); DoorInfo[id][dOwned] = djInt(DOORS_FILE, string2);
    format(string2, sizeof(string2),"Door_%d/Owner", id); format(name, sizeof(name), "%s", dj(DOORS_FILE, string2)); DoorInfo[id][dOwner] = name;
    format(string2, sizeof(string2),"Door_%d/Locked", id); DoorInfo[id][dLocked] = djInt(DOORS_FILE, string2);
    format(string2, sizeof(string2),"Door_%d/Name", id); format(name, sizeof(name), "%s", dj(DOORS_FILE, string2)); DoorInfo[id][dName] = name;
    Itter_Add(Doors, Iter_Count(Doors) + 1);
    DoorInfo[id][dPp] = CreateDynamicPickup(1239, 2, DoorInfo[id][dExteriorX], DoorInfo[id][dExteriorY], DoorInfo[id][dExteriorZ], -1, DoorInfo[id][dExteriorInt], -1, 50.0);
    if(DoorInfo[id][dType] == 1)
    {
        DoorInfo[id][dLocked] = 0;
        return 1;
    }
    else if(DoorInfo[id][dType] == 2)
    {
        DoorInfo[id][dLocked] = 1;
        return 1;
    }
    return 1;
}
This code works fine in my other GM.
Reply
#2

Move >>
pawn Code:
if(!fexist(DOORS_FILE))
    {
        print("NO DOOR FILE! CREATING A NEW ONE!");
        fcreate(DOORS_FILE);
        return 1;
    }
    else
    {
        for(new d=0;d<MAX_DOORS;d++)
        {
            new string[128];
            format(string, sizeof(string),"Door_%d",d);
            if(djIsSet(DOORS_FILE, string))
            {
                LoadDoor(d);
                return 1;
            }
            return 1;
        }
    }
To the bottom of OnGameModeInit
Reply
#3

I got this problem to, my problem is I got more of such stuff.
Reply
#4

Add printf("LINE NUMBER HERE");
Every few lines to find out at which line exactly it stops working. If you know that, you will see the problem easily most of the times.

Things that can cause the callback to stop and do not crash the server can be wrong array indexes. You are using a lot of arrays in that function, might be worth to give it a look.
Reply
#5

Quote:
Originally Posted by Mauzen
View Post
Add printf("LINE NUMBER HERE");
Every few lines to find out at which line exactly it stops working. If you know that, you will see the problem easily most of the times.

Things that can cause the callback to stop and do not crash the server can be wrong array indexes. You are using a lot of arrays in that function, might be worth to give it a look.
Mhm, it cannot be the arrays, because it works fine in my other GM. When i'll be back from school ill debug the script.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)