Raised This Month: $51 Target: $400
 12% 

Set flag for group player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hoycieto
Senior Member
Join Date: Feb 2018
Old 03-14-2018 , 12:13   Set flag for group player
Reply With Quote #1

Hello, I need plugin which will give users which are in my Steam group additional flag (for example P flag). I think it could check on round start if player is in my group and set a flag for him. When user disconnects, plugin have to remove his flag. Maybe someone have something like this?

For now I'm using plugin giving credits for users in my grup:
Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "boomix"
#define PLUGIN_VERSION "1.1"

#include <sourcemod>
#include <SteamWorks>
#include <smlib>
#include <autoexecconfig>

#define LoopAllPlayers(%1) for(int %1=1;%1<=MaxClients;++%1)\
if(IsClientInGame(%1) && !IsFakeClient(%1))

bool b_InGroup[MAXPLAYERS + 1];

Handle GroupID;
Handle MoneyPerKill;

int iGroupID;
int iMoneyPerKill;

public Plugin myinfo = 
{
	name = "Group players",
	author = PLUGIN_AUTHOR,
	description = "Gives more money for players that are in steam group",
	version = PLUGIN_VERSION,
	url = "http://google.lv"
};

public void OnPluginStart()
{
	AutoExecConfig_SetFile("groupplayers");
	
	HookConVarChange(GroupID 		=	AutoExecConfig_CreateConVar("sm_groupid", "xxxxxxxxxxxxxxxxxx", "Group ID 64"), 								OnCvarChanged);
	HookConVarChange(MoneyPerKill 	=	AutoExecConfig_CreateConVar("sm_moneyperkill", "50", "How much more money per kill, if player is in group"), 	OnCvarChanged);
	
	AutoExecConfig_ExecuteFile();
	AutoExecConfig_CleanFile();
	
	HookEvent("player_death", Event_PlayerDeath);
	
	UpdateConvars();
	
}

public void OnCvarChanged(Handle hConvar, const char[] chOldValue, const char[] chNewValue)
{
	UpdateConvars();
}

public void UpdateConvars()
{
	iGroupID 		= GetConVarInt(GroupID);
	iMoneyPerKill	= GetConVarInt(MoneyPerKill);	
}

public Action Event_PlayerDeath(Handle event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(GetEventInt(event, "attacker"));
	
	if(IsClientInGame(client) && b_InGroup[client])
	{
		int money = Client_GetMoney(client);
		Client_SetMoney(client, money + iMoneyPerKill);
	}
		
}

public void OnClientPutInServer(int client)
{
	b_InGroup[client] = false;
	SteamWorks_GetUserGroupStatus(client, iGroupID);
}

public int SteamWorks_OnClientGroupStatus(int authid, int groupid, bool isMember, bool isOfficer)
{
	
	int client = GetUserFromAuthID(authid);
	
	if(isMember)
	{
		b_InGroup[client] = true;
	}
	
}

int GetUserFromAuthID(int authid)
{
	
	LoopAllPlayers(i)
	{
		char authstring[50];
		GetClientAuthId(i, AuthId_Steam3, authstring, sizeof(authstring));	
		
		char authstring2[50];
		IntToString(authid, authstring2, sizeof(authstring2));
		
		if(StrContains(authstring, authstring2) != -1)
		{
			return i;
		}
	}
	
	return -1;

}
I think it will be good base for this I've tried but I can't do this :/
Thanks in advance
hoycieto is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 03-14-2018 , 13:44   Re: Set flag for group player
Reply With Quote #2

Maybe take a look here:

https://forums.alliedmods.net/showthread.php?p=1352434
__________________
coding & free software
shanapu is offline
Noodl
Member
Join Date: Jun 2015
Old 03-17-2018 , 17:20   Re: Set flag for group player
Reply With Quote #3

HTML Code:
public int SteamWorks_OnClientGroupStatus(int authid, int groupid, bool isMember, bool isOfficer)
{
	
	int client = GetUserFromAuthID(authid);
	
	if(isMember)
	{
		b_InGroup[client] = true;
                AddUserFlags(client, Admin_Flag);
	}
	
}
Change adminflag to whatever flag you want from here: https://sm.alliedmods.net/new-api/admin/AdminFlag

Last edited by Noodl; 03-17-2018 at 17:20.
Noodl is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:27.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode