Problem with function
#1

When Loading stock get called; it only creates 1 object and unloading function doesn't work at all. Why?

Enum
pawn Код:
#define MAX_SUIHKUOBJ 33 // File contains 32 lines
enum krsuihku
{
    model,
    Float:kroX,
    Float:kroY,
    Float:kroZ,
    Float:kroRX,
    Float:kroRY,
    Float:kroRZ
};
new korjaamosuihku[MAX_SUIHKUOBJ][krsuihku];
Loading stock
pawn Код:
new SplitDiv[7][MAX_SUIHKUOBJ];
            new filestring[256];
            new File: file = fopen(SUIHKU_FILE, io_read);
            if (file)
            {
            for(new krsid = 0; krsid < MAX_SUIHKUOBJ; krsid++)
            {
            fread(file, filestring);
            split(filestring, SplitDiv, ',');
            korjaamosuihku[krsid][model] = strval(SplitDiv[0]);
            korjaamosuihku[krsid][kroX] = floatstr(SplitDiv[1]);
            korjaamosuihku[krsid][kroY] = floatstr(SplitDiv[2]);
            korjaamosuihku[krsid][kroZ] = floatstr(SplitDiv[3]);
            korjaamosuihku[krsid][kroRX] = floatstr(SplitDiv[4]);
            korjaamosuihku[krsid][kroRY] = floatstr(SplitDiv[5]);
            korjaamosuihku[krsid][kroRZ] = floatstr(SplitDiv[6]);
            krsid = CreateDynamicObject(korjaamosuihku[krsid][model], korjaamosuihku[krsid][kroX], korjaamosuihku[krsid][kroY], korjaamosuihku[krsid][kroZ], korjaamosuihku[krsid][kroRX], korjaamosuihku[krsid][kroRY], korjaamosuihku[krsid][kroRZ]);
            }
        }
        fclose(file);
        issuihkuon = 1;
Unloading stock
pawn Код:
stock UnloadKorjaamoSuihku()
{

        for(new krsid = 0; krsid < MAX_SUIHKUOBJ; krsid++)
        {
        DestroyDynamicObject(krsid);
        }
        issuihkuon = 0;

}
Calling
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 2, 450.1813,-1850.3495,5.4607))
        {
        if(issuihkuon == 0)
        {
        LoadKorjaamoSuihku();
        }
        if(issuihkuon == 1)
        {
        UnloadKorjaamoSuihku();
        }
        }
Reply
#2

bumb
Reply
#3

bumb
Reply
#4

You must add into array
pawn Код:
korjaamosuihku[krsid][Loaded] = CreateDynamicObject(...
and then
pawn Код:
stock UnloadKorjaamoSuihku()
{
    for(new krsid = 0; krsid < MAX_SUIHKUOBJ; krsid++)
    {
        if(korjaamosuihku[krsid][Loaded] != 0) {
            DestroyDynamicObject(krsid);
            korjaamosuihku[krsid][Loaded]=0;
        }
    }
    issuihkuon = 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)