Raised This Month: $51 Target: $400
 12% 

Crashs love me ;)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cr3V3TT3
Senior Member
Join Date: Jul 2004
Location: V'dauban
Old 02-10-2005 , 19:14   Crashs love me ;)
Reply With Quote #1

Hi all,

since i used engine->PEntityOfEntIndex() in the code my plugin crashs

(PS : the commands before using this function http://forums.alliedmods.net/showthread.php?t=37220 )

New code :
Code:
KeyValues *kv = new KeyValues( "menu" );
kv->SetString( "title", mess);
kv->SetString( "msg", "" );
kv->SetColor( "color", Color( ss_hudmsg_blue.GetInt(), ss_hudmsg_green.GetInt(), ss_hudmsg_blue.GetInt(), ss_hudmsg_alpha.GetInt()));
kv->SetInt( "level", 2);
kv->SetInt( "time", ss_hudmsg_time.GetInt());
for (int i=1;i<=i_MaxPlayers;i++){
	IPlayerInfo *playerinfo=playerinfomanager->GetPlayerInfo(engine->PEntityOfEntIndex(i));
	if (playerinfo->IsConnected()){
			helpers->CreateMessage(engine->PEntityOfEntIndex(i), DIALOG_MSG, kv, this );
	}
}
kv->deleteThis();

Code:
helpers->CreateMessage(engine->PEntityOfEntIndex(i), DIALOG_MSG, kv, this );
instead of
Code:
edict_t * player=(PlayersList+i);
helpers->CreateMessage(player, DIALOG_MSG, kv, this );
I want to use the least of edict_t as i can because Manip said me to do not use them

Hmm the code looks very wonderfull now... but it s crashing lol
Any idea?
Cr3V3TT3 is offline
Send a message via MSN to Cr3V3TT3
BeetleFart
SourceMod Donor
Join Date: Apr 2004
Old 02-10-2005 , 20:06   Re: Crashs love me ;)
Reply With Quote #2

try adding a few checks of the entity and the playerinfo pointers


edict_t * player=engine->PEntityOfEntIndex(x);
if ((player)&&(!player->IsFree()))
{
IPlayerInfo * playerinfo=playerInfomanager->GetPlayerInfo(player);
if ((playerinfo)&&(playerinfo->IsConnected()))
{
//should be safe to use edict and player info here
}
}
BeetleFart is offline
Cr3V3TT3
Senior Member
Join Date: Jul 2004
Location: V'dauban
Old 02-11-2005 , 10:34  
Reply With Quote #3

right, thx
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:39.


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