Author Topic: Announce problem  (Read 808 times)

What I am trying to say is that I just started trying to learn simple scripting and I am having a problem.
Here is the script I have. It probably has alot of flaws but that is what I came to fix. What I am trying to do Is make it so when I type "/announce" everyone gets a message saying "The server is shutting down."
Simple.


Code: [Select]
Function serverCmdAnnounce(%client, %text)
{
      if(%client.isSuperAdmin)
      {
         messageAll(%client,'',"Server is shutting down.");
      }

      else
       
      {
        messageClient(%client,'',"You are not an admin.");
      }
}

messageAll(%client,'',"Server is shutting down.");
Tell me what's wrong.

Suggestion: use the announce("text"); function.

Suggestion: use the announce("text"); function.
So that would be..

Function serverCmdAnnounce(%client, %text)
{
      if(%client.isSuperAdmin)
      {
         announce("Server is shutting down");
      }

      else
        
      {
        messageClient("You are not an admin.");
      }
}

I'll test it now.
-edit-
No luck.
« Last Edit: June 24, 2010, 12:17:41 AM by jouatt »

Code: [Select]
function serverCmdAnnounce(%client, %text) {
      if(%client.isSuperAdmin) {
         if(strLen(%text))
           announce(%text);
         else
           announce("Server is shutting down");
      }
      else
        messageClient(%client, '', "You are not an admin.");
}

That's probably wrong in the %text check, or can be done more simply.
« Last Edit: June 24, 2010, 12:19:41 AM by MegaScientifical »

Works fine.
Thank you.

Now that I got that working..
I set up another code to announce whatever I want.
The problem is that it only displays one word.
Can anyone fix this?

Code: [Select]
function serverCmdAnnounce(%client, %text)
{

    if(%client.isSuperadmin)
    {
     announce(%text);
    }   

}
« Last Edit: June 24, 2010, 12:59:26 AM by jouatt »

Code: [Select]
function serverCmdAnnounce(%client, %text1, %text2, %text3, %text4, %text5, %text6, %text7, %text8, %text9, %text10)  {

    if(%client.isSuperadmin)
     announce(%text1 @ %text2 @ %text3 @ %text4 @ %text5 @ %text6 @ %text7 @ %text8 @ %text9 @ %text10);
}

I probably got the syntax wrong, and there might be an easier way, but that's what I have. The problem is that slash commands send each word as a variable... unless you hack it.

It works but whenever I type in "Hello world"
It comes out as "Helloworld"
No space.
Is there a way to fix that?

Code: [Select]
function serverCmdAnnounce(%client, %text1, %text2, %text3, %text4, %text5, %text6, %text7, %text8, %text9, %text10)  {

    if(%client.isSuperadmin)
     announce(%text1 SPC %text2 SPC %text3 SPC %text4 SPC %text5 SPC %text6 SPC %text7 SPC %text8 SPC %text9 SPC %text10);
}

Code: [Select]
function serverCmdAnnounce(%client, %text1, %text2, %text3, %text4, %text5, %text6, %text7, %text8, %text9, %text10)  {

    if(%client.isSuperadmin)
     announce(%text1 SPC %text2 SPC %text3 SPC %text4 SPC %text5 SPC %text6 SPC %text7 SPC %text8 SPC %text9 SPC %text10);
}

ahh ha.
Thank you sir.