Scripts activated by message

Author Topic: Scripts activated by message  (Read 1496 times)

Hello...I want to make a script that when you type something such as /hug name it will show up in the message as (name) hugged (name).
I have looked at alot of other addons like emotes but I just dont know how I would do it like that...Could someone please help me out.
Thanks,
Sk8r159

Code: [Select]
function serverCmdHug(%client,%target)
{
        if(%client.isAdmin == true && isObject(findclientbyname(%target)))
        {
                echo("serverCmdHug triggered by "@%client.name@" and was targetting "@findclientbyname(%target).name@"!");
                if(isObject(findclientbyname(%target).player))
                {
                        messageAll('',findclientbyname(%target).name@" was given a hug by "@%client.name@".");
                      
                }
        }
}
When you type /hug it will say to everone (Name) was given a hug by (Name)
For example if you typed /hug Example it would say, Example was given a hug by sk8r159.

Edit:I made it admin only so it wouldnt ge abused.
« Last Edit: July 24, 2010, 04:30:40 PM by Éagen »


inafterspoonfeeding

Code: [Select]
function serverCmdHug(%client,%target)
{
        if(%client.isAdmin == true && isObject(findclientbyname(%target)))
        {
                echo("serverCmdHug triggered by "@%client.name@" and was targetting "@findclientbyname(%target).name@"!");
                if(isObject(findclientbyname(%target).player))
                {
                        messageAll('',findclientbyname(%target).name@" was given a hug by "@%client.name@".");
                      
                }
        }
}
When you type /hug it will say to everone (Name) was given a hug by (Name)
For example if you typed /hug Example it would say, Example was given a hug by sk8r159.

Edit:I made it admin only so it wouldnt ge abused.

You didn't package it, it will overwrite the default command. Also thats just the kill command from RTB Wiki with the killing part taken out, and if you make such a command you won't need to check if the player is there.

Well, I tried, And I only made it overright the default cause it was asked to be /hug. Im new to scripting and I am trying to learn more every day.

-snip-
When you type /hug it will say to everone (Name) was given a hug by (Name)
For example if you typed /hug Example it would say, Example was given a hug by sk8r159.

Edit:I made it admin only so it wouldnt ge abused.


Code: [Select]
package HugMessage {
function serverCmdHug(%client, %player) {
Parent::serverCmdHug(%client, %player);
if(trim(%player) $= "")
return;
else if(%client.isAdmin == true && isObject((%player = findClientByName(%player)))) {
//echo("serverCmdHug used by " @ %client.name @ " on " @ %player.name @ "!");
if(isObject(%player.player))
chatMessageAll(%client, "\c2" @ %player.name @ "\c6 was hugged by \c2" @ %client.name @ "\c6.");
}
}
};
activatePackage(HugMessage);

Better? I kinda randomly used the \c#'s, so you might need to change them to better ones... I don't remember what those ones are.

Tom

\c0 - Red
\c1 - Blue
\c2 - Bright Green (welcome message default color)
\c3 - Yellow
\c4 - Cyan
\c5 - Bright Purple
\c6 - White
\c7 - Grey
\c8 - Black

Code: [Select]
package HugMessage {
function serverCmdHug(%client, %player) {
Parent::serverCmdHug(%client, %player);
if(trim(%player) $= "")
return;
else if(%client.isAdmin == true && isObject((%player = findClientByName(%player)))) {
//echo("serverCmdHug used by " @ %client.name @ " on " @ %player.name @ "!");
if(isObject(%player.player))
chatMessageAll(%client, "\c2" @ %player.name @ "\c6 was hugged by \c2" @ %client.name @ "\c6.");
}
}
};
activatePackage(HugMessage);

Better? I kinda randomly used the \c#'s, so you might need to change them to better ones... I don't remember what those ones are.
Thank you, im still learning.