Raised This Month: $32 Target: $400
 8% 

Why they are crashing?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cr3V3TT3
Senior Member
Join Date: Jul 2004
Location: V'dauban
Old 01-26-2005 , 10:57   Why they are crashing?
Reply With Quote #1

Hi,
what do you think about this funcs :
Code:
void CSoundsSourcePlugin::PlayOnAll(const char * sound){
	for (int i=1;i<i_MaxPlayers;i++){
		IPlayerInfo *playerinfo=playerinfomanager->GetPlayerInfo(Players+i);
		if (playerinfo){
			if (playerinfo->IsConnected()){
				if (i_NoSounds[i]==0){
					edict_t * player=(Players+i);
					engine->ClientCommand(player,"play \"%s\"",sound);
				}
			}
		}
	}
}
Code:
void CSoundsSourcePlugin::HudMessage(const char * mess){
	if (mess){
		KeyValues *kv = new KeyValues( "menu" );
		char c_Mess[128];
		sprintf(c_Mess,"[SS] %s", mess);
		int i_Red; sscanf(ss_hudmsg_red.GetString(),"%d",&i_Red);
		int i_Green; sscanf(ss_hudmsg_green.GetString(),"%d",&i_Green);
		int i_Blue; sscanf(ss_hudmsg_blue.GetString(),"%d",&i_Blue);
		int i_Alpha; sscanf(ss_hudmsg_alpha.GetString(),"%d",&i_Alpha);
		kv->SetString( "title", c_Mess);
		kv->SetString( "msg", "" );
		kv->SetColor( "color", Color( i_Red, i_Green, i_Blue, i_Alpha ));
		kv->SetInt( "level", 2);
		kv->SetInt( "time", ss_hudmsg_time.GetInt());
		for (int i=1;i<=i_MaxPlayers;i++){
			IPlayerInfo *playerinfo=playerinfomanager->GetPlayerInfo(Players+i);
			if (playerinfo){
				if (playerinfo->IsConnected()){
					edict_t * player=(Players+i);
					helpers->CreateMessage(player, DIALOG_MSG, kv, this );
				}
			}
		}
		kv->deleteThis();
	}
}
They can be compiled with no error, but when they are called they crash the server.
Don' t understand why don' t working :/

PS :
Code:
void CSoundsSourcePlugin::ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ){
	i_MaxPlayers=clientMax;
	Players=pEdictList;
}
Cr3V3TT3 is offline
Send a message via MSN to Cr3V3TT3
Manip
Senior Member
Join Date: Jan 2004
Old 01-26-2005 , 11:23  
Reply With Quote #2

I've already said I don't like -

Code:
Players=pEdictList;
Just my opinion.

That code looks fairly solid .. could try -

Code:
edict_t * player=(Players+i); 
if(player) 
   helpers->CreateMessage(player, DIALOG_MSG, kv, this );
Code:
edict_t * player=(Players+i); 
if(player)
      engine->ClientCommand(player,"play \"%s\"",sound);
PS - The pointer is part of the type
Manip is offline
Send a message via AIM to Manip
Cr3V3TT3
Senior Member
Join Date: Jul 2004
Location: V'dauban
Old 01-26-2005 , 11:40  
Reply With Quote #3

lol i done as i can
try if(player) still crashing maybe it' s not from here...

Code:
void	ClientCommand( edict_t *pEdict, const char *szFmt, ... )
bool CreateMessage( const char *plugin, edict_t *pEntity, DIALOG_TYPE type, KeyValues *data )
I need to use edict_t for this funcs, no?
Cr3V3TT3 is offline
Send a message via MSN to Cr3V3TT3
Manip
Senior Member
Join Date: Jan 2004
Old 01-26-2005 , 11:52  
Reply With Quote #4

When is it crashing?

I thought this was rare/random crashes..? Wanna give us some more information on WHEN it is crashing and with WHAT error or information.
Manip is offline
Send a message via AIM to Manip
Cr3V3TT3
Senior Member
Join Date: Jul 2004
Location: V'dauban
Old 01-26-2005 , 11:59  
Reply With Quote #5

The last log message is :
Quote:
L 01/26/2005 - 15:55:04: World triggered "Round_Start"
There is no "error" or warning in the log


Round_Start event :
Code:
if (FStrEq(name,"Round_Start")){
	if (ss_firstblood.GetInt())
		i_FirstBlood = 1;
	if (ss_prepare.GetInt()){
		PlayOnAll(ss_prepare_sound.GetString());
		std::string hudmsg_hs = ss_prepare_hudmsg.GetString();
		char *round=NULL;
		sprintf(round,"%d",i_RoundNum);
		ReplaceTerm(hudmsg_hs, "$rn", round);
		HudMessage(hudmsg_hs.c_str());
		i_RoundNum++;
	}
}
Cr3V3TT3 is offline
Send a message via MSN to Cr3V3TT3
Manip
Senior Member
Join Date: Jan 2004
Old 01-26-2005 , 12:04  
Reply With Quote #6

PM me over the source-code, I'm going to run it though a debugger and figure out why it is crashing.
Manip is offline
Send a message via AIM to Manip
Cr3V3TT3
Senior Member
Join Date: Jul 2004
Location: V'dauban
Old 01-26-2005 , 12:19  
Reply With Quote #7

I' m sorry but whe i commented the "prepare" block like :

Code:
if (FStrEq(name,"Round_Start")){
	if (ss_firstblood.GetInt())
		i_FirstBlood = 1;
	if (ss_prepare.GetInt()){
		//PlayOnAll(ss_prepare_sound.GetString());
		//std::string hudmsg_hs = ss_prepare_hudmsg.GetString();
		//char *round=NULL;
		//sprintf(round,"%d",i_RoundNum);
		//ReplaceTerm(hudmsg_hs, "$rn", round);
		//HudMessage(hudmsg_hs.c_str());
		//i_RoundNum++;
	}
}
The prepare to fight don' t work (normal lol) bt other thing(playonall, hudmsg) works

So it' s not from the funcs :S
But when it' s uncommented still crash

I' ll see this part of the code sorry for this useless thread :S


EDIT : Crash is from "char *round=NULL;"
Fixed
Cr3V3TT3 is offline
Send a message via MSN to Cr3V3TT3
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 03:58.


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