Bloko Forums
Welcome to the Bloko Forums! Please register to enjoy all of our features!
Bloko Forums
Welcome to the Bloko Forums! Please register to enjoy all of our features!
Bloko Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.


A forum to discuss blockland, hang out with friends, and a whole lot more!
 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log in  

 

 [GUIDE] Chat Commands

Go down 

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

AuthorMessage
Ladias
Member
Ladias


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

[GUIDE] Chat Commands Empty
PostSubject: [GUIDE] Chat Commands   [GUIDE] Chat Commands EmptyTue 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
 
[GUIDE] Chat Commands
Back to top 
Page 1 of 1
 Similar topics
-
» [GUIDE] Chat Commands
» Console commands!
» [GUIDE] making maps (terrain only)
» The Ghostown that is the Blocko Fourms: guide to passersby.

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