Raised This Month: $ Target: $400
 0% 

write_short()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-05-2006 , 14:45   write_short()
Reply With Quote #1

Ok, so i have this script... but i don't understand these write_short. I've tested some different values with various results.
Can i make them more logically? If so, can someone explain how? Lets say I want the message to hold for 13 seconds... what would i type in at "holdtime" to make it last that long?
Code:
    message_begin(MSG_BROADCAST ,SVC_TEMPENTITY, {0,0,0}, id)     write_byte(TE_TEXTMESSAGE)     write_byte(-1)     write_short(1<<10)  // X     write_short(1<<12)  // Y     write_byte(0)     write_byte(255)     write_byte(0)     write_byte(0)     write_byte(255)     write_byte(0)     write_byte(0)     write_byte(0)     write_byte(255)     write_short(1<<1)   // Fadein     write_short(1<<1)   // Fadeout     write_short(1<<10)  // Hold     write_string("Text")     message_end()

Last edited by [ --<-@ ] Black Rose; 11-05-2006 at 15:31.
[ --<-@ ] Black Rose is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 11-05-2006 , 15:23   Re: write_short()
Reply With Quote #2

To hold it for 13 seconds, use 13.0. I'm pretty sure shorts are floats.

I would use set_hudmessage() and show_hudmessage(), or even the hudmessage generator.
stupok is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-05-2006 , 15:25   Re: write_short()
Reply With Quote #3

No.

byte : int
char : int
short : int
long : int
angle : float
coord : float
string : string
entity : int

Yes i know, but i don't want to use them. No way, I would never use the hudmessage generator.

Last edited by [ --<-@ ] Black Rose; 11-05-2006 at 15:29.
[ --<-@ ] Black Rose is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 11-05-2006 , 17:02   Re: write_short()
Reply With Quote #4

this is how its done in set_hudmessage/show_hudmessage
(http://svn.tcwonline.org/viewvc.cgi/...xmodx&view=log)

Code:
unsigned short FixedUnsigned16(float value, float scale)
{
	int output = (int)(value * scale);

	if (output < 0)
		output = 0;
	else if (output > 0xFFFF)
		output = 0xFFFF;

	return (unsigned short)output;
}

short FixedSigned16(float value, float scale)
{
	int output = (int)(value * scale);

	if (output > 32767)
		output = 32767;
	else if (output < -32768)
		output = -32768;

	return (short)output;
}

void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, char *pMessage)
{
	if (pEntity)
		MESSAGE_BEGIN(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pEntity);
	else
		MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY);

	WRITE_BYTE(29);
	WRITE_BYTE(textparms.channel & 0xFF);
	WRITE_SHORT(FixedSigned16(textparms.x, (1<<13)));
	WRITE_SHORT(FixedSigned16(textparms.y, (1<<13)));
	WRITE_BYTE(textparms.effect);
	WRITE_BYTE(textparms.r1);
	WRITE_BYTE(textparms.g1);
	WRITE_BYTE(textparms.b1);
	WRITE_BYTE(0);
	WRITE_BYTE(255);
	WRITE_BYTE(255);
	WRITE_BYTE(250);
	WRITE_BYTE(0);
	WRITE_SHORT(FixedUnsigned16(textparms.fadeinTime, (1<<8)));
	WRITE_SHORT(FixedUnsigned16(textparms.fadeoutTime, (1<<8)));
	WRITE_SHORT(FixedUnsigned16(textparms.holdTime, (1<<8)));
	
	if (textparms.effect == 2)
		WRITE_SHORT(FixedUnsigned16(textparms.fxTime, (1<<8)));
	
	WRITE_STRING(pMessage);
	MESSAGE_END();
}
hope it helps!
__________________
plop
p3tsin is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-05-2006 , 17:44   Re: write_short()
Reply With Quote #5

I know but I can't do "return (short)output" in pawn (?).
[ --<-@ ] Black Rose is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 11-06-2006 , 09:44   Re: write_short()
Reply With Quote #6

read this has useful info and good links:
http://forums.alliedmods.net/showthread.php?t=41125
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-06-2006 , 10:16   Re: write_short()
Reply With Quote #7

That's not what i need...
[ --<-@ ] Black Rose is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 11-07-2006 , 04:44   Re: write_short()
Reply With Quote #8

Quote:
Originally Posted by [ --<-@ ] Black Rose View Post
I know but I can't do "return (short)output" in pawn (?).
Quote:
Originally Posted by [ --<-@ ] Black Rose View Post
No.

byte : int
char : int
short : int
long : int
angle : float
coord : float
string : string
entity : int

Yes i know, but i don't want to use them. No way, I would never use the hudmessage generator.
u dont need to cast it into a short value since pawn doesnt use them
__________________
plop
p3tsin is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 11-07-2006 , 12:14   Re: write_short()
Reply With Quote #9

For that matter, you don't need to use the FixedSigned16() function, since it deals with C++ aspects and not pawn.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-07-2006 , 12:19   Re: write_short()
Reply With Quote #10

This wont work... ok? The message shows up but dissapears like 0.1 secs later. ( and that isn't at channel 2 so scrollmsg isn't writing it over. )
Is there an error?
Code:
    message_begin(MSG_ONE_UNRELIABLE ,SVC_TEMPENTITY, {0,0,0}, id)     write_byte(TE_TEXTMESSAGE)     write_byte(1)     write_short(-1)     //  X     write_short(-1)     //  Y     write_byte(0)     write_byte(255)     write_byte(0)     write_byte(0)     write_byte(255)     write_byte(0)     write_byte(0)     write_byte(0)     write_byte(255)     write_short(1)      //  Fadein     write_short(1)      //  Fadeout     write_short(10)     //  Hold     write_string("Text")     message_end()
Quote:
Originally Posted by p3tsin View Post
u dont need to cast it into a short value since pawn doesnt use them
Can you please stfu?

Last edited by [ --<-@ ] Black Rose; 11-07-2006 at 12:23.
[ --<-@ ] Black Rose 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 04:59.


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