Confirmedusers
13,514
edits
Mirotworez (talk | contribs) m (add tvar tag) |
Mirotworez (talk | contribs) (Undo revision 55424 by Mirotworez (talk)) Tag: Undo |
||
Line 16: | Line 16: | ||
<!--T:6--> | <!--T:6--> | ||
First of all you need to add another mod to your workspace. I will use the modid <tvar| | First of all you need to add another mod to your workspace. I will use the modid <tvar|name><code>here</code></>, so I will type in <code>add here</code> in modtools to create a new mod. Additionally I will create <code>Command.cs</code> in the <code>src</code> directory. | ||
<!--T:7--> | <!--T:7--> | ||
As always we need to create a class extending | As always we need to create a class extending <code>ModSystem</code>: | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
public class CommandMod : ModSystem | public class CommandMod : ModSystem | ||
Line 28: | Line 27: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<!--T:9--> | <!--T:9--> | ||
Commands are processed by the server, so our mod only needs to load on the server's side: | Commands are processed by the server, so our mod only needs to load on the server's side: | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
public override bool ShouldLoad(EnumAppSide side) | public override bool ShouldLoad(EnumAppSide side) | ||
Line 39: | Line 36: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<!--T:10--> | <!--T:10--> | ||
Now we need to register the command itself: | Now we need to register the command itself: | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
public override void StartServerSide(ICoreServerAPI api) | public override void StartServerSide(ICoreServerAPI api) | ||
Line 56: | Line 51: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<!--T:12--> | <!--T:12--> | ||
This command can be used by any player who is allowed to send a message (by default everyone). When a player types in | This command can be used by any player who is allowed to send a message (by default everyone). When a player types in <code>/here</code>, the command will be executed. Now we the only thing missing is the actual code to spawn particles and to play the sound. | ||
<!--T:13--> | <!--T:13--> | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
public override void StartServerSide(ICoreServerAPI api) | public override void StartServerSide(ICoreServerAPI api) | ||
Line 89: | Line 82: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<!--T:15--> | <!--T:15--> |