Author Topic: Code help  (Read 2215 times)

« Last Edit: March 20, 2009, 11:48:18 AM by AGlass0fMilk »

« Last Edit: March 19, 2009, 04:24:46 PM by AGlass0fMilk »

It looks like you are trying to use if statements as functions...

I just thought about it, and don't mess with muting people, you will get servercmdmessagesent privileges revoked just like the other ones.

Oops, I forgot to put in brackets under my if statements... One sec let me fix that and test it.

Can you have more than one servercmd in one script? When I run it, it does this:
=D
« Last Edit: March 20, 2009, 11:48:46 AM by AGlass0fMilk »

You can have several servercmds in one script. However, your servercmdUnmute seems like it will do nothing except tell non-admins that they need to be an admin.

Oh also, ambiguous topic. This is the coding help section. We know you are looking for coding help here.

Im sorry, I didn't know what to put as the title so I put that. Anyway, It does more than that, here i'll edit the code. What would I put at the end of the function unmute thing so that the brackets wouldn't syntax?

Lol super devil
« Last Edit: March 19, 2009, 04:57:41 PM by AGlass0fMilk »

Quote
function unmute(%victim)
{
   $Mute[%victim.player] = false; -You should just assign the mute variable to %victim, instead of some global variable that keeps the ID of the player object, otherwise players could avoid it with Self Delete.
   MessageClient(%victim, '', '\c6You are now unmuted'); -I think you need quotation marks in the last arguement, the " ones.
}##
##
function servercmdUnmute(%client, %user)
{
   if(!%client.isSuperAdmin)
                    -Need a open bracket here.
   messageClient(%client, '', '\c6You must be a super admin to use that command');

   return;
}
   if(%user !$= "")
{
   $Mute[%victim.player] = false; -You're pulling %victim out of nowhere. Also, you should use a Name to Client ID function before here
   messageClient(%victim, '', '\c6You have been unmuted by \c3%1', %Client.name);
   messageAll("\c3%1 \c6has been unmuted by \c3%2", %victim.name, %Client.name); -Maybe change this to a messageallexcept to avoid sending aq second line to the victim.
}
                    -Need a close bracket here.

The global variable keeps it so that if they leave, it doesn't un mute them when they come back, but then again, I assigned it to their player object. Could I just assign it to the victim?
« Last Edit: March 19, 2009, 05:40:18 PM by AGlass0fMilk »

And I'm asking why it syntaxes up here:
=D
« Last Edit: March 20, 2009, 11:49:20 AM by AGlass0fMilk »

And by the way, could I just assign the Global variable to their name? Would that make is so that if they leave and come back, that it doesnt unmute them? I mean if they changed their name, it probably would unmute them.Would it work in general?

Major points.

Most time-valued functions are measured in milliseconds(10 second release of mute seems unintended to me).

When you do an IF without a body, only one statement will be part of the IF.

Don't use %1 and %2, they won't work. Use %x.name

Code: (Torque) [Select]
function servercmdMute(%client, %user)
{
    if(!%client.isSuperAdmin)
    {
messageClient(%client, '', '\c6You must be a Super Admin to use this command');
return;
    }

    if(%user !$= "")
    {
%victim = FindClientByName(%user);
$Mute[%victim.player] = true;
messageAll('', "\c3"@ %victim.name @" \c6has been muted by \c3"@ %user.name, 5);
messageClient(%victim, '', "\c6You have been muted by \c3"@ %client.name);
//schedule(10000, 0, "unmute", %victim);
    }
}


function unmute(%victim)
{
    $Mute[%victim.player] = false;
    messageClient(%victim, '', "\c6You are now unmuted");
}


function servercmdUnmute(%client, %user)
{
    if(!%client.isSuperAdmin)
    {
messageClient(%client, '', '\c6You must be a super admin to use that command');
return;
    }

    if(%user !$= "")
    {
$Mute[%victim.player] = false;
messageClient(%victim, '', "\c6You have been unmuted by \c3"@ %client.name);
messageAll('', "\c3"@ %user.name @" \c6has been unmuted by \c3"@ %client.name);
    }
}

package mutePackage
{
    function servercmdMessageSent(%client, %text)
    {
if($mute::mute[%victim.player])
{
   messageClient(%client, '', '\c6You cannot talk while muted.');
   return;
}


else
   Parent::ServercmdmessageSent(%client, %text);
    }
};

ActivatePackage(mutePackage);
« Last Edit: March 19, 2009, 08:06:33 PM by Kalphiter »

I was planning on making it so it was:
Code: [Select]
Function ServercmdMute(%Client, %user, %time)
and that the length of the mute would be this:
Code: [Select]
length = (%time * 1000)
So you could insert how long and in seconds.

Great job at naming the topic almost the exact same as the forum it's in.
Oh and your code is terrible.

Im sorry, I didn't know what to put as the title so I put that.
Conversation over
« Last Edit: March 19, 2009, 05:57:45 PM by AGlass0fMilk »