SA-MP Forums Archive
Inserting a small text in between 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)
+--- Thread: Inserting a small text in between a string. (/showthread.php?tid=462290)



Inserting a small text in between a string. - Black Wolf - 06.09.2013

Hey,

I m fetching inputtext to another variable.After 79th position i wanna insert ~n~ and then the rest goes.

Can anyone help pls.


Re: Inserting a small text in between a string. - Dragonsaurus - 06.09.2013

pawn Код:
if(strlen(othervariable) >= 79) strins(othervariable, "~n~", 79, sizeof(othervariable));



Re: Inserting a small text in between a string. - Misiur - 06.09.2013

@up - you meant strlen, not strval.


Re: Inserting a small text in between a string. - Black Wolf - 06.09.2013

Код:
C:\Users\newpwn.pwn(28794) : warning 224: indeterminate array size in "sizeof" expression (symbol "maxlength")
On the same line.
pawn Код:
if(strlen(inputtext) >= 79) strins(inputtext, "~n~", 79);



Re: Inserting a small text in between a string. - Dragonsaurus - 06.09.2013

@Misiur - Yeah, you are right, thanks for correcting


Re: Inserting a small text in between a string. - Black Wolf - 06.09.2013

fixed thanks repped


Re: Inserting a small text in between a string. - Misiur - 06.09.2013

Sizeof inputtext is just a reference and compiler doesn't know what's its real size. Try

pawn Код:
if(strlen(inputtext) >= 79) strins(inputtext, "~n~", 79, 128);