View Single Post
Author Message
Unreal1
AlliedModders Donor
Join Date: Dec 2010
Old 11-22-2011 , 08:17   How would I set the group that the extention checks if player is a memeber of
Reply With Quote #1

I have this code for example. I basically want to make a plugin that checks the group status of a client and then prints a welcome message depending on their group status.

As you can tell I have no idea what I'm doing and I would really appreciate any help.

Code:
 
#pragma semicolon 1
#include <sourcemod>
#define AUTOLOAD_EXTENSIONS
#define REQUIRE_EXTENSIONS
#include <steamtools>
#define PLUGIN_VERSION "1.0"
public Plugin:myinfo = {
 name        = "SteamTools Tester",
 author      = "",
 description = "A plugin to tell people to join your group",
 version     = PLUGIN_VERSION,
 url         = ""
};
new ReplySource:Async_GroupStatus_Reply;
new Async_GroupStatus_Client;
public OnPluginStart()
{
 LoadTranslations("common.phrases");
 RegAdminCmd("sm_groupstatus", Command_GroupStatus, ADMFLAG_SLAY, "Requests a client's membership status in a Steam Community Group.");
}

public Action:Command_GroupStatus(client, args)
{
 if (args != 2)
 {
  ReplyToCommand(client, "[SM] Usage: sm_groupstatus <client> <group>");
  return Plugin_Handled;
 }
 new String:arg1[32];
 new String:arg2[32];
 GetCmdArg(1, arg1, sizeof(arg1));
 GetCmdArg(2, arg2, sizeof(arg2));
 
 new String:target_name[MAX_TARGET_LENGTH];
 new target_list[MAXPLAYERS], target_count;
 new bool:tn_is_ml;
 
 if ((target_count = ProcessTargetString(
   arg1,
   client,
   target_list,
   MAXPLAYERS,
   COMMAND_FILTER_NO_IMMUNITY,
   target_name,
   sizeof(target_name),
   tn_is_ml)) <= 0)
 {
  ReplyToTargetError(client, target_count);
  return Plugin_Handled;
 }
 new bool:didLastRequestWork = false;
 
 for (new i = 0; i < target_count; i++)
 {
  didLastRequestWork = Steam_RequestGroupStatus(target_list[i], StringToInt(arg2));
 }
 ReplyToCommand(client, "[SM] %s.", didLastRequestWork?"Group status requested":"Error in requesting group status, not connected to Steam");
 Async_GroupStatus_Client = client;
 Async_GroupStatus_Reply = GetCmdReplySource();
 return Plugin_Handled;
}
public Steam_GroupStatusResult(client, groupAccountID, bool:groupMember, bool:groupOfficer)
{
 SetCmdReplySource(Async_GroupStatus_Reply);
 ReplyToCommand(Async_GroupStatus_Client, "[SM] %N is %s in group %d.", client, groupMember?(groupOfficer?"an officer":"a member"):"not a member", groupAccountID);
 Async_GroupStatus_Reply = SM_REPLY_TO_CONSOLE;
 Async_GroupStatus_Client = 0;
 return;
}
ChatMessagesDisplay(client)
{
if (IsClientConnected(client) && IsClientInGame(client))
 {
  if (groupMember = false)
  CPrintToChat (client, "%T", "Please Join our steam group!", LANG_SERVER, client);
  
  if (groupOfficer = true)
  CPrintToChat (client, "%T", "Welcome back group officer!", LANG_SERVER, client);
 }
}
Unreal1 is offline