Raised This Month: $138 Target: $400
 34% 

[INC] Message Stocks


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 08-27-2018 , 09:23   [INC] Message Stocks
Reply With Quote #1


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 Code:
new iStartPos[3], iEndPos[3];
get_user_origin(idiStartPos);
get_user_origin(idiEndPos3);

message_begin(MSG_ALLSVC_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 Code:
new iStartPos[3], iEndPos[3];
get_user_origin(idiStartPos);
get_user_origin(idiEndPos3);

te_create_beam_between_points(iStartPosiEndPosg_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.

__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
EXteRmiNaToR
Senior Member
Join Date: Dec 2009
Old 08-27-2018 , 16:01   Re: [INC] Message Stocks
Reply With Quote #2

Amazing, well organized work! Could you also add the plugin you demonstrate in the video?
EXteRmiNaToR is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 08-27-2018 , 17:53   Re: [INC] Message Stocks
Reply With Quote #3

Sure.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cromchat>
#include <fakemeta>
#include <fun>
#include <msgstocks>

#if AMXX_VERSION_NUM < 183
    #include <dhudmessage>
#endif

#define rnd random(256)
#pragma unused lightning

new pos1[3] = {3582048, -53}, ent1
new pos2[3] = {3902527, -82}, ent2
new beamrecmenupageunusedexplosionsmoke 
new lightningballflameglowbubbles

public plugin_precache()
{
    
beam precache_model("sprites/laserbeam.spr")
    
explosion precache_model("sprites/zerogxplode.spr")
    
smoke precache_model("sprites/steam1.spr")
    
lightning precache_model("sprites/lgtning.spr")
    
ball precache_model("models/xtcs/ball.mdl")
    
flame precache_model("sprites/flame.spr")
    
glow precache_model("sprites/glow01.spr")
    
bubbles precache_model("sprites/bubble.spr")
}

public 
act(id)
{
    
menu_display(idmenuclamp(page, .max menu_pages(menu) - 1))
    return 
PLUGIN_HANDLED
}

public 
plugin_init()
{
    
register_plugin("TE_TESTING""1.0""OciXCrom")
    
register_concmd("act""act")
    
register_concmd("set""set")
    
register_clcmd("set1""set1")
    
register_clcmd("set2""set2")
    
register_clcmd("switch""switchit")

    
menu menu_create("Temporary entity effects list""menuhandler")
    
menu_additem(menu"te_create_beam_between_points")
    
menu_additem(menu"te_create_beam_from_entity")
    
menu_additem(menu"te_create_gunshot")
    
menu_additem(menu"te_create_explosion")
    
menu_additem(menu"te_create_tar_explosion")
    
menu_additem(menu"te_create_smoke")
    
menu_additem(menu"te_create_tracer")
    
menu_additem(menu"te_create_beam_between_entities")
    
menu_additem(menu"te_create_sparks")
    
menu_additem(menu"te_create_lava_splash")
    
menu_additem(menu"te_create_teleport_splash")
    
menu_additem(menu"te_create_colored_explosion")
    
menu_additem(menu"te_place_decal_from_bsp_file")
    
menu_additem(menu"te_create_implosion")
    
menu_additem(menu"te_create_model_trail")
    
menu_additem(menu"te_display_additive_sprite")
    
menu_additem(menu"te_create_beam_sprite")
    
menu_additem(menu"te_create_beam_ring")
    
menu_additem(menu"te_create_beam_disk")
    
menu_additem(menu"te_create_beam_cylinder")
    
menu_additem(menu"te_create_following_beam")
    
menu_additem(menu"te_display_glow_sprite")
    
menu_additem(menu"te_create_beam_ring_between_entities")
    
menu_additem(menu"te_create_tracer_shower")
    
menu_additem(menu"te_create_dynamic_light")
    
menu_additem(menu"te_create_entity_light")
    
menu_additem(menu"te_draw_line")
    
menu_additem(menu"te_create_box")
    
menu_additem(menu"te_remove_all_beams_from_entity")
    
menu_additem(menu"te_create_large_funnel")
    
menu_additem(menu"te_create_bloodstream")
    
menu_additem(menu"te_draw_blood_line")
    
menu_additem(menu"te_spray_blood")
    
menu_additem(menu"te_place_brush_decal")
    
menu_additem(menu"te_create_bouncing_model")
    
menu_additem(menu"te_create_explode_model")
    
menu_additem(menu"te_create_break_model")
    
menu_additem(menu"te_place_gunshot_decal")
    
menu_additem(menu"te_create_sprite_spray")
    
menu_additem(menu"te_create_armor_ricochet")
    
menu_additem(menu"te_place_player_spray")
    
menu_additem(menu"te_create_bubble_box")
    
menu_additem(menu"te_create_bubble_line")
    
menu_additem(menu"te_display_falling_sprite")
    
menu_additem(menu"te_place_world_decal")
    
menu_additem(menu"te_create_projectile")
    
menu_additem(menu"te_create_sprite_shower")
    
menu_additem(menu"te_emit_sprite_from_player")
    
menu_additem(menu"te_create_particle_burst")
    
menu_additem(menu"te_create_fire_field")
    
menu_additem(menu"te_attach_model_to_player")
    
menu_additem(menu"te_remove_all_player_attachments")
    
menu_additem(menu"te_create_multi_gunshot")
    
menu_additem(menu"te_create_user_tracer")
    
menu_additem(menu"draw_ammo_pickup_icon")
    
menu_additem(menu"draw_weapon_pickup_icon")
    
menu_additem(menu"draw_status_icon")
    
menu_additem(menu"draw_train_controls")
    
menu_additem(menu"send_geiger_signal")
    
menu_additem(menu"hide_hud_elements")
    
menu_additem(menu"fade_user_screen")
    
menu_additem(menu"shake_user_screen")
    
menu_additem(menu"set_user_fov")
    
menu_additem(menu"cs_draw_progress_bar")
    
menu_additem(menu"cs_play_reload_sound")
    
menu_additem(menu"cs_set_hud_icon")
    
menu_additem(menu"cs_set_user_shadow")
}

public 
menuhandler(idmenuitem)
{
    if(!
is_user_connected(id))
        return

    new 
upos[3], vpos[3]
    
get_user_origin(idupos)
    
get_user_origin(idvpos3)
    
player_menu_info(idunusedunusedpage)

    switch(
item)
    {
        case 
0te_create_beam_between_points(pos1pos2beam, .rnd, .rnd, .rnd)
        case 
1te_create_beam_from_entity(ent1vposbeam, .rnd, .rnd, .rnd)
        case 
2te_create_gunshot(vpos)
        case 
3te_create_explosion(vposexplosion)
        case 
4te_create_tar_explosion(vpos)
        case 
5te_create_smoke(vpossmoke)
        case 
6te_create_tracer(uposvpos)
        case 
7te_create_beam_between_entities(ent1ent2beam, .rnd, .rnd, .rnd)
        case 
8te_create_sparks(vpos)
        case 
9te_create_lava_splash(vpos)
        case 
10te_create_teleport_splash(vpos)
        case 
11te_create_colored_explosion(vpos00)
        case 
12te_place_decal_from_bsp_file(vposrec)
        case 
13te_create_implosion(vpos)
        case 
14te_create_model_trail(uposvposball)
        case 
15te_display_additive_sprite(vposflame)
        case 
16te_create_beam_sprite(uposvposbeamflame)
        case 
17te_create_beam_ring(vposbeam, .rnd, .rnd, .rnd)
        case 
18te_create_beam_disk(vposbeam, .rnd, .rnd, .rnd)
        case 
19te_create_beam_cylinder(vposbeam, .rnd, .rnd, .rnd)
        case 
20te_create_following_beam(idbeam, .rnd, .rnd, .rnd)
        case 
21te_display_glow_sprite(vposglow)
        case 
22te_create_beam_ring_between_entities(ent1ent2beam, .rnd, .rnd, .rnd)
        case 
23te_create_tracer_shower(vpos_rnd16)
        case 
24te_create_dynamic_light(vpos, .rnd, .rnd, .rnd)
        case 
25te_create_entity_light(ent1, .rnd, .rnd, .rnd)
        case 
26te_draw_line(uposvpos, .rnd, .rnd, .rnd)
        case 
27te_create_box(uposvpos, .rnd, .rnd, .rnd)
        case 
28te_remove_all_beams_from_entity(id)
        case 
29te_create_large_funnel(vposglow)
        case 
30te_create_bloodstream(vpos, .color rnd)
        case 
31te_draw_blood_line(uposvpos)
        case 
32te_spray_blood(vpos)
        case 
33te_place_brush_decal(vposent1rec)
        case 
34te_create_bouncing_model(vposball, .bouncesound BounceSound_ShotShell)
        case 
35te_create_explode_model(vposball)
        case 
36te_create_break_model(vposball, .flags BreakModel_Flesh)
        case 
37te_place_gunshot_decal(vpos)
        case 
38te_create_sprite_spray(vposbeam)
        case 
39te_create_armor_ricochet(vpos)
        case 
40te_place_player_spray(vposid)
        case 
41te_create_bubble_box(vposvposbubbles)
        case 
42te_create_bubble_line(pos1pos2bubbles)
        case 
43te_display_falling_sprite(vposballballrndrec)
        case 
44te_place_world_decal(vposrec)
        case 
45te_create_projectile(vpos, {50,50,50}, ball)
        case 
46te_create_sprite_shower(vposflame)
        case 
47te_emit_sprite_from_player(ent1ball)
        case 
48te_create_particle_burst(vpos)
        case 
49te_create_fire_field(vposflame, .flags TEFIRE_FLAG_ALPHA)
        case 
50te_attach_model_to_player(ent1ball)
        case 
51te_remove_all_player_attachments(ent1)
        case 
52te_create_multi_gunshot(uposvpos)
        case 
53te_create_user_tracer(uposvpos2025)
        case 
54draw_ammo_pickup_icon(idrec69)
        case 
55draw_weapon_pickup_icon(idrec)
        case 
56draw_status_icon(id"d_ump45"StatusIcon_Showrndrndrnd)
        case 
57draw_train_controls(idTrainControls_Medium)
        case 
58send_geiger_signal(idrec)
        case 
59hide_hud_elements(recHideElement_Moneytrue)
        case 
60fade_user_screen(id, .rnd, .rnd, .rnd)
        case 
61shake_user_screen(id)
        case 
62set_user_fov(idrec)
        case 
63cs_draw_progress_bar(idrec)
        case 
64cs_play_reload_sound(id)
        case 
65cs_set_hud_icon(id1"d_ump45"rec42)
        case 
66cs_set_user_shadow(idrec)
    }

    new 
iname[64], unusedszunused[2]
    
menu_item_getinfo(menuitemunusedszunusedunusedinamecharsmax(iname), unused)

    
set_dhudmessage(rndrndrnd, -1.00.8500.21.00.10.1)
    
show_dhudmessage(idiname)

    if(
item != MENU_EXIT)
        
act(id)
}

public 
set(id)
{
    new 
szPlayer[32]
    
read_argv(1szPlayercharsmax(szPlayer))
    
rec str_to_num(szPlayer)
    
CromChat(id"Receiver set to &x04%i"rec)
    return 
PLUGIN_HANDLED
}

public 
set1(id)
{
    
get_user_aiming(ident1unused)

    if(
pev_valid(ent1))
        
CromChat(id"&x06Primary entity set to &x04%i"ent1)
    else
    {
        
get_user_origin(idpos13)
        
CromChat(id"&x06Primary position set at &x04%i %i %i"pos1[0], pos1[1], pos1[2])
    }

    return 
PLUGIN_HANDLED
}

public 
set2(id)
{
    
get_user_aiming(ident2unused)

    if(
pev_valid(ent2))
        
CromChat(id"&x07Secondary entity set to &x04%i"ent2)
    else
    {
        
get_user_origin(idpos23)
        
CromChat(id"&x07Secondary position set at &x04%i %i %i"pos2[0], pos2[1], pos2[2])
    }

    return 
PLUGIN_HANDLED
}

public 
switchit(id)
{
    new 
oldbeam beam
    
new oldball ball

    beam 
oldball
    ball 
oldbeam

    CromChat
(id"Switch successfull!")
    return 
PLUGIN_HANDLED

Ignore the bad coding style. The command that opens the menu is "act". Use "set1" and "set2" to change the position/entity.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
JocAnis
Veteran Member
Join Date: Jun 2010
Old 08-27-2018 , 18:17   Re: [INC] Message Stocks
Reply With Quote #4

haha this is fun. gj and thanks for making it easy to use
JocAnis is offline
shehzad1234
Senior Member
Join Date: Jan 2016
Old 09-01-2018 , 16:03   Re: [INC] Message Stocks
Reply With Quote #5

Good job.
__________________
Contact : Facebook
All Join -=}BBI{=- Hns Server :- 103.50.161.8:10001
shehzad1234 is offline
rtxa
Member
Join Date: Mar 2018
Old 09-12-2018 , 00:13   Re: [INC] Message Stocks
Reply With Quote #6

Very nice, this should be added to AMX 1.9
rtxa is offline
Relaxing
Veteran Member
Join Date: Jun 2016
Location: Catlands
Old 09-12-2018 , 06:40   Re: [INC] Message Stocks
Reply With Quote #7

Quote:
Originally Posted by rtxa View Post
Very nice, this should be added to AMX 1.9
+1
This should made into 1.9
__________________
Relaxing is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-12-2018 , 08:07   Re: [INC] Message Stocks
Reply With Quote #8

It has been requested before this thread was even posted - https://github.com/alliedmodders/amxmodx/pull/523
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 09-14-2018 , 11:45   Re: [INC] Message Stocks
Reply With Quote #9

Quote:
Originally Posted by Relaxing View Post
+1
This should made into 1.9
Guess it'll be 1.8.4 guys.
__________________
• BattleRoyale Mod
• Public PugMod
• Furien Mod

-

Currently working on Thanos vs. Avengers: 15%
EFFx is offline
Send a message via Skype™ to EFFx
JusTGo
Veteran Member
Join Date: Mar 2013
Location: Tunisia
Old 09-14-2018 , 11:47   Re: [INC] Message Stocks
Reply With Quote #10

Quote:
Originally Posted by EFFx View Post
Guess it'll be 1.8.4 guys.
i guess its 1.10
__________________
JusTGo is offline
Reply


Thread Tools
Display Modes

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 02:55.


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