AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   show CT player as a spectator in scoreboard (https://forums.alliedmods.net/showthread.php?t=84139)

kielor 01-21-2009 10:32

show CT player as a spectator in scoreboard
 
subject: howto?:)

Dores 01-21-2009 10:57

Re: show CT player as a spectator in scoreboard
 
The "yourFunction()" function is just an example:
PHP Code:

new const g_szTeams[4] =
{
    
"UNASSIGNED",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

new 
g_Msg_TeamInfo;

public 
plugin_init()
{
    
g_Msg_TeamInfo get_user_msgid("TeamInfo");
}

public 
yourFunction(id)
{
    if(
get_user_team(id) == 2)
    {
        
setScoreTeam(id3); // As you should know, 1 = T, 2 = CT and 3 = SPECTATOR(0 = UNASSIGNED).
    
}
}

setScoreTeam(indexteam)
{
    
message_begin(MSG_BROADCASTg_Msg_TeamInfo);
    
write_byte(index);
    
write_string(g_szTeams[team]);
    
message_end();



kielor 01-29-2009 08:42

Re: show CT player as a spectator in scoreboard
 
hmm.. when i'm running this on dedicated server it doesn't work((
bot is created but he shows in score board as ct, but i need that he must be CT but in scoreboard shown as a SPECTATOR

could anyone help me?

SnoW 01-29-2009 08:49

Re: show CT player as a spectator in scoreboard
 
Quote:

Originally Posted by kielor (Post 752164)
hmm.. when i'm running this on dedicated server it doesn't work((
bot is created but he shows in score board as ct, but i need that he must be CT but in scoreboard shown as a SPECTATOR

could anyone help me?

Dores' code was only an example:
1. If you didn't edit the code, there's no way it could work.
2. if you edited it, the problem can be there. Why wouldn't you post your code, so someone could have even a little chance to fix it?

Dores 01-29-2009 10:58

Re: show CT player as a spectator in scoreboard
 
As SnoW said, post the full code you're using.

Sn!ff3r 01-29-2009 11:16

Re: show CT player as a spectator in scoreboard
 
PHP Code:

new const g_szTeams[4] =
{
    
"UNASSIGNED",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"


Eh...
PHP Code:

new const g_szTeams[4][] =
{
    
"UNASSIGNED",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"



Dores 01-29-2009 12:42

Re: show CT player as a spectator in scoreboard
 
Woops, missed that one. Thanks Sn!ff3r.

kielor 01-30-2009 09:21

Re: show CT player as a spectator in scoreboard
 
Here's a code

Code:

#include <amxmodx>
#include <amxmisc>
#include <kz>

#define _TEAM_T 1
#define _TEAM_CT 2

new g_Msg_TeamInfo;

new bot;

new bot_name[32] = "kreedz bot";

new kz_enabled;

public plugin_init()
{
    register_plugin("kzbot", "1.0", "kielor");
    kz_enabled = get_cvar_pointer("kz_enabled");
    g_Msg_TeamInfo = get_user_msgid("TeamInfo");
}

public kz_Init(_state)
{
    if(!_state)
    {
        _kick_bot();
        pause("a");
        return;
    }

    if(!get_pcvar_num(kz_enabled))
    {
        _kick_bot();
        return;
    }
}

_kick_bot()
{
    if(bot)
        server_cmd("kick #%d", get_user_userid(bot));

    server_exec();
}

public RoundStart()
{
    if(!get_pcvar_num(kz_enabled))
        return;

    new players[32], nums;
    get_players(players, nums, "d");

    if(!bot && !nums)
        _make_player(_TEAM_CT);

    set_task(0.5, "delay_bot_settings");
}

public delay_bot_settings()
{
    if(get_pcvar_num(kz_enabled))
    {
        if(!is_user_alive(bot))
            dllfunc(DLLFunc_Spawn, bot);

        if(bot)
            _bot_settings(bot);
    }
}

_bot_settings(botid)
{
    set_pev(botid, pev_effects, (pev(bot, pev_effects) | 128));
    set_pev(botid, pev_solid, SOLID_NOT);
    set_pev(botid, pev_takedamage, 0.0);
    cs_set_user_deaths(botid, -1000);
    set_pev(botid, pev_frags, 1337.0);
    setScoreTeam(botid);

    if(cs_get_user_team(botid) != CS_TEAM_CT)
        cs_set_user_team(botid, CS_TEAM_CT, CS_CT_URBAN);
}

_make_player(_team)
{
    if(get_pcvar_num(kz_enabled))
    {
        if(!bot)
        {
            new reject[128];
            new botid = bot = engfunc(EngFunc_CreateFakeClient, bot_name);

            if(botid)
            {
                set_user_info(botid, "*bot", "1");
                dllfunc(DLLFunc_ClientConnect, botid, bot_name, "127.0.0.1", reject);
                dllfunc(DLLFunc_ClientPutInServer, botid);

                cs_set_user_team(botid, _team, (_team == 2) ? CS_CT_URBAN : CS_T_TERROR);
                set_user_flags(botid, ADMIN_IMMUNITY);
            }
            else
                log_amx("Failed to create %s bot", bot_name);
        }
    }
}

setScoreTeam(index)
{
    message_begin(MSG_BROADCAST, g_Msg_TeamInfo);
    write_byte(index);
    write_string("SPECTATOR");
    message_end();
}


Dores 01-30-2009 10:16

Re: show CT player as a spectator in scoreboard
 
First set his team to CT, then change score board.

kielor 01-30-2009 11:30

Re: show CT player as a spectator in scoreboard
 
like this:

PHP Code:

_bot_settings(botid)
{
    
set_pev(botidpev_effects, (pev(botpev_effects) | 128));
    
set_pev(botidpev_solidSOLID_NOT);
    
set_pev(botidpev_takedamage0.0);
    
cs_set_user_deaths(botid, -1000);
    
set_pev(botidpev_frags1337.0);
    if(
cs_get_user_team(botid) != CS_TEAM_CT)
        
cs_set_user_team(botidCS_TEAM_CTCS_CT_URBAN);
    
setScoreTeam(botid);


if yes, nothing happened, but on listen server it works correctly


All times are GMT -4. The time now is 01:51.

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