AlliedModders

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

yikomaka 09-11-2004 22:07

Red Nightvision?
 
Okay heres the code... when I type amx_nvg in the game console it does not fade red or anything..... help? Thanks

Code:

#include <amxmodx>
public plugin_init() {
        register_plugin("Red NVG","1.0","SnipaJ")
        register_clcmd("amx_nvg","nvg1")
        register_clcmd("amx_nvg2","nvg2")
        register_clcmd("amx_nvg3","nvg3")
}

public nvg1(id) {
    message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
    write_short( 1<<99999) // fade lasts this long duration
    write_short( 1<<99999 ) // fade lasts this long hold time
    write_short( 1<<12 ) // fade type (in / out)
    write_byte( 200 ) // fade red
    write_byte( 0 ) // fade green
    write_byte( 0 ) // fade blue
    write_byte( 50 ) // fade alpha
    message_end()
    return PLUGIN_HANDLED
}

public nvg2(id) {
    message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
    write_short( 1<<99999) // fade lasts this long duration
    write_short( 1<<99999 ) // fade lasts this long hold time
    write_short( 1<<12 ) // fade type (in / out)
    write_byte( 200 ) // fade red
    write_byte( 0 ) // fade green
    write_byte( 0 ) // fade blue
    write_byte( 150 ) // fade alpha
    message_end()
    return PLUGIN_HANDLED
}

public nvg3(id) {
    message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)
    write_short( 1<<99999) // fade lasts this long duration
    write_short( 1<<99999 ) // fade lasts this long hold time
    write_short( 1<<12 ) // fade type (in / out)
    write_byte( 200 ) // fade red
    write_byte( 0 ) // fade green
    write_byte( 0 ) // fade blue
    write_byte( 200 ) // fade alpha
    message_end()
    return PLUGIN_HANDLED
}


Anpheus 09-12-2004 00:10

1 << # is bitwise manipulation.

The bits are shorts, 16 bit.

So, this is what you're doing:

Take short "0000 0000 0000 0001" and leftshift it by 99999 bits

the result:

"0000 0000 0000 0000"


That doesn't seem very long to me!


To get 'maximum length' simply do ~0 instead of 1 << 99999

~1 (which is Not "0000 0000 0000 0000") will make it "1111 1111 1111 1111"


Unless it's signed. In which case you want ~1<<15.

johnjg75 09-12-2004 00:11

could we change write_short() to write_long() ?

Anpheus 09-12-2004 00:13

Possibly, I don't know how the message works. It's equally probably you'd crash the game.

johnjg75 09-12-2004 00:24

Fixed! :D

Ares0016 03-23-2005 19:38

Can some one give me the final copy
 
could some one make it so if u type amx_nvg (color)
it will give u that color

LynX 03-24-2005 02:06

Code:
message_begin(MSG_ONE, SVC_TEMPENTITY, {0, 0, 0}, id) write_byte(27) // TE_DLIGHT write_coord(origin[0]) // X coord write_coord(origin[1]) // Y coord write_coord(origin[2]) // Z coord write_coord(radius) // radius write_byte(250) // red write_byte(0) // green write_byte(0) // blue write_byte(250) // brightness write_byte(10) // life write_coord(0) // decay rate message_end()


All times are GMT -4. The time now is 17:16.

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