SA-MP Forums Archive
constant expression ; - 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: constant expression ; (/showthread.php?tid=266028)



constant expression ; - willsuckformoney - 03.07.2011

I get the error:
Код:
error 008: must be a constant expression; assumed zero
but I don't know how to fix it. The code is:
pawn Код:
new pName[24] = text;
Anyone know how to fix?


Re: constant expression ; - Bakr - 03.07.2011

pawn Код:
strins( pName, text, 0 );
Alternatively, you could use strmid, or strcat.


Re: constant expression ; - jameskmonger - 03.07.2011

pawn Код:
new pName[24];
format(pName, sizeof(pName), "%s", text);



Re: constant expression ; - Bakr - 03.07.2011

Quote:
Originally Posted by jameskmonger
Посмотреть сообщение
pawn Код:
new pName[24];
format(pName, sizeof(pName), "%s", text);
You're better off using strcat to copy a string to another (which is the essential idea here). ****** mentioned it in one of his threads before that using format to copy a string isn't that great.


Re: constant expression ; - willsuckformoney - 03.07.2011

Thanks Bakr, that helped.