15.09.2012, 12:47
Hi, I want to read the cmdtxt but separate by words, for example:
/call 34 Angala Unity I want to see you in Unity. Bye.
When the player send this I want to send a message (I want to see you in Unity. Bye.) with title (Unity) the sender name(Angala) to the playerid (34)
To do that I need to separate all the cmdtext, I have done a code to put the cmdtext in varibles like:
cmd1 = "/call"
cmd2 = "34"
cmd3 = "Angala"
cmd4 = "Car"
cmd5 = "I want to see you in Unity. Bye."
This is the code:
After the code I have put a control code with messages:
The problem is, if I enter the comand "/call 34 Angala Unity I want to see you in Unity. Bye." I only see the cmd1 that is "/call" the rest of variables are empty
What is the error? or if you know how to do the thing I want to do, please help me
/call 34 Angala Unity I want to see you in Unity. Bye.
When the player send this I want to send a message (I want to see you in Unity. Bye.) with title (Unity) the sender name(Angala) to the playerid (34)
To do that I need to separate all the cmdtext, I have done a code to put the cmdtext in varibles like:
cmd1 = "/call"
cmd2 = "34"
cmd3 = "Angala"
cmd4 = "Car"
cmd5 = "I want to see you in Unity. Bye."
This is the code:
Код:
new ind = 0, tempind = 0, cmdN = 1, cmd1[50], cmd2[50], cmd3[50], cmd4[50], cmd5[200]; EmpWhile: while(cmdtext[ind] != ' ') //This is to put on ind the number of chars before a space. { if(ind + 1 >= strlen(cmdtext)) //If ind is more than the length the while exit. { goto FinWhile; } ind = ind + 1; } while(tempind != ind) //here tempind is the first char, ind is the las char. { //cmdN is a variable that have the word that is reading 1, 2, 3, 4, or 5. if(cmdN == 1) {cmd1[tempind] = cmdtext[tempind];} if(cmdN == 2) {cmd2[tempind] = cmdtext[tempind];} if(cmdN == 3) {cmd3[tempind] = cmdtext[tempind];} if(cmdN == 4) {cmd4[tempind] = cmdtext[tempind];} //if cmdN is 5, ind value is the maximun value of cmdtext, because cmd5 is the rest of cmdtext. if(cmdN == 5) {cmd5[tempind] = cmdtext[tempind]; ind = strlen(cmdtext);} tempind = tempind + 1; } cmdN = cmdN + 1; ind = ind + 1; goto EmpWhile; FinWhile: //this is because if the cmdtext is only one word it came here without put somthing on cmd1 while(tempind != ind) { if(cmdN == 1) {cmd1[tempind] = cmdtext[tempind];} tempind = tempind + 1; }
Код:
SendClientMessage(playerid, COLOR_VERDE, cmd1); SendClientMessage(playerid, COLOR_VERDE, cmd2); SendClientMessage(playerid, COLOR_VERDE, cmd3); SendClientMessage(playerid, COLOR_VERDE, cmd4); SendClientMessage(playerid, COLOR_VERDE, cmd5);
What is the error? or if you know how to do the thing I want to do, please help me