| Blockland Forums > Modification Help |
| string problem |
| (1/1) |
| Herrerarausaure:
Hello, I just started to script, and to start, I tried to make a small, useless script: In the chat, type /I *put in message*. What should happen is that all players on the server will receive a chat message saying your name followed by your message, for example: /I is making a strawberry cake. = Herrerarausaure is making a strawberry cake. Teal = Chat command Blue = Chat message (to all players) I know that script was already done, (Bot's ui script), but I promise never publishing it. Now my problem is, with this code: --- Code: ---function servercmdI(%client, %message) } messageAll('', "<color:FFFF00>"@ %client.getPlayerName() @ " "@ %message); } --- End code --- Everything worked properly, except that only the first word after "/I" was displayed, the other words were ignored. I know that my code is probably a bit weird with some beginner's errors, but I started from almost nothing (only basics from C coding) My question is: How do you add more words? |
| Amade:
Add more arguments to the function. |
| ThinkInvisible:
--- Quote from: Amade on August 09, 2010, 04:26:13 AM ---Add more arguments to the function. --- End quote --- There is another possibility : --- Quote from: herb on August 04, 2010, 07:41:04 PM ---%name=%brick.getName(); %name=strReplace(%name,"_",""); this will change all _ in the string, into nothing and will return John. u can change it into different things, for ex: %name=strReplace(%name,"_","*"); that will return *John --- End quote --- Only different : %name=%message; //Just %message. %name=strReplace(%name,"_"," "); //Notice there's a space there instead of nothing. This will make it so you type it in with underlines like so: /I is_testing_this_command. The code above will replace those underlines with spaces when the code actually executes(if you put it in the right place), and return the chat as: "ThinkInvisible is testing this command." Basic explanation ninja edit! Blockland / commands don't like extra spaces for one variable. So, you have to change a filler character to spaces later on in the code. |
| Herrerarausaure:
ooooh, yeah. ok. Thanks for helping! |
| Navigation |
| Message Index |