Raised This Month: $ Target: $400
 0% 

[HELP] Ham_CS_RoundRespawn bug


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lightokun
Member
Join Date: Oct 2009
Old 12-30-2010 , 12:43   [HELP] Ham_CS_RoundRespawn bug
Reply With Quote #1

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?
__________________

Last edited by Lightokun; 12-30-2010 at 12:59.
Lightokun is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-30-2010 , 23:21   Re: [HELP] Ham_CS_RoundRespawn bug
Reply With Quote #2

You only have to use Ham_CS_RoundRespawn once to respawn a player.
It isn't bugged like spawn() is.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Lightokun
Member
Join Date: Oct 2009
Old 12-31-2010 , 04:44   Re: [HELP] Ham_CS_RoundRespawn bug
Reply With Quote #3

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
__________________
Lightokun is offline
Owner123
Member
Join Date: Jun 2010
Old 12-31-2010 , 05:04   Re: [HELP] Ham_CS_RoundRespawn bug
Reply With Quote #4

Use Ham_Spawn. I never have a problem with this.
__________________
Sorry for my bad english !
Owner123 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-31-2010 , 06:44   Re: [HELP] Ham_CS_RoundRespawn bug
Reply With Quote #5

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.
__________________
Arkshine is offline
Lightokun
Member
Join Date: Oct 2009
Old 12-31-2010 , 08:10   Re: [HELP] Ham_CS_RoundRespawn bug
Reply With Quote #6

OMG, open your eyes! There is Ham_CS_RoundRespawn only. Nothing else.
__________________
Lightokun is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-31-2010 , 08:18   Re: [HELP] Ham_CS_RoundRespawn bug
Reply With Quote #7

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.
__________________

Last edited by Arkshine; 12-31-2010 at 08:25.
Arkshine is offline
Lightokun
Member
Join Date: Oct 2009
Old 12-31-2010 , 12:02   Re: [HELP] Ham_CS_RoundRespawn bug
Reply With Quote #8

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.
__________________
Lightokun is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-01-2011 , 18:20   Re: [HELP] Ham_CS_RoundRespawn bug
Reply With Quote #9

Can you test your method with any other plugin running ?
Extract spawn code and make a single plugin and try to reproduce the bug ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-01-2011 , 19:43   Re: [HELP] Ham_CS_RoundRespawn bug
Reply With Quote #10

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:layerDeathThink(). 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.
__________________
Arkshine 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 02:07.


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