Raised This Month: $ Target: $400
 0% 

[Rewrite] Switch team after T die


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Claw
Member
Join Date: Sep 2004
Old 11-20-2007 , 08:15   [Rewrite] Switch team after T die
Reply With Quote #1

Hi

So im using this plugin which Exolent on these forums made, tho it has some bugs. The problem is that when you get changed betweens teams you sometimes have the wrong skin.

So im wondering if someone could look into it at probably help me?
I've tried the Hide n Seek v1 by OneEyed plugin aswell, but it has the same bug.

Code:
#include <amxmodx>
#include <cstrike>

new gMaxPlayers;
new bool:gRestart[33];

public plugin_init()
{
    register_plugin("Switch Ts", "1.0", "Exolent");
    register_logevent("logevent_Round_End", 2, "1=Round_End");
    register_clcmd("fullupdate", "clcmd_fullupdate");
    register_event("TextMsg", "event_TextMsg", "a", "#2=Game_will_restart_in");
    register_event("ResetHUD", "event_ResetHUD", "be");
    gMaxPlayers = get_maxplayers();
}

public client_disconnect(id)
{
    gRestart[id] = false;
}

public logevent_Round_End()
{
    new bool:tAlive = false;
    new CsTeams:team;
    for(new i = 1; i <= gMaxPlayers; i++) {
        if(!is_user_connected(i)) continue;
        team = cs_get_user_team(i);
        if(team == CS_TEAM_T && is_user_alive(i)) {
            tAlive = true;
            break;
        }
    }
    if(!tAlive) {
        for(new i = 1; i <= gMaxPlayers; i++) {
            if(!is_user_connected(i)) continue;
            team = cs_get_user_team(i);
            if(team != CS_TEAM_CT && team!= CS_TEAM_T) continue;
            cs_set_user_team(i, team == CS_TEAM_T ? CS_TEAM_CT : CS_TEAM_T, random_model(team));
        }
    }
}

public clcmd_fullupdate(id)
{
    return PLUGIN_HANDLED_MAIN;
}

public event_TextMsg()
{
    for(new i = 1; i <= gMaxPlayers; i++) {
        if(is_user_alive(i)) gRestart[i] = true;
    }
}

public event_ResetHUD(id)
{
    if(gRestart[id]) {
        gRestart[id] = false;
        return;
    }
    // let other plugin set custom models before checking bad ones.
    set_task(0.2, "handle_model", id + 888888);
}

public handle_model(id)
{
    id -= 888888;
    if(check_bad_model(id, CS_TEAM_T) || check_bad_model(id, CS_TEAM_CT)) {
        set_task(0.5, "set_model", id + 999999);
    }
}

public set_model(id)
{
    id -= 999999;
    new CsTeams:team = cs_get_user_team(id);
    if(team == CS_TEAM_CT) {
        cs_set_user_model(id, "gign");
    }
    else if(team == CS_TEAM_T) {
        cs_set_user_model(id, "leet");
    }
    
}

bool:check_bad_model(id, CsTeams:team)
{
    new model[32];
    cs_get_user_model(id, model, 31);
    if(team == CS_TEAM_T) {
        if(equali(model, "sas") || equali(model, "gign") || equali(model, "gsg9") || equali(model, "urban")) {
            return true;
        }
    }
    else if(team == CS_TEAM_CT) {
        if(equali(model, "arctic") || equali(model, "leet") || equali(model, "guerilla") || equali(model, "terror")) {
            return true;
        }
    }
    return false;
}

CsInternalModel:random_model(CsTeams:team)
{
    new CsInternalModel:model = CS_DONTCHANGE;
    if(team == CS_TEAM_CT) {
        switch(random_num(1, 4)) {
            case 1: model = CS_T_TERROR;
            case 2: model = CS_T_LEET;
            case 3: model = CS_T_ARCTIC;
            case 4: model = CS_T_GUERILLA;
        }
    }
    else if(team == CS_TEAM_T) {
        switch(random_num(1, 4)) {
            case 1: model = CS_CT_URBAN;
            case 2: model = CS_CT_GSG9;
            case 3: model = CS_CT_SAS;
            case 4: model = CS_CT_GIGN;
        }
    }
    return model;
}
Claw is offline
Claw
Member
Join Date: Sep 2004
Old 11-20-2007 , 15:40   Re: [Rewrite] Switch team after T die
Reply With Quote #2

I've spoken to some guys about how to fix this and they said i had to reset the models at spawn, if anyone could be so kind and edit that into my plugin i would highly appriciate it ;)
Claw is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 11-21-2007 , 11:51   Re: [Rewrite] Switch team after T die
Reply With Quote #3

In the function "event_ResetHud" pop the line:
Code:
cs_reset_user_model(id)
That should reset it.
purple_pixie is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 11-21-2007 , 12:11   Re: [Rewrite] Switch team after T die
Reply With Quote #4

All is about "Switch" thing. That switch you have in "round_end" event, is messy, and is not accurate. Use this instead.

Code:
public swap_teams()
{
 new players[32], num;
 get_players(players, num);
 
 new player;
 for(new i = 0; i < num; i++)
 {
  player = players[i];
 
  if(!is_user_connected(player))
   continue;
 
  if(cs_get_user_team(player) == CS_TEAM_T)
   cs_set_user_team(player, CS_TEAM_CT);
 
  else if(cs_get_user_team(player) == CS_TEAM_CT)
   cs_set_user_team(player, CS_TEAM_T);
 }
}
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Claw
Member
Join Date: Sep 2004
Old 11-21-2007 , 13:32   Re: [Rewrite] Switch team after T die
Reply With Quote #5

Ehm im confused
Could you maybe edit the code for me?
Not really the best at coding. ^^

Thanks for the reply's tho
Claw is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-21-2007 , 13:37   Re: [Rewrite] Switch team after T die
Reply With Quote #6

Add cs_reset_user_model() right after team change?

What is that native based on? Team? Model?

Last edited by [ --<-@ ] Black Rose; 11-21-2007 at 13:41.
[ --<-@ ] Black Rose is offline
Claw
Member
Join Date: Sep 2004
Old 11-21-2007 , 17:20   Re: [Rewrite] Switch team after T die
Reply With Quote #7

Yeah i added the reset model function and it seems to be working ;) thanks
Claw is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 11-22-2007 , 06:14   Re: [Rewrite] Switch team after T die
Reply With Quote #8

Quote:
Originally Posted by [ --<-@ ] Black Rose View Post
Add cs_reset_user_model() right after team change?

What is that native based on? Team? Model?
No idea.

But he wants the models reset, and there's a function called reset_model.

It can't hurt, right?
purple_pixie 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 01:15.


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