cmdtext string problem
#1

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?
Reply
#2

then you should do something like
pawn Код:
while (cmdtext[i++] != '\0')
Reply
#3

Yeah, but I need only first part / second'll be params[]
Reply
#4

well you should do it like that then
pawn Код:
while(cmdtext[++i] > ' ')
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)