Author Topic: Scripting Help  (Read 767 times)

Ok im new to scripting, and im making this cheesy little script and what it is supposed to do is when you say /Hello the server sees -NAME- says Hello!

Heres what i have so far:

--------------------------------------------------------------------------------------------------------------------------
function serverCmdHello(%client, %player)
{
   if(findLocalClient() == %client || %client.bl_id == getNumKeyID() || !%client)
   {
      %client.isHost = true;
   }

   if(!%client.ishost)
   {
      messageAll('', "\c2" @ %client.name SPC "\c6Just \c0SAID \c6HELLO!!!!");
   }
}
--------------------------------------------------------------------------------------------------------------------------------------------------
-is this right or do i need to add something?

The !%client in the first if statement makes it so the %client.isHost = true; is never called. I would remove that.

-is this right or do i need to add something?
Why not try it and see if it works?

The !%client in the first if statement makes it so the %client.isHost = true; is never called. I would remove that.
It doesn't, it will still get set if the client is the host, covered by the other 2 checks.
However it does nothing as %client will always exist, and the 2 other checks are basically duplicates.

Then, why are you conditionaly setting a variable and then checking for it later? Just do it directly:


function serverCmdHello(%client)
{
    if(%client.bl_id == getNumKeyID())
    {
        messageAll('', "\c2" @ %client.name @ " \c6Just \c0SAID \c6HELLO!!!!");
    }
}


Also, for future reference, you should post topics like this in Coding Help.
« Last Edit: August 09, 2014, 03:19:25 PM by Zeblote »