SA-MP Forums Archive
Saving A String.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Saving A String.. (/showthread.php?tid=162810)



Saving A String.. - [L3th4l] - 24.07.2010

I have problems save a string, i got this dynamic 3d text. So i can create ingame, when i exit it saves that file. But when i create the label, the save part is not working correct. After i create the label in-game, it does work and it creates the label as i named it.

So, when i close the server, the file saves but it won't save the text i typed while in -game. It saves a number :/

here is the saving part:

pawn Код:
stock LoadLabels()
{
    for(new x = 0; x <MAX_LABELS; x++)
    {
        format(lFile,sizeof(lFile),LABELFILE,x);
        format(lInfo[x][LInfo], 100, "%s", dini_Get(lFile, "LInfo"));
        lInfo[x][LabelX]    = dini_Float(lFile,"LabelX");
        lInfo[x][LabelY]    = dini_Float(lFile,"LabelY");
        lInfo[x][LabelZ]    = dini_Float(lFile,"LabelZ");
        lInfo[x][LID]       = CreateDynamic3DTextLabel(lInfo[x][LInfo], 0xFFFFFF,lInfo[x][LabelX],lInfo[x][LabelY],lInfo[x][LabelZ],100,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0,-1,-1,-1,100);
    }
}

stock CreateSavedLabel(name[], Float:x, Float:y, Float:z)
{
    format(lIDFile, sizeof(lIDFile), LABELIDFILE);
    if(!dini_Exists(lIDFile))
    {
        dini_Create(lIDFile);
        dini_IntSet(lIDFile, "Total 3D Labels:", -1);
    }
    else
    {
        dini_IntSet(lIDFile, "Total 3D Labels:", dini_Int(lIDFile, "Total 3D Labels:")+1);
    }

    new lID = dini_Int(lIDFile, "Total 3D Labels:");
    format(lFile, sizeof(lFile), LABELFILE, lID);
    if(!dini_Exists(lFile)) dini_Create(lFile);

    format(lInfo[lID][LInfo], 100, "%s", name);
    lInfo[lID][LabelX]  = x;
    lInfo[lID][LabelY]  = y;
    lInfo[lID][LabelZ]  = z;
    lInfo[lID][LID]     = CreateDynamic3DTextLabel(name, 0xFFFFFF, x, y, z, 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100);
}

public SaveLabels()
{
    for(new x=0; x<MAX_LABELS; x++)
    {
        format(lFile, sizeof(lFile),    LABELFILE, x);
       
        dini_IntSet     (lFile, "LInfo",    lInfo[x][LInfo]);
        dini_FloatSet   (lFile, "LabelX",   lInfo[x][LabelX]);
        dini_FloatSet   (lFile, "LabelY",   lInfo[x][LabelY]);
        dini_FloatSet   (lFile, "LabelZ",   lInfo[x][LabelZ]);
    }
}
Im guessing is something in the savelabels part.

Btw, LInfo = the name i add to the label.


Re: Saving A String.. - [L3th4l] - 25.07.2010

Bumpy Bumb Bump! I tried a diff method but got the same result, i don't understand how to format that string..


Re: Saving A String.. - PotH3Ad - 25.07.2010

Replace this line under the SaveLabels() function:

pawn Код:
dini_IntSet(lFile, "LInfo", lInfo[x][LInfo]);
With:

pawn Код:
dini_Set(lFile, "LInfo", lInfo[x][LInfo]);
dini_IntSet saves an integer, dini_Set saves a string -_-...


Re: Saving A String.. - Dudits - 25.07.2010

pawn Код:
stock LoadLabels()
{
    for(new x = 0; x <MAX_LABELS; x++)
    {
        format(lFile,sizeof(lFile),LABELFILE,x);
        format(lInfo[x][LInfo], 100, "%s", dini_Get(lFile, "LInfo"));
        lInfo[x][LabelX]    = dini_Float(lFile,"LabelX");
        lInfo[x][LabelY]    = dini_Float(lFile,"LabelY");
        lInfo[x][LabelZ]    = dini_Float(lFile,"LabelZ");
        lInfo[x][LID]       = CreateDynamic3DTextLabel(lInfo[x][LInfo], 0xFFFFFF,lInfo[x][LabelX],lInfo[x][LabelY],lInfo[x][LabelZ],100,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0,-1,-1,-1,100);
    }
}

stock CreateSavedLabel(name[], Float:x, Float:y, Float:z)
{
    format(lIDFile, sizeof(lIDFile), LABELIDFILE);
    if(!dini_Exists(lIDFile))
    {
        dini_Create(lIDFile);
        dini_Set(lIDFile, "Total 3D Labels:", -1);
    }
    else
    {
        dini_Set(lIDFile, "Total 3D Labels:", dini_Get(lIDFile, "Total 3D Labels:")+1);
    }

    new lID = dini_Get(lIDFile, "Total 3D Labels:");
    format(lFile, sizeof(lFile), LABELFILE, lID);
    if(!dini_Exists(lFile)) dini_Create(lFile);

    format(lInfo[lID][LInfo], 100, "%s", name);
    lInfo[lID][LabelX]  = x;
    lInfo[lID][LabelY]  = y;
    lInfo[lID][LabelZ]  = z;
    lInfo[lID][LID]     = CreateDynamic3DTextLabel(name, 0xFFFFFF, x, y, z, 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100);
}

public SaveLabels()
{
    for(new x=0; x<MAX_LABELS; x++)
    {
        format(lFile, sizeof(lFile),    LABELFILE, x);
       
        dini_Set     (lFile, "LInfo",    lInfo[x][LInfo]);
        dini_FloatSet   (lFile, "LabelX",   lInfo[x][LabelX]);
        dini_FloatSet   (lFile, "LabelY",   lInfo[x][LabelY]);
        dini_FloatSet   (lFile, "LabelZ",   lInfo[x][LabelZ]);
    }
}
Try this, simply I changed the "IntSet" to "Set" and "Int" to "Get"
Edit: Try PotH3Ad's first though, I didn't look into the code, I just replaced the Int's with Strings.


Re: Saving A String.. - [L3th4l] - 25.07.2010

thanx P0t And Dudits

btw, P0t is a feg xiter xD