Understanding foreach.
#2

pawn Код:
// Use this under OnGameModeInit() - for loading
stock LoadDoor(id)
{
    new string[128], string2[128], name[128];
    format(string, sizeof(string), "Door_%d", id);
    if(djIsSet(DOORS_FILE, string))
    {
        format(string2, sizeof(string2),"Door_%d/ExteriorX", id); DoorInfo[id][dExteriorX] = djFloat(DOORS_FILE, string);
        format(string2, sizeof(string2),"Door_%d/ExteriorY", id); DoorInfo[id][dExteriorY] = djFloat(DOORS_FILE, string);
        format(string2, sizeof(string2),"Door_%d/ExteriorZ", id); DoorInfo[id][dExteriorZ] = djFloat(DOORS_FILE, string);
        format(string2, sizeof(string2),"Door_%d/ExteriorInt", id); DoorInfo[id][dExteriorInt] = djInt(DOORS_FILE, string);
        format(string2, sizeof(string2),"Door_%d/InteriorX", id); DoorInfo[id][dInteriorX] = djFloat(DOORS_FILE, string);
        format(string2, sizeof(string2),"Door_%d/InteriorY", id); DoorInfo[id][dInteriorY] = djFloat(DOORS_FILE, string);
        format(string2, sizeof(string2),"Door_%d/InteriorZ", id); DoorInfo[id][dInteriorZ] = djFloat(DOORS_FILE, string);
        format(string2, sizeof(string2),"Door_%d/InteriorInt", id); DoorInfo[id][dInteriorInt] = djInt(DOORS_FILE, string);
        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);
        return 1;
    }
    return 1;
}
pawn Код:
stock AddDoor(Float:x, Float:y, Float:z, interior, name[])
{
    new string2[128];
    Itter_Add(Doors, Iter_Count(Doors) + 1);
    dCount =  Iter_Count(Doors) ;
    format(string2, sizeof(string2), "Door_%d/ExteriorX", dCount); djSetFloat(DOORS_FILE, string2, x);
    format(string2, sizeof(string2), "Door_%d/ExteriorY", dCount); djSetFloat(DOORS_FILE, string2, y);
    format(string2, sizeof(string2), "Door_%d/ExteriorZ", dCount); djSetFloat(DOORS_FILE, string2, z);
    format(string2, sizeof(string2), "Door_%d/ExteriorInt", dCount); djSetInt(DOORS_FILE, string2, interior);
    format(string2, sizeof(string2), "Door_%d/InteriorX", dCount); djSetFloat(DOORS_FILE, string2, 0);
    format(string2, sizeof(string2), "Door_%d/InteriorY", dCount); djSetFloat(DOORS_FILE, string2, 0);
    format(string2, sizeof(string2), "Door_%d/InteriorZ", dCount); djSetFloat(DOORS_FILE, string2, 0);
    format(string2, sizeof(string2), "Door_%d/InteriorInt", dCount); djSetInt(DOORS_FILE, string2, 0);
    format(string2, sizeof(string2), "Door_%d/Name", dCount); djSet(DOORS_FILE, string2, name);

    DoorInfo[dCount][dExteriorX] = x;
    DoorInfo[dCount][dExteriorY] = y;
    DoorInfo[dCount][dExteriorZ] =  z;
    DoorInfo[dCount][dExteriorInt] = interior;
    DoorInfo[dCount][dInteriorX] = // interior
    DoorInfo[dCount][dInteriorY] =  // interior
    DoorInfo[dCount][dInteriorZ] = // interior
    format(DoorInfo[dCount][dName], sizeof(DoorInfo[dCount][dName]), "%s", name);

    DoorInfo[dCount][dPp] = CreateDynamicPickup(1239, 2, DoorInfo[dCount][dExteriorX], DoorInfo[dCount][dExteriorY], DoorInfo[dCount][dExteriorZ], -1, DoorInfo[dCount][dExteriorInt], -1, 50.0);
    return 1;
}
Try this.
EDIT: You shouldn't use LoadDoor() function into AddDoor() function, because it will add 2 itters.
LoadDoor() should be used under ongamemodeinit , therefore , loading when server starts.
You should assign the right variables under AddDoor() not LoadDoor()
Reply


Messages In This Thread
Understanding foreach. - by sekol - 24.03.2011, 16:54
Re: Understanding foreach. - by armyoftwo - 24.03.2011, 17:06
Re: Understanding foreach. - by sekol - 24.03.2011, 17:45
Re: Understanding foreach. - by armyoftwo - 25.03.2011, 07:10
Re: Understanding foreach. - by sekol - 25.03.2011, 07:17
Re: Understanding foreach. - by armyoftwo - 25.03.2011, 07:21
Re: Understanding foreach. - by sekol - 25.03.2011, 07:23
Re: Understanding foreach. - by sekol - 25.03.2011, 13:17

Forum Jump:


Users browsing this thread: 1 Guest(s)