AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Using write byte and such (https://forums.alliedmods.net/showthread.php?t=609)

knekter 03-28-2004 21:07

Using write byte and such
 
Right now Im trying to learn how to add effects like lightning and such, I read about write_byte, but its out of my league :oops: Im trying to make a bolt of lightning come down on top of a person every 10 seconds, Heres my code:

Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {     register_plugin("God Like Player","0.1","Knekter")     register_clcmd("say /godme","god_me",ADMIN_KICK,": gives player godmode") } public plugin_precache() {     light = precache_model("sprites/lgtning.spr")     return PLUGIN_CONTINUE } public god_me(id) {     if(!(get_user_flags(id)&ADMIN_KICK))     {         client_print(id,print_chat,"[AMXX] HAHAHA nice try!")         return PLUGIN_HANDLED     }     set_user_godmode(id,1)     new Origin[33][3]     get_user_origin(id,Origin[id])     message_begin(MSG_BROADCAST,SVC_TEMPENTITY,Origin[id],id)     write_byte(0)     write_coord(Origin[0])     write_coord(Origin[1])     write_coord(Origin[2])     write_short(light)     write_byte(1) // frame start     write_byte(5) // framerate     write_byte(2) // life     write_byte(20) // width     write_byte(30) // noise     write_byte(200) // r, g, b     write_byte(200) // r, g, b     write_byte(200) // r, g, b     write_byte(200) // brightness     write_byte(200) // speed     message_end()     set_task(10.0,"god_me",0,id,1)     return PLUGIN_CONTINUE }

I got some errors, but Its not even right. Heres the errors though:

Code:

Small compiler 2.1.0            Copyright (c) 1997-2002, ITB CompuPhase

godme.sma(12) : error 017: undefined symbol "light"
godme.sma(27) : error 035: argument type mismatch (argument 1)
godme.sma(28) : error 035: argument type mismatch (argument 1)
godme.sma(29) : error 035: argument type mismatch (argument 1)
godme.sma(30) : error 017: undefined symbol "light"
godme.sma(42) : error 035: argument type mismatch (argument 4)

6 Errors.


BAILOPAN 03-28-2004 21:24

You need to define the light variable globally in the plugin:
Code:
new light

write_byte etc are ways of constructing data packs to send to the client, they are very minimalistic... learning their ways is often just copying code examples

IceMouse[WrG] 03-29-2004 14:49

Get the SDK and open up common/const.h

knekter 03-29-2004 15:41

Where
 
Where can I get the include file......

IceMouse[WrG] 03-29-2004 17:56

It's a long list...
Code:

//
// temp entity events
//
#define        TE_BEAMPOINTS                0                // beam effect between two points
// coord coord coord (start position)
// coord coord coord (end position)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)

#define        TE_BEAMENTPOINT                1                // beam effect between point and entity
// short (start entity)
// coord coord coord (end position)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)

#define        TE_GUNSHOT                        2                // particle effect plus ricochet sound
// coord coord coord (position)

#define        TE_EXPLOSION                3                // additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps
// coord coord coord (position)
// short (sprite index)
// byte (scale in 0.1's)
// byte (framerate)
// byte (flags)
//
// The Explosion effect has some flags to control performance/aesthetic features:
#define TE_EXPLFLAG_NONE                0        // all flags clear makes default Half-Life explosion
#define TE_EXPLFLAG_NOADDITIVE        1        // sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite)
#define TE_EXPLFLAG_NODLIGHTS        2        // do not render dynamic lights
#define TE_EXPLFLAG_NOSOUND                4        // do not play client explosion sound
#define TE_EXPLFLAG_NOPARTICLES        8        // do not draw particles


#define        TE_TAREXPLOSION                4                // Quake1 "tarbaby" explosion with sound
// coord coord coord (position)

#define        TE_SMOKE                        5                // alphablend sprite, move vertically 30 pps
// coord coord coord (position)
// short (sprite index)
// byte (scale in 0.1's)
// byte (framerate)

#define        TE_TRACER                        6                // tracer effect from point to point
// coord, coord, coord (start)
// coord, coord, coord (end)

#define        TE_LIGHTNING                7                // TE_BEAMPOINTS with simplified parameters
// coord, coord, coord (start)
// coord, coord, coord (end)
// byte (life in 0.1's)
// byte (width in 0.1's)
// byte (amplitude in 0.01's)
// short (sprite model index)

#define        TE_BEAMENTS                        8               
// short (start entity)
// short (end entity)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)

#define        TE_SPARKS                        9                // 8 random tracers with gravity, ricochet sprite
// coord coord coord (position)

#define        TE_LAVASPLASH                10                // Quake1 lava splash
// coord coord coord (position)

#define        TE_TELEPORT                        11                // Quake1 teleport splash
// coord coord coord (position)

#define TE_EXPLOSION2                12                // Quake1 colormaped (base palette) particle explosion with sound
// coord coord coord (position)
// byte (starting color)
// byte (num colors)

#define TE_BSPDECAL                        13                // Decal from the .BSP file
// coord, coord, coord (x,y,z), decal position (center of texture in world)
// short (texture index of precached decal texture name)
// short (entity index)
// [optional - only included if previous short is non-zero (not the world)] short (index of model of above entity)

#define TE_IMPLOSION                14                // tracers moving toward a point
// coord, coord, coord (position)
// byte (radius)
// byte (count)
// byte (life in 0.1's)

#define TE_SPRITETRAIL                15                // line of moving glow sprites with gravity, fadeout, and collisions
// coord, coord, coord (start)
// coord, coord, coord (end)
// short (sprite index)
// byte (count)
// byte (life in 0.1's)
// byte (scale in 0.1's)
// byte (velocity along vector in 10's)
// byte (randomness of velocity in 10's)

#define TE_BEAM                                16                // obsolete

#define TE_SPRITE                        17                // additive sprite, plays 1 cycle
// coord, coord, coord (position)
// short (sprite index)
// byte (scale in 0.1's)
// byte (brightness)

#define TE_BEAMSPRITE                18                // A beam with a sprite at the end
// coord, coord, coord (start position)
// coord, coord, coord (end position)
// short (beam sprite index)
// short (end sprite index)

#define TE_BEAMTORUS                19                // screen aligned beam ring, expands to max radius over lifetime
// coord coord coord (center position)
// coord coord coord (axis and radius)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)

#define TE_BEAMDISK                        20                // disk that expands to max radius over lifetime
// coord coord coord (center position)
// coord coord coord (axis and radius)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)

#define TE_BEAMCYLINDER                21                // cylinder that expands to max radius over lifetime
// coord coord coord (center position)
// coord coord coord (axis and radius)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)

#define TE_BEAMFOLLOW                22                // create a line of decaying beam segments until entity stops moving
// short (entity:attachment to follow)
// short (sprite index)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte,byte,byte (color)
// byte (brightness)

#define TE_GLOWSPRITE                23               
// coord, coord, coord (pos) short (model index) byte (scale / 10)

#define TE_BEAMRING                        24                // connect a beam ring to two entities
// short (start entity)
// short (end entity)
// short (sprite index)
// byte (starting frame)
// byte (frame rate in 0.1's)
// byte (life in 0.1's)
// byte (line width in 0.1's)
// byte (noise amplitude in 0.01's)
// byte,byte,byte (color)
// byte (brightness)
// byte (scroll speed in 0.1's)

#define TE_STREAK_SPLASH        25                // oriented shower of tracers
// coord coord coord (start position)
// coord coord coord (direction vector)
// byte (color)
// short (count)
// short (base speed)
// short (ramdon velocity)

#define TE_BEAMHOSE                        26                // obsolete

#define TE_DLIGHT                        27                // dynamic light, effect world, minor entity effect
// coord, coord, coord (pos)
// byte (radius in 10's)
// byte byte byte (color)
// byte (brightness)
// byte (life in 10's)
// byte (decay rate in 10's)

#define TE_ELIGHT                        28                // point entity light, no world effect
// short (entity:attachment to follow)
// coord coord coord (initial position)
// coord (radius)
// byte byte byte (color)
// byte (life in 0.1's)
// coord (decay rate)

#define TE_TEXTMESSAGE                29
// short 1.2.13 x (-1 = center)
// short 1.2.13 y (-1 = center)
// byte Effect 0 = fade in/fade out
                        // 1 is flickery credits
                        // 2 is write out (training room)

// 4 bytes r,g,b,a color1        (text color)
// 4 bytes r,g,b,a color2        (effect color)
// ushort 8.8 fadein time
// ushort 8.8  fadeout time
// ushort 8.8 hold time
// optional ushort 8.8 fxtime        (time the highlight lags behing the leading text in effect 2)
// string text message                (512 chars max sz string)
#define TE_LINE                                30
// coord, coord, coord                startpos
// coord, coord, coord                endpos
// short life in 0.1 s
// 3 bytes r, g, b

#define TE_BOX                                31
// coord, coord, coord                boxmins
// coord, coord, coord                boxmaxs
// short life in 0.1 s
// 3 bytes r, g, b

#define TE_KILLBEAM                        99                // kill all beams attached to entity
// short (entity)

#define TE_LARGEFUNNEL                100
// coord coord coord (funnel position)
// short (sprite index)
// short (flags)

#define        TE_BLOODSTREAM                101                // particle spray
// coord coord coord (start position)
// coord coord coord (spray vector)
// byte (color)
// byte (speed)

#define        TE_SHOWLINE                        102                // line of particles every 5 units, dies in 30 seconds
// coord coord coord (start position)
// coord coord coord (end position)

#define TE_BLOOD                        103                // particle spray
// coord coord coord (start position)
// coord coord coord (spray vector)
// byte (color)
// byte (speed)

#define TE_DECAL                        104                // Decal applied to a brush entity (not the world)
// coord, coord, coord (x,y,z), decal position (center of texture in world)
// byte (texture index of precached decal texture name)
// short (entity index)

#define TE_FIZZ                                105                // create alpha sprites inside of entity, float upwards
// short (entity)
// short (sprite index)
// byte (density)

#define TE_MODEL                        106                // create a moving model that bounces and makes a sound when it hits
// coord, coord, coord (position)
// coord, coord, coord (velocity)
// angle (initial yaw)
// short (model index)
// byte (bounce sound type)
// byte (life in 0.1's)

#define TE_EXPLODEMODEL                107                // spherical shower of models, picks from set
// coord, coord, coord (origin)
// coord (velocity)
// short (model index)
// short (count)
// byte (life in 0.1's)

#define TE_BREAKMODEL                108                // box of models or sprites
// coord, coord, coord (position)
// coord, coord, coord (size)
// coord, coord, coord (velocity)
// byte (random velocity in 10's)
// short (sprite or model index)
// byte (count)
// byte (life in 0.1 secs)
// byte (flags)

#define TE_GUNSHOTDECAL                109                // decal and ricochet sound
// coord, coord, coord (position)
// short (entity index???)
// byte (decal???)

#define TE_SPRITE_SPRAY                110                // spay of alpha sprites
// coord, coord, coord (position)
// coord, coord, coord (velocity)
// short (sprite index)
// byte (count)
// byte (speed)
// byte (noise)

#define TE_ARMOR_RICOCHET        111                // quick spark sprite, client ricochet sound.
// coord, coord, coord (position)
// byte (scale in 0.1's)

#define TE_PLAYERDECAL                112                // ???
// byte (playerindex)
// coord, coord, coord (position)
// short (entity???)
// byte (decal number???)
// [optional] short (model index???)

#define TE_BUBBLES                        113                // create alpha sprites inside of box, float upwards
// coord, coord, coord (min start position)
// coord, coord, coord (max start position)
// coord (float height)
// short (model index)
// byte (count)
// coord (speed)

#define TE_BUBBLETRAIL                114                // create alpha sprites along a line, float upwards
// coord, coord, coord (min start position)
// coord, coord, coord (max start position)
// coord (float height)
// short (model index)
// byte (count)
// coord (speed)

#define TE_BLOODSPRITE                115                // spray of opaque sprite1's that fall, single sprite2 for 1..2 secs (this is a high-priority tent)
// coord, coord, coord (position)
// short (sprite1 index)
// short (sprite2 index)
// byte (color)
// byte (scale)

#define TE_WORLDDECAL                116                // Decal applied to the world brush
// coord, coord, coord (x,y,z), decal position (center of texture in world)
// byte (texture index of precached decal texture name)

#define TE_WORLDDECALHIGH        117                // Decal (with texture index > 256) applied to world brush
// coord, coord, coord (x,y,z), decal position (center of texture in world)
// byte (texture index of precached decal texture name - 256)

#define TE_DECALHIGH                118                // Same as TE_DECAL, but the texture index was greater than 256
// coord, coord, coord (x,y,z), decal position (center of texture in world)
// byte (texture index of precached decal texture name - 256)
// short (entity index)

#define TE_PROJECTILE                119                // Makes a projectile (like a nail) (this is a high-priority tent)
// coord, coord, coord (position)
// coord, coord, coord (velocity)
// short (modelindex)
// byte (life)
// byte (owner)  projectile won't collide with owner (if owner == 0, projectile will hit any client).

#define TE_SPRAY                        120                // Throws a shower of sprites or models
// coord, coord, coord (position)
// coord, coord, coord (direction)
// short (modelindex)
// byte (count)
// byte (speed)
// byte (noise)
// byte (rendermode)

#define TE_PLAYERSPRITES        121                // sprites emit from a player's bounding box (ONLY use for players!)
// byte (playernum)
// short (sprite modelindex)
// byte (count)
// byte (variance) (0 = no variance in size) (10 = 10% variance in size)

#define TE_PARTICLEBURST        122                // very similar to lavasplash.
// coord (origin)
// short (radius)
// byte (particle color)
// byte (duration * 10) (will be randomized a bit)

#define TE_FIREFIELD                        123                // makes a field of fire.
// coord (origin)
// short (radius) (fire is made in a square around origin. -radius, -radius to radius, radius)
// short (modelindex)
// byte (count)
// byte (flags)
// byte (duration (in seconds) * 10) (will be randomized a bit)
//
// to keep network traffic low, this message has associated flags that fit into a byte:
#define TEFIRE_FLAG_ALLFLOAT        1 // all sprites will drift upwards as they animate
#define TEFIRE_FLAG_SOMEFLOAT        2 // some of the sprites will drift upwards. (50% chance)
#define TEFIRE_FLAG_LOOP                4 // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration.
#define TEFIRE_FLAG_ALPHA                8 // if set, sprite is rendered alpha blended at 50% else, opaque
#define TEFIRE_FLAG_PLANAR                16 // if set, all fire sprites have same initial Z instead of randomly filling a cube.

#define TE_PLAYERATTACHMENT                        124 // attaches a TENT to a player (this is a high-priority tent)
// byte (entity index of player)
// coord (vertical offset) ( attachment origin.z = player origin.z + vertical offset )
// short (model index)
// short (life * 10 );

#define TE_KILLPLAYERATTACHMENTS        125 // will expire all TENTS attached to a player.
// byte (entity index of player)

#define TE_MULTIGUNSHOT                                126 // much more compact shotgun message
// This message is used to make a client approximate a 'spray' of gunfire.
// Any weapon that fires more than one bullet per frame and fires in a bit of a spread is
// a good candidate for MULTIGUNSHOT use. (shotguns)
//
// NOTE: This effect makes the client do traces for each bullet, these client traces ignore
//                entities that have studio models.Traces are 4096 long.
//
// coord (origin)
// coord (origin)
// coord (origin)
// coord (direction)
// coord (direction)
// coord (direction)
// coord (x noise * 100)
// coord (y noise * 100)
// byte (count)
// byte (bullethole decal texture index)

#define TE_USERTRACER                                127 // larger message than the standard tracer, but allows some customization.
// coord (origin)
// coord (origin)
// coord (origin)
// coord (velocity)
// coord (velocity)
// coord (velocity)
// byte ( life * 10 )
// byte ( color ) this is an index into an array of color vectors in the engine. (0 - )
// byte ( length * 10 )

Anyhow thats all the TEMPENTITYs
You use them like
Code:

message_begin(MSG_ALL,SVC_TEMPENTITY);
write_byte(/*NUMBER OF TEMP EVENT*/);
/*
* All of the things that it asks for
*/
message_end();


knekter 03-31-2004 20:01

sooo
 
So this plugin in sense, which I revised should make a lightning bolt shoot down on top if is head?

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <engine> public plugin_init() {     register_plugin("God Like Player","0.1","Knekter")     register_clcmd("say /givemegod","god_meh",ADMIN_KICK,": gives player godmode") } public god_meh(id) {     if(!(get_user_flags(id)&ADMIN_KICK))     {         client_print(id,print_chat,"[AMXX] HAHAHA nice try!")         return PLUGIN_HANDLED     }     set_user_godmode(id,1)     new UserOrigin[33][3]     get_user_origin(id,UserOrigin[id])     new light = precache_model("sprites/lgtning.spr")     message_begin( MSG_BROADCAST,SVC_TEMPENTITY)     write_byte(7) // number of temp event     write_coord(UserOrigin[id][0]) // x coord     write_coord(UserOrigin[id][1]) // y coord     write_coord(UserOrigin[id][2]) // z coord     write_coord(UserOrigin[id][0]) // x2 coord     write_coord(UserOrigin[id][1]) // y2 coord     write_coord(UserOrigin[id][2] + 10) // z2 coord     write_byte(2) // life     write_byte(5) // width     write_byte(5) // amplitude     write_short(light) // sprite index     message_end()     return PLUGIN_HANDLED }

xeroblood 03-31-2004 21:03

you got the idea!! but as far as I know, this:
Code:
new light = precache_model("sprites/lgtning.spr")

should be in:

Code:
// global new light public plugin_precache()     precache_model("sprites/lgtning.spr")

knekter 03-31-2004 21:09

wait
 
but how does the precahe get assigned to light?

BAILOPAN 03-31-2004 21:17

that should be

Code:
// global new light public plugin_precache() {     light = precache_model("sprites/lgtning.spr") }

Always put { and } braces around functions even if they are one line
It is a bad idea not to

xeroblood 04-01-2004 06:08

Re: wait
 
Quote:

Originally Posted by knekter
but how does the precahe get assigned to light?

:o I forgot to assign it to light!! lol, and I forgot brackets (actually, I was just being lazy there)... anyway, Bailopan fixed it up, use his method!!

dragonchaos 04-01-2004 07:47

Quote:

Originally Posted by IceMouse[WrG
]It's a long list...
Code:

//
// temp entity events
//
#define        TE_BEAMPOINTS                0                //
...
// byte ( length * 10 )


Thanks for this ... I've been wondering, but hesitant to ask, just so happens that someone else needed it =)


All times are GMT -4. The time now is 06:32.

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