issue data file
#1

PHP код:
new labeltext[80];
                
format(labeltextsizeof(labeltext), "Building ID %d\nBuilding Level %d\nType /scavenge to Scavenge",ammunationid,store);
        
dini_Set(file"BuildingName"labeltext); 
here is the code I want to ask why result in my file is
PHP код:
BuildingName=Building ID 0
Building Level 1
Type 
/scavenge to Scavenge 
and after reload when funcion try to load file and make 3DTextLabel
PHP код:
            StoreLabel[dini_Int(file"BuildingID")] = Create3DTextLabel(dini_Get(file"BuildingName"), 0x00BC00FFdini_Float(file"CPOutX"), dini_Float(file"CPOutY"), dini_Float(file"CPOutZ")+0.72501); 
only be charged
PHP код:
BuildingName=Building ID 0 
without
PHP код:
Building Level 1
Type 
/scavenge to Scavenge 
Reply
#2

someone?
Reply
#3

The problem is that dini_Get is defined as:

pawn Код:
stock dini_Get(filename[],key[]) {
        new tmpres[DINI_MAX_STRING];
       
        new key_length = strlen(key);
        if (key_length==0 || key_length+2>DINI_MAX_STRING) return tmpres;
       
        new File:fohnd;
        fohnd=fopen(filename,io_read);
        if (!fohnd) return tmpres;
       
        while (fread(fohnd,tmpres)) {
                if (
                        tmpres[key_length]=='='
                        && !strcmp(tmpres, key, true, key_length)      
                ) {
                        /* We've got what we need */
                        DINI_StripNewLine(tmpres);
                        strmid(tmpres, tmpres, key_length + 1, strlen(tmpres), DINI_MAX_STRING);
                        fclose(fohnd);
                        return tmpres;
                }
        }
        fclose(fohnd);
        return tmpres;
}
(at least the original one)

So it will read only one line.
I suggest you to do

pawn Код:
new labeltext[80];
                format(labeltext, sizeof(labeltext), "Building ID %d#Building Level %d#Type /scavenge to Scavenge",ammunationid,store);
        dini_Set(file, "BuildingName", labeltext); // changed \n to #
So your file will be saved like this
Код:
BuildingName=Building ID 0#Building Level 1#Type /scavenge to Scavenge
but then when creating the label we will convert a # to a \n

pawn Код:
new labelname[32];
labelname = dini_Get(file, "BuildingName");
str_replace("#", "\n", labelname);

StoreLabel[dini_Int(file, "BuildingID")] = Create3DTextLabel(labelname, 0x00BC00FF, dini_Float(file, "CPOutX"), dini_Float(file, "CPOutY"), dini_Float(file, "CPOutZ")+0.7, 25, 0, 1);

And define this stock function (from strlib by westie)
pawn Код:
stock str_replace(sSearch[], sReplace[], const sSubject[], &iCount = 0)
{
    new
        iLengthTarget = strlen(sSearch),
        iLengthReplace = strlen(sReplace),
        iLengthSource = strlen(sSubject),
        iItterations = (iLengthSource - iLengthTarget) + 1;

    new
        sTemp[128],
        sReturn[_strlib_med_string];

    strcat(sReturn, sSubject, _strlib_med_string);
    iCount = 0;

    for(new iIndex; iIndex < iItterations; ++iIndex)
    {
        strmid(sTemp, sReturn, iIndex, (iIndex + iLengthTarget), (iLengthTarget + 1));

        if(!strcmp(sTemp, sSearch, false))
        {
            strdel(sReturn, iIndex, (iIndex + iLengthTarget));
            strins(sReturn, sReplace, iIndex, iLengthReplace);

            iIndex += iLengthTarget;
            iCount++;
        }
    }

    return sReturn;
}
I hope I was helpful
Reply
#4

PHP код:
D:\Downloads\ZombieWorld\pawno\include\SRB.inc(227) : error 047: array sizes do not match, or destination array is too small
D
:\Downloads\ZombieWorld\pawno\include\SRB.inc(268) : error 017undefined symbol "_strlib_med_string"
D:\Downloads\ZombieWorld\pawno\include\SRB.inc(268) : error 009invalid array size (negativezero or out of bounds)
D:\Downloads\ZombieWorld\pawno\include\SRB.inc(268) : warning 217loose indentation
D
:\Downloads\ZombieWorld\pawno\include\SRB.inc(268) : error 036: empty statement
D
:\Downloads\ZombieWorld\pawno\include\SRB.inc(268) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
5 Errors

I get these errors
Here is the code from line 266 to 270
PHP код:
    new
        
sTemp[128],
        
sReturn[_strlib_med_string];
    
strcat(sReturnsSubject_strlib_med_string); 
Reply
#5

sorry for that, I didn't test it, then try to download the full library (https://sampforum.blast.hk/showthread.php?tid=85697) and include it in your script
Reply
#6

PHP код:
D:\Downloads\ZombieWorld\filterscripts\reality.pwn(392) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
1 Error

Line 392
PHP код:
            labelname dini_Get(file"BuildingName"); 
Edit:
I fixed it, I found the error just changed
PHP код:
     new labelname[32]; 
to
PHP код:
new labelname[256]; 
Reply
#7

I do not know what happens now, but do not want to replace the # with \n
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)