91
Modification Help / Re: Basic ServerCmd and Messages
« on: March 27, 2016, 07:49:12 PM »Here's an example of multiple words:Thanks for the example; I was able to improve my code to something like this:
Code: server.cs (10 lines) function serverCmdHi(%client, %msg0, %msg1, %msg2, %msg3, %msg4, %msg5, %msg6)
{
for(%i = 0; %i <= 6; %i++) //There are 7 msg arguments, start from 0, go to 6.
if(%msg[%i] !$= "") //If the current number has something in it, add it to the message variable
%msg = %msg SPC %msg[%i]; //Each argument gets a space in between
%client.chatMessage("\c6Hello. I have a message for you: \c3" @ %msg); //%client.chatMessage(string message);
//\c0 to \c8 have different colors, you can do a /colorTest on your server for each of their colors.
//Ex: <color:ffff00> is the same as \c3 (Yellow)
}
Code: [Select]
//Command "/messageall {message}"
function servercmdMessageAll(%client, %msg1, %msg2, %msg3, %msg4, %msg5, %msg6, %msg7, %msg8)
{
if (!%client.issuperadmin) return;
for (%i = 0; %i < 8; %i++)
if (%msg[%i] !$= "")
%msg = %msg SPC %msg[%i];
messageAll('', "[Announcement] \c6" @ %msg);
}
//Command "/messageuser {name} {message}"
function servercmdMessageUser(%client, %name, %msg1, %msg2, %msg3, %msg4, %msg5, %msg6, %msg7, %msg8)
{
%target = findClientByName(%name);
if(!isObject(%target))
messageClient(%client, '', "\c0Could not send message to user [\c3" @ %name @ "\c0]"); //1
return;
for (%i = 0; %i < 8; %i++)
if (%msg[%i] !$= "")
%msg = %msg SPC %msg[%i];
messageClient(%target, '', "\c0Message from [\c3" @ %client.name @ "\c0] \c6" @ %msg); //2
}
An error I seem to be having now is that if I have the line of code marked //1, then the code marked //2 stops functioning.