shanapu
03-24-2016, 23:28
hi,
i'm not familar with sourcepawn, i couldnd write a plugin from scratch. but i know how to read & edit sourcecodes. i read many sources recently and found 3 different ways to trigger/read a chat command.
What are the pros and contras of these ways to handle a chat command?
thanks in advance
shanapu
public OnPluginStart()
{
RegConsoleCmd("sm_test1", TestOn);
}
public Action:TestOn(client, args)
{
PrintToChatAll("Hello world")
}
public OnPluginStart()
{
HookEvent("player_say", PlayerSay);
}
public PlayerSay(Handle:event, String:name[], bool:dontBroadcast)
{
decl String:text[256];
GetEventString(event, "text", text, sizeof(text));
if (StrEqual(text, "!test2"))
{
PrintToChatAll("Hello world")
}
}
public OnPluginStart()
{
AddCommandListener(Event_Say, "say");
AddCommandListener(Event_Say, "say_team");
}
public Action:Event_Say(clientIndex, const String:command[], arg)
{
static String:menuTriggers[][] = { "!test3" };
decl String:text[24];
GetCmdArgString(text, sizeof(text));
StripQuotes(text);
TrimString(text);
for(new i = 0; i < sizeof(menuTriggers); i++)
{
if (StrEqual(text, menuTriggers[i], false))
{
PrintToChatAll("Hello world")
}
}
}
i'm not familar with sourcepawn, i couldnd write a plugin from scratch. but i know how to read & edit sourcecodes. i read many sources recently and found 3 different ways to trigger/read a chat command.
What are the pros and contras of these ways to handle a chat command?
thanks in advance
shanapu
public OnPluginStart()
{
RegConsoleCmd("sm_test1", TestOn);
}
public Action:TestOn(client, args)
{
PrintToChatAll("Hello world")
}
public OnPluginStart()
{
HookEvent("player_say", PlayerSay);
}
public PlayerSay(Handle:event, String:name[], bool:dontBroadcast)
{
decl String:text[256];
GetEventString(event, "text", text, sizeof(text));
if (StrEqual(text, "!test2"))
{
PrintToChatAll("Hello world")
}
}
public OnPluginStart()
{
AddCommandListener(Event_Say, "say");
AddCommandListener(Event_Say, "say_team");
}
public Action:Event_Say(clientIndex, const String:command[], arg)
{
static String:menuTriggers[][] = { "!test3" };
decl String:text[24];
GetCmdArgString(text, sizeof(text));
StripQuotes(text);
TrimString(text);
for(new i = 0; i < sizeof(menuTriggers); i++)
{
if (StrEqual(text, menuTriggers[i], false))
{
PrintToChatAll("Hello world")
}
}
}