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

[HELP] My plugin requires new features.


Post New Thread Reply   
 
Thread Tools Display Modes
debr1s
Junior Member
Join Date: Jun 2021
Old 07-19-2021 , 20:38   Re: [HELP] My plugin requires new features.
Reply With Quote #11

Quote:
Originally Posted by Bacardi View Post
Example 2
- Player need choose random team, when connected into server or map change.
- After this player can choose between spectator and old team.
- If player reconnect or map change -> start read this post again above.

- Admins immunity is now removed, so you can test without thinking admin rights/overrides.
You can enable it back by erase double slash (//) line 16.

- You may counter problems with team limit.
You need either increase mp_limitteams example 5 or 0 = disable check.

- optional: you can force player in team when they connect to server automatically with
mp_force_assign_teams 1

PHP Code:
public void OnPluginStart()
{
    
AddCommandListener(listen"jointeam");
    
HookEventEx("player_spawn"player_spawn);
    
HookEventEx("player_team"player_team);
}

int oldteam[MAXPLAYERS+1];

public 
Action listen(int client, const char[] commandint argc)
{
    
// human player only
    
if(client || !IsClientInGame(client) || IsFakeClient(client)) return Plugin_Continue;

    
// immunity - disabled for now
    //if(CheckCommandAccess(client, "sm_bypass_jointeam", ADMFLAG_CUSTOM6)) return Plugin_Continue;

    // not enough arguments
    
if(argc 1) return Plugin_Handled;


    
char arg[3];
    
GetCmdArg(1argsizeof(arg));
    
    
int newteam StringToInt(arg);

    
// bad team index
    
if(newteam || newteam 3) return Plugin_Handled;

    switch(
newteam)
    {
        case 
0:    // random choose
        
{
            if(
oldteam[client] == 0)
            {
                return 
Plugin_Continue;
            }

            return 
Plugin_Handled;
        }
        case 
1// spectator
        
{
            return 
Plugin_Continue;
        }
        default: 
// T or CT
        
{
            if(
oldteam[client] != newteam)
                return 
Plugin_Handled;
        }
    }

    
    
// player need pick old team

    
return Plugin_Continue;
}

public 
void player_spawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));

    
oldteam[client] = event.GetInt("teamnum");
}

public 
void player_team(Event event, const char[] namebool dontBroadcast)
{
    
int team event.GetInt("team");
    
    
// skip moving to spectator
    
if(team == 1) return;

    
int client GetClientOfUserId(event.GetInt("userid"));

    
// clear record when player disconnect or bot
    
if(event.GetBool("disconnect") || event.GetBool("isbot"))
    {
        
oldteam[client] = 0;
        return;
    }
    
    
// record
    
oldteam[client] = event.GetInt("team");

This works perfectly thank you.
debr1s 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 11:16.


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