A new feature in the upcoming release r173 is that you can register commands, so you don't have to parse the chat messages yourself anymore.
This feature was requested twice:
http://www.mc-server.org/support/index.p...task_id=71
http://www.mc-server.org/support/index.p...task_id=24
So you created a function that needs to be called when you type /god, this is the function:
It's really easy to bind this function to a command, you bind a command on a plugin. Like so:
The function HandleGodCommand is called each time a player types /god
UPDATE:
In r174 you can also specify the permissions of a command, so you don't have to manually check it.
Both methods work.
This feature was requested twice:
http://www.mc-server.org/support/index.p...task_id=71
http://www.mc-server.org/support/index.p...task_id=24
So you created a function that needs to be called when you type /god, this is the function:
Code:
function HandleGodCommand( Split, Player )
if( not Player:HasPermission( "myplugin.god" ) ) then -- Check permissions first
return false
end
MakePlayerGod( Player ) -- Do something to make the player invincible
return true
end
It's really easy to bind this function to a command, you bind a command on a plugin. Like so:
Code:
function MyPlugin:Initialize()
self:AddCommand("/god", " - Makes you invincible", "myplugin.god") -- This only adds the command to the commandlist for /help
self:BindCommand("/god", HandleGodCommand) -- This actually binds the /god command to the HandleGodCommand function
return true -- Make sure you return true, otherwise the plugin is not added
end
The function HandleGodCommand is called each time a player types /god
UPDATE:
In r174 you can also specify the permissions of a command, so you don't have to manually check it.
Code:
self:BindCommand("/god", HandleGodCommand) -- This still works, but you have to manually check permissions
self:BindCommand( "/home", "myplugin.god", HandleGodCommand) -- New version where permissions are checked for you