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

(Req CS:GO) Transfer CT to T team when killed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shebzftw
New Member
Join Date: Apr 2023
Location: Romania
Old 09-01-2023 , 12:35   (Req CS:GO) Transfer CT to T team when killed
Reply With Quote #1

Hi!
I would like to request a plugin that transfers the CT to the T Team and gets respawned after being killed.

Thank you!
shebzftw is offline
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 09-05-2023 , 06:19   Re: (Req CS:GO) Transfer CT to T team when killed
Reply With Quote #2

This should do the job

Code:
#pragma semicolon 1
#pragma newdecls required
#pragma tabsize 0
#include <cstrike>

public Plugin myinfo =
{
	name = "Transfer player onto terrorist team on frag.",
	author = "Teamkiller324, shebzftw(requester)",
	description = "When fragged, tranfers the player onto terrorist team.",
	version = "1.0.0",
	url = "https://forums.alliedmods.net/showthread.php?t=343800"
}

public void OnPluginStart()
{
	HookEvent("player_death", OnPlayerDeath);
}

void OnPlayerDeath(Event event, const char[] event_name, bool dontBroadcast)
{
	int attacker = event.GetInt("attacker"); // the fragger.
	int userid = event.GetInt("userid"); // the fragged player.
	if(attacker < 1
	|| userid < 1
	|| attacker == userid)
	{
		return;
	}
	
	// check if valid frag event.
	int fragger;
	if(!IsValidClient((fragger = GetClientOfUserId(attacker))))
	{
		return;
	}
	
	int client;
	if(IsValidClient((client = GetClientOfUserId(userid))))
	{
		// check if the frag event was a teamkill.
		int team;
		if((team = GetClientTeam(client)) != GetClientTeam(fragger))
		{
			if(team == CS_TEAM_CT)
			{
				CreateTimer(0.151257512585125, Timer_Transfer, userid); // delayed, to ensure avoiding rare client crash related to source spaghetti.
			}
		}
	}
}

Action Timer_Transfer(Handle timer, int userid)
{
	int client;
	if(IsValidClient((client = GetClientOfUserId(userid))))
	{
		ChangeClientTeam(client, CS_TEAM_T);
		CS_RespawnPlayer(client);
	}
	
	return Plugin_Continue;
}

bool IsValidClient(int client)
{
	if(client < 1 || client > MAXPLAYERS)
	{
		return false;
	}
	
	if(!IsClientConnected(client))
	{
		return false;
	}
	
	if(!IsClientInGame(client))
	{
		return false;
	}
	
	if(IsClientSourceTV(client))
	{
		return false;
	}
	
	if(IsClientReplay(client))
	{
		return false;
	}
	
	return true;
}
Attached Files
File Type: sp Get Plugin or Get Source (cs_transfer_onkilled.sp - 60 views - 1.7 KB)
__________________
Teamkiller324 is offline
shebzftw
New Member
Join Date: Apr 2023
Location: Romania
Old 09-05-2023 , 09:14   Re: (Req CS:GO) Transfer CT to T team when killed
Reply With Quote #3

thank you! it's working perfectly.
shebzftw is offline
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 09-05-2023 , 11:27   Re: (Req CS:GO) Transfer CT to T team when killed
Reply With Quote #4

Quote:
Originally Posted by shebzftw View Post
thank you! it's working perfectly.
Glad to hear C:
__________________
Teamkiller324 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 12:48.


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