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

When doing a saytext message it's cutting off the last char


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 01-18-2005 , 22:21   When doing a saytext message it's cutting off the last char
Reply With Quote #1

Anyone else experience this?

Here is my code:

Code:
	char msg[128];
	sprintf(msg, "[WAR3FT] You changed your race to : %s\n", race_Names[iRace-1]);

	this->SayText( msg );
The constant:
Code:
const char race_Names[MAX_RACES][64] =	{
										"Undead Scourge", 
										"Human Alliance", 
										"Orcish Horde", 
										"Night Elf"
									};
The SayText function:
Code:
void CPlayer::SayText( const char *szMsg )
{
	bf_write *msg;
	MRecipientFilter f;
	f.AddPlayer( pIndex );
	msg = engine->UserMessageBegin( (IRecipientFilter *)&f, 3 );
	msg->WriteByte( pIndex );
	msg->WriteString( szMsg );
	msg->WriteByte( true );
	engine->MessageEnd();

}
It just chops off the last letter, if the race is Night Elf, it prints Night El on the screen, BUT when you look in the console it shows the f. wtf?

It's very strange, anyone have any ideas? Also what does the last WriteByte actually mean?
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
Manip
Senior Member
Join Date: Jan 2004
Old 01-18-2005 , 22:31  
Reply With Quote #2

I have... I just "solved" it by placing a space in there.
Manip is offline
Send a message via AIM to Manip
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 01-19-2005 , 08:55  
Reply With Quote #3

Just put a space at the end? K cool that works Weird I must say.

So I should just do:

Code:
void CPlayer::SayText( const char *szMsg )
{
	char message[256];
	sprintf(message, "%s \n", szMsg);

	bf_write *msg;
	MRecipientFilter f;
	f.AddPlayer( pIndex );
	msg = engine->UserMessageBegin( (IRecipientFilter *)&f, 3 );
	msg->WriteByte( pIndex );
	msg->WriteString( message );
	msg->WriteByte( true );
	engine->MessageEnd();

}
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
XAD
Senior Member
Join Date: Mar 2004
Location: Sweden
Old 01-19-2005 , 10:26  
Reply With Quote #4

Quote:
Originally Posted by Geesu
Just put a space at the end? K cool that works Weird I must say.
Actually, it's enough to add a '\n' at the end of the line... if you put a 0 in the last byte and in the first (at least in your example)...

/X
XAD is offline
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 01-19-2005 , 12:53  
Reply With Quote #5

yea you would think, but I put \0\n and it still cut off the last character.
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
XAD
Senior Member
Join Date: Mar 2004
Location: Sweden
Old 01-19-2005 , 13:45  
Reply With Quote #6

Quote:
Originally Posted by Geesu
yea you would think, but I put \0\n and it still cut off the last character.
Yeah, of course... read the bf_write/read functions... a string is ending with a \0 so the first one will terminate the string... the next byte \n will be the last parameter byte and your next byte will just be ignored... so remove the \0 in the string and keep the last \n but put a 0 in the last byte parameter...

byte = 0
string = string terminated with a \n\0 (ex "hej\n\0")
byte = 0

/X
XAD is offline
aszsian
New Member
Join Date: Jan 2005
Old 01-19-2005 , 23:02   sfdafdadaffdsfdd
Reply With Quote #7

is coding for the war3ft similar to JAVA?

cause im in AP Computer Science and we are studying Java... were only upto arrays but i can program alot of stuff now..


oh yeah it maybe that ur pointer to the display is messed up... maybe u need to add 1 to ur variable.

i wanna learn other programming languages.. like C++.... so i can program into games like u modders
aszsian is offline
Tim
Senior Member
Join Date: Dec 2004
Location: the Netherlands
Old 01-20-2005 , 09:57  
Reply With Quote #8

SM will support, among others, JavaScript...
This isn't the same as Java, so you'll have to do some research into Javascript, if that's the
language you want to be programming in...
An alternative is learning C/C++ (isn't it?), which is quite a different approach to programming.
(C++'s OOP-parts are just some tricks they build in, not what they had in mind in the first place)
From what the SourceMod people have said, it's unlikely there'll be Java-plugin-support...
But lets keep things on-topic, shall we?
Tim 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 22:10.


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