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

[REQ] USP Ninja Team swap (CS GO)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 05-07-2018 , 10:58   [REQ] USP Ninja Team swap (CS GO)
Reply With Quote #1

Hello!

Is there anyone that can either point me in the right direction or maybe help me out?

I'm looking for a plugin that does the following:

When CT's win, swap teams completely (everyone in CT gets swapped to T, and everyone that's in T gets swapped to CT)

When T's win, do nothing and leave teams as is.

I've tried to search and was unable to find anything that does this
__________________
Ayyylmao
malec321 is offline
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 05-07-2018 , 22:52   Re: [REQ] USP Ninja Team swap (CS GO)
Reply With Quote #2

I found a plugin that does this, but it has much more in it that I don't need...

https://forums.alliedmods.net/showthread.php?t=251829

Can anyone help me extract the part where it does what I need?

If CTs win, teams switch

If Ts win, teams stay the same
__________________
Ayyylmao
malec321 is offline
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 05-07-2018 , 23:54   Re: [REQ] USP Ninja Team swap (CS GO)
Reply With Quote #3

Update: I found this USP_NINJAS code by Splewis

It loads but it doesn't work properly..

When T team wins, it leaves the team as it should

But when CT wins it throws the guy on T to the CT team, but only chooses 1 random CT to go T.

We tried with 5 people so it was making it a 1v4 everytime

Quote:
#pragma semicolon 1
#include <cstrike>
#include <sdktools>
#include <sourcemod>
#define PLUGIN_VERSION "1.0.0"

new bool:g_ShouldBeT[MAXPLAYERS+1] = false;

public Plugin:myinfo = {
name = "CS:GO USP Ninjas",
author = "splewis",
description = "",
version = PLUGIN_VERSION,
url = "https://github.com/splewis/"
};

public OnPluginStart() {
AddNormalSoundHook(OnSoundPlayed);
HookEvent("round_end", Event_RoundEnd);
HookEvent("round_prestart", Event_RoundPreStart);
AddCommandListener(Command_TeamJoin, "jointeam");
}

public OnClientConnected(client) {
g_ShouldBeT[client] = false;
}

public Action:Command_TeamJoin(client, const String:command[], argc) {
if (!IsClientConnected(client) || IsFakeClient(client) || argc < 1)
return Plugin_Handled;

decl String:arg[4];
GetCmdArg(1, arg, sizeof(arg));
new team_to = StringToInt(arg);

// don't let people move themselves to T
if (team_to == CS_TEAM_T) {
SwitchPlayerTeam(client, CS_TEAM_CT);
return Plugin_Handled;
}

return Plugin_Continue;
}

public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast) {
new winner = GetEventInt(event, "winner");
for (new i = 1; i <= MaxClients; i++) {
if (IsClientConnected(i) && IsClientInGame(i)) {
if (winner == GetClientTeam(i)) {
g_ShouldBeT[i] = true;
} else {
g_ShouldBeT[i] = false;
}
}
}
}

public Event_RoundPreStart(Handle:event, const String:name[], bool:dontBroadcast) {
new tCount, ctCount;
for (new i = 1; i <= MaxClients; i++) {
if (IsClientConnected(i) && IsClientInGame(i)) {
if (GetClientTeam(i) == CS_TEAM_T)
tCount++;
if (GetClientTeam(i) == CS_TEAM_CT)
ctCount++;
}
}

new allowedTs = (tCount + ctCount) / 2;
new moved = 0;

// move players that are maked as "should be T"
for (new i = 1; i <= MaxClients; i++) {
if (IsClientConnected(i) && IsClientInGame(i)) {
if (g_ShouldBeT[i] && moved+1 < allowedTs) {
moved++;
ChangeClientTeam(i, CS_TEAM_T);
} else {
ChangeClientTeam(i, CS_TEAM_CT);
}
}
}

// move any extra players needed
for (new i = 1; i <= MaxClients; i++) {
if (IsClientConnected(i) && IsClientInGame(i)) {
if (GetClientTeam(i) == CS_TEAM_CT && moved+1 < allowedTs) {
moved++;
ChangeClientTeam(i, CS_TEAM_T);
}
}
}
}

public Action:OnSoundPlayed(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags) {
if (entity && entity <= MaxClients && (StrContains(sample, "physics") != -1 || StrContains(sample, "footsteps") != -1)) {
return Plugin_Handled;
}

return Plugin_Continue;
}


public SwitchPlayerTeam(client, team) {
if (GetClientTeam(client) == team)
return;

if (team > CS_TEAM_SPECTATOR) {
CS_SwitchTeam(client, team);
CS_UpdateClientModel(client);
} else {
ChangeClientTeam(client, team);
}
}
__________________
Ayyylmao

Last edited by malec321; 05-07-2018 at 23:54.
malec321 is offline
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 05-09-2018 , 00:21  
Reply With Quote #4

I'm assuming this is the part of the code that is messed up.. Any advice??

Quote:
// move players that are maked as "should be T"
for (new i = 1; i <= MaxClients; i++) {
if (IsClientConnected(i) && IsClientInGame(i)) {
if (g_ShouldBeT[i] && moved+1 < allowedTs) {
moved++;
ChangeClientTeam(i, CS_TEAM_T);
} else {
ChangeClientTeam(i, CS_TEAM_CT);
}
}
}

// move any extra players needed
for (new i = 1; i <= MaxClients; i++) {
if (IsClientConnected(i) && IsClientInGame(i)) {
if (GetClientTeam(i) == CS_TEAM_CT && moved+1 < allowedTs) {
moved++;
ChangeClientTeam(i, CS_TEAM_T);
}
}
}
}
Willing to tip someone at this point to help me out.

Just need a simple request:
Switch teams if CTs win
Keep teams the same if Ts win
__________________
Ayyylmao

Last edited by sneaK; 05-10-2018 at 03:25.
malec321 is offline
Equiment
AlliedModders Donor
Join Date: Feb 2014
Old 05-18-2018 , 12:56   Re: [REQ] USP Ninja Team swap (CS GO)
Reply With Quote #5

Quote:
public OnPluginStart() HookEvent("round_end", RoundEnd);

public Action:RoundEnd(Handle:event, const String:name[], bool:dB)
{
new reason = GetEventInt(event, "reason");
if(reason == 6 || reason == 7)
{
for (new i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && GetClientTeam(i) > 1)
{
if(GetClientTeam(i) == 2) CS_SwitchTeam(i, 3);
else if(GetClientTeam(i) == 3) CS_SwitchTeam(i, 2);
}
}
}
}
btw: if u want to request paid plugin - write in pm
Equiment is offline
Markiez
Junior Member
Join Date: Mar 2018
Location: somewhere over the rainb
Old 05-27-2018 , 15:11   Re: [REQ] USP Ninja Team swap (CS GO)
Reply With Quote #6

Code:
#include <sourcemod>

bool g_bSwapped;

public void OnPluginStart()
{
	HookEvent("round_end", Event_End);
}

public void OnMapStart()
{
	g_bSwapped = false;
}

public Action Event_End(Event event, const char[] name, bool dontBroadcast)
{
	int iWinner = GetEventInt(event.GetInt("winner"));
	
	if (g_bSwapped)
	{
		if (iWinner == 3)
		{
			g_bSwapped = true;
			return;
		}
	}
	
	SwapTeams();
}

public void SwapTeams()
{
	for (int i = 1; i <= GetClientCount(false); i++)
	{
		int iTeam = GetClientTeam(i);
		
		if (iTeam == 2)
			ChangeClientTeam(i, 3);
		
		else if (iTeam == 3)
			ChangeClientTeam(i, 2);
	}
}
this should do the trick, sorry for being late with the response.
__________________
bool am_I_retarded = true;

Last edited by Markiez; 05-29-2018 at 11:15. Reason: just fixed some stuff
Markiez is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 05-27-2018 , 19:34   Re: [REQ] USP Ninja Team swap (CS GO)
Reply With Quote #7

Quote:
Originally Posted by Markiez View Post
int iWinner = GetClientOfUserId(event.GetInt("winner"));
GetClientOfUserId?

Here:

PHP Code:
#include <sourcemod>
#include <cstrike>

#pragma newdecls required
#pragma semicolon 1

public void OnPluginStart()
{
    
HookEvent("round_end"Event_RoundEndEventHookMode_Post);    
}

public 
void Event_RoundEnd(Event hEvent, const char[] sEventNamebool bDontBroadcast)
{
    if (
hEvent.GetInt("winner") == CS_TEAM_CT)
    {
        for (
int i 1<= MaxClients; ++i)
        {
            if (
IsClientInGame(i) && GetClientTeam(i) > 1
                
CS_SwitchTeam(i, (GetClientTeam(i) == CS_TEAM_CT)? CS_TEAM_T:CS_TEAM_CT);
        }
    }

__________________
LenHard is offline
Markiez
Junior Member
Join Date: Mar 2018
Location: somewhere over the rainb
Old 05-29-2018 , 11:13   Re: [REQ] USP Ninja Team swap (CS GO)
Reply With Quote #8

Quote:
Originally Posted by LenHard View Post
GetClientOfUserId?
I obviously mean GetEventInt xD

ur vers repeats every round (I think he mean the pistol round only).
__________________
bool am_I_retarded = true;

Last edited by Markiez; 05-29-2018 at 11:13.
Markiez is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 05-29-2018 , 12:21   Re: [REQ] USP Ninja Team swap (CS GO)
Reply With Quote #9

Quote:
Originally Posted by Markiez View Post
I obviously mean GetEventInt xD

ur vers repeats every round (I think he mean the pistol round only).
USP Ninja is only pistols (that's why it's called USP Ninja)...
__________________
LenHard is offline
Markiez
Junior Member
Join Date: Mar 2018
Location: somewhere over the rainb
Old 05-29-2018 , 12:58   Re: [REQ] USP Ninja Team swap (CS GO)
Reply With Quote #10

Quote:
Originally Posted by LenHard View Post
USP Ninja is only pistols (that's why it's called USP Ninja)...
aw right, never played that gamemode xD my bad sorry
__________________
bool am_I_retarded = true;
Markiez 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 13:02.


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