PHP-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
public OnPluginStart()
{
// Register Console Commands
RegConsoleCmd("say", Command_Say);
RegConsoleCmd("say2", Command_Say);
RegConsoleCmd("say_team", Command_Say);
}
public Action:Command_Say(client, args)
{
// Declaring variables
decl String:text[192], String:command[64];
new startidx = 0;
// Check saycommand is valid
if (GetCmdArgString(text, sizeof(text)) < 1)
{
return Plugin_Continue;
}
if (text[strlen(text)-1] == '"')
{
text[strlen(text)-1] = '\0';
startidx = 1;
}
// Check saycommand type
GetCmdArg(0, command, sizeof(command));
if (strcmp(command, "say2", false) == 0)
{
startidx += 4;
}
// Command vergleichen
if (strcmp(text[startidx], "test1", false) == 0)
{
// Action when command = test1
}
// Command vergleichen
if (strcmp(text[startidx], "test2", false) == 0)
{
// Action when command = test2
}
// u.s.w.....
return Plugin_Continue;
}
|
PHP-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
// 2D Array
new String:MyCommands[][] = {"command1", "command2"};
// Cache
new MComSize = sizeof(MyCommands);
public OnPluginStart()
{
// Man koennte hier auch say_team hooken, halte ich allerdings nichts von
AddCommandListener(Listener, "say");
}
public Action:Listener(client, const String:command[], argc)
{
// Arg definieren
new String:Arg[64];
// Das erste Argument speichern
GetCmdArgString(Arg, sizeof(Arg));
// Anfuehrungstriche entfernen "text"
StripQuotes(Arg);
// Fuer jeden Command
for(new i; i < MComSize; i++)
{
// Wenn der Command == command1, oder command2
if(StrEqual(Arg, MyCommands[i], true))
{
PrintToChat(client, "Yay, du hast %s eingegeben", Arg);
}
}
return Plugin_Continue;
}
|
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Impact« (15. Februar 2012, 13:01)