string problem - 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)
+--- Thread: string problem (
/showthread.php?tid=485535)
string problem -
Battlezone - 04.01.2014
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;
}
Re: string problem -
Konstantinos - 04.01.2014
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.
Re: string problem -
Battlezone - 04.01.2014
i used strreplace., it says unknown symbol :/
Re: string problem -
MatriXgaMer - 04.01.2014
pawn Код:
stock strreplace(string[], find, replace)
{
for(new i=0; string[i]; i++)
{
if(string[i] == find)
{
string[i] = replace;
}
}
return replace;
}
Re: string problem -
Battlezone - 04.01.2014
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!