cmdtext 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: cmdtext string problem (
/showthread.php?tid=522276)
cmdtext string problem -
Riwerry - 26.06.2014
Hello guys, I have issue with cmdtext[] string.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) {
new
i;
printf("Before %s\n", cmdtext);
while (cmdtext[i++] != ' ') {
printf("%c", cmdtext[i]);
}
printf("After %s", cmdtext); //thats issue
return 0;
}
When I use as cmdtext /mycommand it outputs:
Before /mycommand
m
y
c
o
m
m
a
n
d
*NOTHING HERE*
It should output cmdtext string again, but this while loop ruins it.. why?
Re: cmdtext string problem -
Djole1337 - 26.06.2014
then you should do something like
pawn Код:
while (cmdtext[i++] != '\0')
Re: cmdtext string problem -
Riwerry - 26.06.2014
Yeah, but I need only first part / second'll be params[]
AW: cmdtext string problem -
Nero_3D - 26.06.2014
well you should do it like that then
pawn Код:
while(cmdtext[++i] > ' ')