AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Ham_CS_RoundRespawn bug (https://forums.alliedmods.net/showthread.php?t=146659)

Lightokun 12-30-2010 12:43

[HELP] Ham_CS_RoundRespawn bug
 
So, a have latest war3ft on my linux server.
Sometimes(randomly) when i buy scroll of respawning, player is transfered to team_spectator (team 3).
The part of code:
Code:

public _SHARED_Spawn( id )
{
        id -= TASK_SPAWN;
       
        if(id < 1 && id > MAXPLAYERS)
                return;
       
        // Respawning isn't necessary w/CSDM - so lets not do that!
        if ( CVAR_csdm_active > 0 && get_pcvar_num( CVAR_csdm_active ) == 1 )
        {
                return;
        }

        // User is no longer connected or is not on a team
        if ( !p_data_b[id][PB_ISCONNECTED] )
        {
                SHARED_SetUserMoney( id, SHARED_GetUserMoney( id ) + ITEM_Cost( id, ITEM_SCROLL ) );
                return;
        }
       
        if( !SHARED_IsOnTeam( id ) ) {
                client_print( id, print_chat, "%s Unable to respawn because of the bug", g_MODclient );
                SHARED_SetUserMoney( id, SHARED_GetUserMoney( id ) + ITEM_Cost( id, ITEM_SCROLL ) );
                return;
        }
       
        if ( is_user_alive( id ) )
        {
                return;
        }

        // Round has ended, lets give money back if they bought a scroll
        if ( g_EndRound )
        {
                if ( p_data[id][P_RESPAWNBY] == RESPAWN_ITEM )
                {
                        client_print( id, print_chat, "%s Unable to respawn because the round is over, here is your money back", g_MODclient );

                        SHARED_SetUserMoney( id, SHARED_GetUserMoney( id ) + ITEM_Cost( id, ITEM_SCROLL ) );
                }

                return;
        }

        // Reset items when the user spawns!
        g_iShopMenuItems[id][ITEM_SLOT_ONE]        = ITEM_NONE;
        g_iShopMenuItems[id][ITEM_SLOT_TWO] = ITEM_NONE;

        // Give the user godmode for a little
        //set_user_godmode( id, 1 );
        p_data_b[id][PB_NO_DAMAGE] = true;

        // Save their previous weapons!
        SHARED_CopySavedWeapons( id );

        // Ignore the armor settaging...
        bIgnoreArmorSet[id] = true;

        // We don't want to call a crap-ton of WC3 functions when we're spawning them 3 times do we ?
        bIgnorePlayerSpawning[id] = true;

        // Spawn the player
        ExecuteHamB(Ham_CS_RoundRespawn,id);
       
        p_data_b[id][PB_SLOWED]                = false;
        p_data_b[id][PB_STUNNED]        = false;
        p_data_b[id][PB_GIVEITEMS]        = true;
       
        // Reset the user's skin to normal
        SHARED_ChangeSkin( id, SKIN_RESET );

        // The user should no longer be a mole!
        p_data_b[id][PB_MOLE] = false;

        set_task( 0.2, "_SHARED_Spawn_Final", TASK_SPAWNPLAYER + id );
        set_task( 0.4, "_SHARED_CS_GiveWeapons", TASK_GIVEITEMS + id );
        set_task( 1.0, "_SHARED_SpawnRemoveGod", TASK_SPAWNREMOVEGOD + id );

        return;
}

I did a lot of checks. So, when i'm dead my team is CT or T and it's normal. But when Ham_CS_RoundRespawn executed sometimes player transfered to spectator team. I put the client_print stuff like:
Code:

client_print(id, print_chat, "%d",cs_get_user_team(id));
ExecuteHamB(Ham_CS_RoundRespawn,id);
client_print(id, print_chat, "%d",cs_get_user_team(id));

And it shows:
2
3
And i'm transfered to spec team.
Sometimes it works well. So, what's the reason for this and if there exists another way to respawn player with correct team?
So, i'm thinking of writing my own module or fixing ham for respawn. Can anyone tell me where to find part of code where Ham_CS_RoundRespawn respawns a player?

Exolent[jNr] 12-30-2010 23:21

Re: [HELP] Ham_CS_RoundRespawn bug
 
You only have to use Ham_CS_RoundRespawn once to respawn a player.
It isn't bugged like spawn() is.

Lightokun 12-31-2010 04:44

Re: [HELP] Ham_CS_RoundRespawn bug
 
And i use only
// Spawn the player
ExecuteHamB(Ham_CS_RoundRespawn,id);
as you can see.
Here is a screenshot of
Code:

client_print(id, print_chat, "%d",cs_get_user_team(id));
ExecuteHamB(Ham_CS_RoundRespawn,id);
client_print(id, print_chat, "%d",cs_get_user_team(id));

http://upload.lpsw.ru/files/original..._dust20000.bmp

Owner123 12-31-2010 05:04

Re: [HELP] Ham_CS_RoundRespawn bug
 
Use Ham_Spawn. I never have a problem with this.

Arkshine 12-31-2010 06:44

Re: [HELP] Ham_CS_RoundRespawn bug
 
No, that's wrong. There is tuto with explanations. It's the same as using spawn() or cs_user_spawn(), both generates problems because it doesn't follow the right way of respawing a player.

You have to use either DEAD_RESPAWNABLE + Think(), or Ham_CS_RoundRespawn.

Lightokun 12-31-2010 08:10

Re: [HELP] Ham_CS_RoundRespawn bug
 
OMG, open your eyes! There is Ham_CS_RoundRespawn only. Nothing else.

Arkshine 12-31-2010 08:18

Re: [HELP] Ham_CS_RoundRespawn bug
 
Answered to Owner123, not you.

About your problem, no idea. It happens when exactly ? I doubt randomly.

So, i'm thinking of writing my own module or fixing ham for respawn ; Ham calls just the CS functions, these ones work fine. So, It would be more you don't use properly the function or not at the right time. You can try the other method, flag + think.

Lightokun 12-31-2010 12:02

Re: [HELP] Ham_CS_RoundRespawn bug
 
Sorry.
And yes, it happens randomly. I fixed it some way and it works well but it's not the panacea.
I have linux server and amxx 1.8.2. Same situation with 1.8.1 with windows.

ConnorMcLeod 01-01-2011 18:20

Re: [HELP] Ham_CS_RoundRespawn bug
 
Can you test your method with any other plugin running ?
Extract spawn code and make a single plugin and try to reproduce the bug ?

Arkshine 01-01-2011 19:43

Re: [HELP] Ham_CS_RoundRespawn bug
 
Looking at the decompiled code, both way do actually the same thing at the end :

Code:

respawn();
pev_nextthink = -1;
pev_button = 0;

respawn() = Some checks but at the end, call to CBasePlayer::Spawn()


There are though one small difference :

- DEAD_RESPAWNABLE + Think()
While we are dead, we are in CBasePlayer::PlayerDeathThink(). Some stuffs are done ( animation, weapon drop, etc. ) and there is a check DEAD_RESPAWNABLE which will allow to spawn. So this way triggers directly this check.
- Ham_CS_RoundRespawn
It calls actually CBasePlayer::RoundRespawn(). This functions does basically : punish you (kill) if you have tk'ed before (if mp_tkpunish is enabled), respawn you if m_iMenu offset is not equal to 3. ( 3 = #Terrorist_Select and #CT_Select )
So, I don't see how you can respawn in spectator from the CS code.
Your bug is most likely because of some code in your plugin or others.


All times are GMT -4. The time now is 02:07.

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