Raised This Month: $32 Target: $400
 8% 

Solved [L4D2] Trying to make sure clients are in the correct team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 03-14-2023 , 18:01   [L4D2] Trying to make sure clients are in the correct team
Reply With Quote #1

Hello guys, this is part of a long script

Left 4 Dead 2 - Versus Mode

Trying to sort clients and put them in their correct team upon changing to next map.

This will also help me solve other issues as well. My main issue is: I'm not able to detect the actual winning team (team with the higher score) weather they are survivors or infected. Specially sometimes teams are flipped making it a bit complicated for me.

Thanks

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <left4dhooks>

StringMap g_sCampaign;

int g_iSurvivor_Score;
int g_iInfected_Score;

bool g_bTrigger;

public 
void OnPluginStart()
{
    
HookEvent("round_end"Event_RoundEndEventHookMode_PostNoCopy);
    
g_sCampaign = new StringMap();
}

public 
void OnMapStart()
{
    
g_bTrigger false;
}

void Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    if (!
GameRules_GetProp("m_bInSecondHalfOfRound") || g_bTrigger) return;
    
    if (!
L4D2_AreTeamsFlipped())
    {
        
g_iSurvivor_Score L4D_GetTeamScore(1true);
        
g_iInfected_Score L4D_GetTeamScore(2true);
    }
    else
    {
        
g_iSurvivor_Score L4D_GetTeamScore(2true);
        
g_iInfected_Score L4D_GetTeamScore(1true);
    }
    
    
g_sCampaign.Clear();
    
g_bTrigger true;
    
    
CreateTimer(2.0Timer_SavePlayersTeamTIMER_FLAG_NO_MAPCHANGE);
}

Action Timer_SavePlayersTeam(Handle timer)
{
    
int iTeam;
    for (
int i 1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i) || IsFakeClient(i)) continue;
        
        
char auth[32];
        
GetClientAuthId(iAuthId_Steam2authsizeof(auth));
        
        if(
g_iSurvivor_Score >= g_iInfected_Score)
        {
            if(
GetClientTeam(i) == 1iTeam 1;
            else if(
GetClientTeam(i) == 2iTeam 2;
            else 
iTeam 3;
        }
        else
        {
            if(
GetClientTeam(i) == 1iTeam 1;
            else if(
GetClientTeam(i) == 3iTeam 2;
            else 
iTeam 3;
            
            
PrintToChat(i"Your saved team for the next chapter is: %i"iTeam);
        }
        
        
g_sCampaign.SetValue(authiTeamtrue);
    }
    return 
Plugin_Handled;
}

public 
void OnClientPostAdminCheck(int client)
{
    if (!
IsClientInGame(client) || IsFakeClient(client)) return;
    
CreateTimer(1.0Timer_RepositionClientsGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}

Action Timer_RepositionClients(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);
    if(
client == || !IsClientInGame(client) || IsFakeClient(client)) return Plugin_Handled;
    
    
char auth[32];
    
GetClientAuthId(clientAuthId_Steam2authsizeof(auth));
    
    
int iTeam;
    if(
g_sCampaign.GetValue(authiTeam))
    {
        if(
iTeam || iTeam 3) return Plugin_Handled;
        
PrintToChat(client"Your loaded team this chapter should be set to: %i"iTeam);
    }
    
    return 
Plugin_Handled;

__________________

Last edited by alasfourom; 03-15-2023 at 20:13. Reason: uploading the sp file
alasfourom is offline
sorallll
Senior Member
Join Date: Oct 2018
Old 03-14-2023 , 21:28   Re: [L4D2] Trying to make sure clients are in the correct team
Reply With Quote #2

You can refer to this plugin

Last edited by sorallll; 03-14-2023 at 21:30.
sorallll 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 23:11.


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