Bloko Forums
Welcome to the Bloko Forums! Please register to enjoy all of our features!


A forum to discuss blockland, hang out with friends, and a whole lot more!
 
HomeHome  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log in  

Share | 
 

 [GUIDE] Chat Commands

View previous topic View next topic Go down 

do you find this tutorial...
Super helpful
0%
 0% [ 0 ]
Helpfull
0%
 0% [ 0 ]
Good
0%
 0% [ 0 ]
So so
0%
 0% [ 0 ]
Bad
0%
 0% [ 0 ]
Fail
0%
 0% [ 0 ]
Epic fail
0%
 0% [ 0 ]
Total Votes : 0
 

AuthorMessage
Ladias
Member


Blockland ID : 268
Posts : 37
Join date : 2010-05-08
Age : 34
Location : Berlin, Germany

PostSubject: [GUIDE] Chat Commands   Tue May 11, 2010 12:00 pm

• /fetch: a command that teleports a player to yourself when used. • /find: a command that teleports yourself to another player. • /suicide: a command that kills yourself. • /wand: a command that equips the wand. All of these commands are simply a function with the prefix "serverCmd", so "/wand" would be "serverCmdWand". If you include additional parameters with the slash command (such as /fetch Destiny) the "serverCmd" function will be parsed with the extended parameters. A Quick Example of Chat Commands In this example we'll go through the simple steps of making a kill command that only administrators of the server may use. First we get down to the pure core of the command, the 'function'. function serverCmdKill(%client)
{
echo("serverCmdKill triggered by " @ %client.name @ "!");
}
Set this up in a script file and check in the console for the string sent by the echo function. All it will show is the string sent with the argument in the echo function with " @ %client.name @ " replaced with the person who used the chat command's name. Now thats cool and all, but let's step it up. function serverCmdKill(%client)
{
if(%client.isAdmin == true)
{
echo("serverCmdKill triggered by "@%client.name@"!");
}
}
Now we've got the function checking if the client is an admin before echoing the string to the console. The %client.isAdmin variable is a boolean (a true or false statement) set to true or 1 when the client is an admin (or super admin) and false or 0 when the client is not an admin. The if conditional simply checks that the client's isAdmin variable is set to true before continuing. Now we want to make the command find the client we are trying to kill. We add a additional check to see if the target with a name's player object actually exists. function serverCmdKill(%client,%target)
{
if(%client.isAdmin == true && isObject(findclientbyname(%target)))
{
echo("serverCmdKill triggered by "@%client.name@" and was targetting "@findclientbyname(%target).name@"!");
}
}
And now the command will not only check if the client is admin, but then check if the part of the target's name they entered is an existing client in the server. As you can see, we find the client with a name using the findclientbyname command. This is a command included with Blockland and is one of the most useful. There also exists a findclientbybl_id function but we can use that another time! Let's get to the part this whole command is about. Killing the target's player object. function serverCmdKill(%client,%target)
{
if(%client.isAdmin == true && isObject(findclientbyname(%target)))
{
echo("serverCmdKill triggered by "@%client.name@" and was targetting "@findclientbyname(%target).name@"!");
if(isObject(findclientbyname(%target).player))
{
messageAll('',findclientbyname(%target).name@" was killed by "@%client.name@"!");
findclientbyname(%target).player.kill();
}
}
}
Now the chat command will finally work. It checks if the client is admin, if the target actually exists. Then we actually check if the target's player exists, then kills it if it does. We also message every single user on the server saying that the client killed the player, so they don't get confused as to why their comrades are falling down in battle without any wounds. Congragulations, you've made a simple but cool new chat command! Go on and investigate creating new and brilliant chat commands.
Back to top Go down
View user profile
 
[GUIDE] Chat Commands
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Chatbox Guide to Commands and Rules
» Stormies Shitty Basic Guide To using Events in Pac 3
» guthans guide
» ___A Guide to Ranging Mithril Dragons___
» Round 6 - Laguna Seca - Pre Race Chat

Permissions in this forum:You cannot reply to topics in this forum
Bloko Forums :: Blockland :: Support-
Jump to: