AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   write_short() (https://forums.alliedmods.net/showthread.php?t=46934)

[ --<-@ ] Black Rose 11-05-2006 14:45

write_short()
 
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()

stupok 11-05-2006 15:23

Re: write_short()
 
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.

[ --<-@ ] Black Rose 11-05-2006 15:25

Re: write_short()
 
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.

p3tsin 11-05-2006 17:02

Re: write_short()
 
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!

[ --<-@ ] Black Rose 11-05-2006 17:44

Re: write_short()
 
I know but I can't do "return (short)output" in pawn (?).

Rolnaaba 11-06-2006 09:44

Re: write_short()
 
read this has useful info and good links:
http://forums.alliedmods.net/showthread.php?t=41125

[ --<-@ ] Black Rose 11-06-2006 10:16

Re: write_short()
 
That's not what i need...

p3tsin 11-07-2006 04:44

Re: write_short()
 
Quote:

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

Quote:

Originally Posted by [ --<-@ ] Black Rose (Post 400085)
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 :wink:

Zenith77 11-07-2006 12:14

Re: write_short()
 
For that matter, you don't need to use the FixedSigned16() function, since it deals with C++ aspects and not pawn.

[ --<-@ ] Black Rose 11-07-2006 12:19

Re: write_short()
 
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 (Post 400738)
u dont need to cast it into a short value since pawn doesnt use them :wink:

Can you please stfu?


All times are GMT -4. The time now is 04:59.

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