AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   message_begin crashes server (https://forums.alliedmods.net/showthread.php?t=6890)

genesis 10-18-2004 01:45

message_begin crashes server
 
I'm not sure what I'm doing wrong here:
NOTE: using amx 0.20 RC6
Code:
new gmsgFade // this is at the very beginning of my plugin message_begin(MSG_ONE, gmsgFade, {0,0,0}, player) write_short(1<<12) write_short(1<<8) write_byte(0) write_byte(0) write_byte(0) write_byte(255) message_end()

when this part of the code is run my server crashes and I get the following message

tried to create a message with a bogus message type ( 0 )

DS 10-18-2004 01:58

That's probably because gmsgFade is never set to anything. Just creating the variable will automatically initialize it to 0. You need to get the message ID of the fade message before you can use it. So what you need to do is put something like this in plugin_init like this:

Code:
public plugin_init() {     gmsgFade = get_user_msgid("ScreenFade") }

or you could also get rid of gmsgFade variable and make the message_begin like this:
Code:
message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, player)

Either way should work, but I don't know if that variable gmsgFade is used elsewhere within your plugin or not.

genesis 10-19-2004 01:41

ty
 
yep that was it, thanks.

on a small continuation note though ... this only fades to black for a second then goes back to normal. how can i get it to stay black


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

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