string problem
#1

I have a string maxlength problem, and im using strlib;

here are the errors:

Код:
Sign.pwn(92) : error 017: undefined symbol "maxlength"
Sign.pwn(92) : error 029: invalid expression, assumed zero
Sign.pwn(92) : warning 215: expression has no effect
here are the lines:

Код:
SetSignText(signid, text[])
{
	if(!Iter_Contains(sgn_Index, signid))
		return 0;

	str_replace(text, "\\n", "\n", .maxlength = MAX_SIGN_TEXT);

	strcpy(sgn_Data[signid][sgn_text], text, MAX_SIGN_TEXT);
	strcat(sgn_Data[signid][sgn_text], "\n\n\n");

	SetDynamicObjectMaterialText(sgn_Data[signid][sgn_object], 0, text, OBJECT_MATERIAL_SIZE_512x512, "Arial", 72, 1, -16777216, -1, 1);

	return 1;
}
Reply
#2

From this include: https://sampforum.blast.hk/showthread.php?tid=85697? If so:
pawn Код:
/*
    str_replace:
        Case sensitive string replace

    Arguments:
        sSearch[]    String to search for
        sReplace[]   String to replace with
        sSubject[]   Original string
        (op) &iCount  How many times 'sSearch' has been replaced.

    Returns:
        Replaced string.
*/

native str_replace(sSearch[], sReplace[], const sSubject[], &iCount = 0)
there isn't any maxlength parameter. In Slice's include, there is; however the function is called strreplace.
Reply
#3

i used strreplace., it says unknown symbol :/
Reply
#4

pawn Код:
stock strreplace(string[], find, replace)
{
    for(new i=0; string[i]; i++)
    {
        if(string[i] == find)
        {
            string[i] = replace;
        }
    }
    return replace;
}
Reply
#5

Quote:
Originally Posted by MatriXgaMer
Посмотреть сообщение
pawn Код:
stock strreplace(string[], find, replace)
{
    for(new i=0; string[i]; i++)
    {
        if(string[i] == find)
        {
            string[i] = replace;
        }
    }
    return replace;
}
Thank you very much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)