Problem with function
#1

Problem is that my save function makes 20 lines wich all are same... why?
Код:
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0

OR

831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
831.504394,-871.401550,68.789062,0.000000,0.000000,135.162384,0,0
pawn Код:
#define MAX_ADS 20

enum KAdsInfo
{
    nblank,
    objectidsa,
    costed,
    Float:aX,
    Float:aY,
    Float:aZ,
    Float:rotX,
    Float:rotY,
    Float:rotZ,
    aObject,
    Text3D:aLabel
};

new kadscoords[MAX_ADS][KAdsInfo];

stock SavefixAds()
{
    new filestring[256];
    new File: file = fopen(AD_FILE, io_write);
    for(new adid = 0; adid < MAX_ADS; adid++)
    {
            format(filestring, sizeof(filestring), "%f,%f,%f,%f,%f,%f,%i,%i\n",
            kadscoords[adid][aX],
            kadscoords[adid][aY],
            kadscoords[adid][aZ],
            kadscoords[adid][rotX],
            kadscoords[adid][rotY],
            kadscoords[adid][rotZ],
            kadscoords[adid][objectidsa],
            kadscoords[adid][costed]
            );
        fwrite(file, filestring);
    }
    fclose(file);
}
The function part wich creates object ja 3dtext and saves coords to array..
pawn Код:
if (cSetting[fixmoney] > cSetting[adkyltti1])
            {
            new msg[145];
            new Float:x, Float:y, Float:z, Float:Angle;
            GetPlayerPos(playerid, x, y, z);
            GetPlayerFacingAngle(playerid, Angle);
            for(new adid = 1; adid < MAX_ADS; adid++)
            {
            kadscoords[adid][aX] = x;
            kadscoords[adid][aY] = y;
            kadscoords[adid][aZ] = z;
            kadscoords[adid][rotX] = 0.0;
            kadscoords[adid][rotY] = 0.0;
            kadscoords[adid][rotZ] = Angle;
            kadscoords[adid][aObject] = CreateDynamicObject(cSetting[adkylttiid1], kadscoords[adid][aX], kadscoords[adid][aY], kadscoords[adid][aZ], kadscoords[adid][rotX], kadscoords[adid][rotY], Angle);
            kadscoords[adid][aLabel] = Create3DTextLabel(fixcentername[fixcenteradtext], ADS_COLOR, kadscoords[adid][aX], kadscoords[adid][aY], kadscoords[adid][aZ], DRAW_DISRANCE_3DTEXT, 0, 1);
            }
            cSetting[fixmoney] = (cSetting[fixmoney] - cSetting[adkyltti1]);
            format(msg, sizeof(msg), "Ostit juuri kyltin joka maksoi %iЂ (Raha veloitettiin korjaamon tililtд ja sinne jдi vielд %iЂ)", cSetting[adkyltti1], cSetting[fixmoney]);
            ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX, fixcentername[fixcenter], msg, "OK","Poistu");
            UpdateDynamicADLabels();
            }
            else
            {
            SendClientMessage(playerid, COLOR_YELLOW, "Korjaamon tilillд ei ole edes noin paljon rahaa!");
            new string[65];
            format(string, sizeof(string), "Pieni kyltti %iЂ\nNormaali kyltti %iЂ\nIso kyltti %iЂ", cSetting[adkyltti1], cSetting[adkyltti2], cSetting[adkyltti3]);
            ShowPlayerDialog(playerid, 2356, DIALOG_STYLE_LIST, fixcentername[fixcenter], string, "Valitse", "Poistu");
            }
What wrong there is?

BTW SavefixAds() is called on ongameexit.

Also got problem with loading function
pawn Код:
stock LoadFixAds()
{
    new SplitDiv[8][MAX_ADS];
    new filestring[256];
    new File: file = fopen(AD_FILE, io_read);
    if (file)
    {
        for(new adid = 1;adid<=MAX_ADS;adid++)
        {
            fread(file, filestring);
            split(filestring, SplitDiv, ',');
            kadscoords[adid][aX] = floatstr(SplitDiv[0]);
            kadscoords[adid][aY] = floatstr(SplitDiv[1]);
            kadscoords[adid][aZ] = floatstr(SplitDiv[2]);
            kadscoords[adid][rotX] = floatstr(SplitDiv[3]);
            kadscoords[adid][rotY] = floatstr(SplitDiv[4]);
            kadscoords[adid][rotZ] = floatstr(SplitDiv[5]);
            kadscoords[adid][objectidsa] = strval(SplitDiv[6]);
            kadscoords[adid][costed] = strval(SplitDiv[7]);
            kadscoords[adid][aObject] = CreateDynamicObject(kadscoords[adid][objectidsa], kadscoords[adid][aX], kadscoords[adid][aY], kadscoords[adid][aZ], kadscoords[adid][rotX], kadscoords[adid][rotY], kadscoords[adid][rotZ]);
            kadscoords[adid][aLabel] = Create3DTextLabel(fixcentername[fixcenteradtext], ADS_COLOR, kadscoords[adid][aX], kadscoords[adid][aY], kadscoords[adid][aZ], DRAW_DISRANCE_3DTEXT, 0, 1);
        }
    }
    fclose(file);
}
When called from ongamemodeinit it causes only cj skin avaible at spawn.... wtf?
Reply
#2

EDIT: Remove.
Reply
#3

Bumb.....
Reply
#4

bumb.....
Reply
#5

Well, how to fix that? :F
Reply
#6

bump...
Really need help with this. How I can fix that stupid looping? I have been stucked on this now many weeks with no idea or anything... and anyone can tell why LoadFixAds() causes only CJ skin avaible? (It is called at ongamemodeinit)
Reply
#7

bump....
Reply
#8

Yeah you said
Quote:
Originally Posted by ******
Посмотреть сообщение
Because you do a loop and set all slots to the same data in second chunk of code.
Second chunk of code? Wich one? And, if I remove loop then where from it gets adid?

(I am noob, indeed)....
Reply
#9

Quote:
Originally Posted by woaha
Посмотреть сообщение
Yeah you said


Second chunk of code? Wich one? And, if I remove loop then where from it gets adid?

(I am noob, indeed)....
bumb....
Reply
#10

Quote:
Originally Posted by woaha
Посмотреть сообщение
bumb....
Bumb? Are you Justin Bieber?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)