[INC] Message Stocks

Сообщения
157
Реакции
279

This .inc file contains a bunch of functions that will make your life easier. The goal of it is to make the usage of message_begin functions a piece of cake, especially the SVC_TEMPENTITY ones.

Instead of having to do all of this just to create a single beam:

PHP:
new iStartPos[3], iEndPos[3];
get_user_origin(id, iStartPos);
get_user_origin(id, iEndPos, 3);

message_begin(MSG_ALL, SVC_TEMPENTITY);
write_byte(TE_BEAMPOINTS);
write_coord(iStartPos[0]);
write_coord(iStartPos[1]);
write_coord(iStartPos[2]);
write_coord(iEndPos[0]);
write_coord(iEndPos[1]);
write_coord(iEndPos[2]);
write_short(g_iSprite);
write_byte(0);
write_byte(30);
write_byte(10);
write_byte(10);
write_byte(0);
write_byte(0);
write_byte(0);
write_byte(255);
write_byte(75);
write_byte(0);
message_end();
With using this library, we can do it as simple as this:

PHP:
new iStartPos[3], iEndPos[3];
get_user_origin(id, iStartPos);
get_user_origin(id, iEndPos, 3);

te_create_beam_between_points(iStartPos, iEndPos, g_iSprite)
This saves a lot of time that you would spend searching for the write_ arguments, experimenting with the numbers and having to write all 20 arguments 1 by 1 and having a huge chance of messing some of them up.

Only the mandatory arguments in the stocks are required (e.g. starting position, sprite index, etc) and all other ones have a default value and are optional.

All of the stocks share 2 same arguments - receiver and bool:reliable - both optional and the second one is always the last argument in the natives. The first one controls who will see the message and the second one controls whether or not to use the reliable channel. With this being said, if receiver is set to 0 and reliable is true, the stock will use MSG_ALL as the message destination.

 
Сообщения
2,751
Реакции
3,017
Помог
61 раз(а)
Предлагаю сделать данные стоки в AMXX 1.8.3 стандартом. (в комплект)
 
Сообщения
157
Реакции
279
Сообщения
157
Реакции
279
Сообщения
3,593
Реакции
1,576
Помог
141 раз(а)
OciXCrom,
Код:
stock draw_status_icon(id, sprite[] = "", StatusIconFlags:status = StatusIcon_Hide, r = 0, g = 0, b = 0, bool:reliable = true)
{
    if(id && !is_user_connected(id))
        return 0;

    static MSG_StatusIcon;

    if(!MSG_StatusIcon)
        MSG_StatusIcon = get_user_msgid("StatusIcon");

    message_begin(get_msg_destination(id, reliable), MSG_StatusIcon, .player = id);
    write_byte(_:status);
+   write_string(sprite);

    if(status)
    {
-       write_string(sprite);
        write_byte(r);
        write_byte(g);
        write_byte(b);
    }

    message_end();
    return 1;
}
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу