PDA

View Full Version : Seperate


TheLazySloth
20/06/2012, 05:53 AM
stock Seperate(Source[], Destination[][], Seperater) {
new DestinationNum = 0,
DestinationPos = 0;

for(new SourcePos = 0; Source[SourcePos]; SourcePos++) {
if(Source[SourcePos] != Seperater) {
Destination[DestinationNum][DestinationPos] = Source[SourcePos];
DestinationPos++;
} else {
if(strlen(Destination[DestinationNum]) > 0) {
DestinationNum++;
DestinationPos = 0;
}
}
}
return true;
}

This code runs fine, I made and tested it myself.
But there's a feature I want added to it.

public OnGameModeInit() {
new Result[5][100];

Seperate("23 Hello World! 54.5 How ya doing?", Result, ' ');

printf("%s %s %s", Result[1], Result[2], Result[4]);
return true;
}

Right now that code will display,
Hello World! How
in the server.log.

I want it to display,
Hello World! How ya doing?
instead.

I want it so if the person new Result[2][100]; it will ignore the Seperater after it is done creating Result[1].
I want it so if the person new Result[5][100]; it will ignore the Seperater after it is done creating Result[4].

TheLazySloth
02/07/2012, 06:47 AM
Would still love help.