Raised This Month: $51 Target: $400
 12% 

Playing A Model's Sequence


Post New Thread Reply   
 
Thread Tools Display Modes
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 08-22-2005 , 22:45  
Reply With Quote #21

Sometimes posting the whole code is best.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 08-22-2005 , 23:34  
Reply With Quote #22

Quote:
Originally Posted by v3x
Sometimes posting the whole code is best.
That is most of the model spawning part. There is nothing else dealing with the model spawning, only other things are model and user interaction and toggle plugin on and off.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
knekter
Senior Member
Join Date: Mar 2004
Location: PA
Old 08-22-2005 , 23:47   hmm
Reply With Quote #23

Ok I have been experimenting with this lately, I have created a mod that adds in the Displacer Gun from Opposing forces. I was able to play the animations for the weapons when they are firing/reloading/idleing/ect. I also noticed that setting it once won't work. I needed to constantly set it either in server frame or prethink. I used prethink. Here is my code and what I have so far, not many intentions to finish it:

Code:
#include <amxmodx> #include <engine> #include <fakemeta> #define SEQ_IDLE    0 #define SEQ_CHARGE  2 #define SEQ_FIRE    4 // All the CS Standard knife sounds new const g_szKnifeSnd[9][] = {     "weapons/knife_deploy1.wav",     "weapons/knife_hit1.wav",     "weapons/knife_hit2.wav",     "weapons/knife_hit3.wav",     "weapons/knife_hit4.wav",     "weapons/knife_hitwall1.wav",     "weapons/knife_slash1.wav",     "weapons/knife_slash2.wav",     "weapons/knife_stab.wav" } new g_iSequence[33]  // Current sequence your weapon is in new g_sprGlow, g_sprSmoke   // Sprites public plugin_init() {     register_plugin("Displacer Cannon", "0.1", "Knekter")     register_event("CurWeapon", "WeaponChange", "be")     register_forward(FM_SetModel, "SetModel")     register_forward(FM_EmitSound, "EmitSound") } public plugin_precache() {     precache_model("models/v_displacer.mdl")     precache_model("models/p_displacer.mdl")     precache_model("models/w_displacer.mdl")     precache_sound("weapons/displacer_spin.wav")     precache_sound("weapons/displacer_fire.wav")     g_sprGlow = precache_model("sprites/glow04.spr")     g_sprSmoke = precache_model("sprites/smoke.spr") } public WeaponChange(id) {     new iWeap = read_data(2)     if(iWeap == 29)     {         entity_set_string(id, EV_SZ_viewmodel, "models/v_displacer.mdl")         entity_set_string(id, EV_SZ_weaponmodel, "models/p_displacer.mdl")     } } public EmitSound(entity, channel, const sound[]) {     for(new iSnd = 0; iSnd < 8; iSnd++)     {         if(containi(sound, g_szKnifeSnd[iSnd]) != -1)             return FMRES_SUPERCEDE     }     return FMRES_IGNORED } public client_PreThink(id) {     new iClip, iAmmo     new iWeap = get_user_weapon(id, iClip, iAmmo)     if(iWeap == 29)     {         if(g_iSequence[id] == SEQ_CHARGE)             entity_set_int(id, EV_INT_weaponanim, SEQ_CHARGE)         else if(g_iSequence[id] == SEQ_FIRE)             entity_set_int(id, EV_INT_weaponanim, SEQ_FIRE)         else if(g_iSequence[id] == SEQ_IDLE)             entity_set_int(id, EV_INT_weaponanim, SEQ_IDLE)         if((get_user_button(id) & IN_ATTACK) && !(get_user_oldbutton(id) & IN_ATTACK) && !task_exists(id + 57455))         {             new param[1]             param[0] = id             client_cmd(id, "spk ^"%s^"", "weapons/displacer_spin.wav")             set_task(1.0, "FireDisplacer", id + 57455, param, 1)             g_iSequence[id] = SEQ_CHARGE         }     }     return PLUGIN_CONTINUE } public FireDisplacer(param[1]) {     new id = param[0]     g_iSequence[id] = SEQ_FIRE     client_cmd(id, "spk ^"%s^"", "weapons/displacer_fire.wav")     new entity = create_entity("info_target")     if(entity > 0)     {         new Float:Origin[3], Float:Velocity[3], Float:Angle[3]         entity_set_string(entity, EV_SZ_classname, "energy_ball")         entity_get_vector(id, EV_VEC_origin, Origin)         Origin[2] += 12.0         entity_set_origin(entity, Origin)         entity_set_size(entity, Float:{-1.0, -1.0, -1.0}, Float:{1.0, 1.0, 1.0})         entity_set_int(entity, EV_INT_solid, 2)         entity_set_int(entity, EV_INT_movetype, 5)         entity_set_edict(entity, EV_ENT_owner, id)         velocity_by_aim(id, 500, Velocity)         vector_to_angle(Velocity, Angle)         entity_set_vector(entity, EV_VEC_angles, Angle)         entity_set_vector(entity, EV_VEC_velocity, Velocity)         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)         write_byte(22)         write_short(entity)         write_short(g_sprSmoke)         write_byte(10)         write_byte(5)         write_byte(255)         write_byte(156)         write_byte(0)         write_byte(255)         message_end()         new param2[2]         param[0] = id         param2[1] = entity         set_task(0.1, "EnergyEffect", id + 49734, param2, 1, "b")     }     set_task(0.9, "IdleDisplacer", id)     return PLUGIN_CONTINUE } public EnergyEffect(param2[1]) {     new entity = param2[0]     if(is_valid_ent(entity))     {         new Float:fOrigin[3], Origin[3]         entity_get_vector(entity, EV_VEC_origin, fOrigin)         FVecIVec(fOrigin, Origin)         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)         write_byte(17)         write_coord(Origin[0])         write_coord(Origin[1])         write_coord(Origin[2])         write_short(g_sprGlow)         write_byte(10)         write_byte(150)         message_end()     }     return PLUGIN_CONTINUE } public IdleDisplacer(id) {     g_iSequence[id] = SEQ_IDLE } public pfn_touch(ptr, ptd) {     if(ptr > 0 && ptd >= 0)     {         new pToucher[33]         entity_get_string(ptr, EV_SZ_classname, pToucher, 32)         if(equal(pToucher, "energy_ball"))         {             new Float:fOrigin[3], Origin[3]             entity_get_vector(ptr, EV_VEC_origin, fOrigin)             FVecIVec(fOrigin, Origin)             /*message_begin(MSG_BROADCAST, SVC_TEMPENTITY)             write_byte(27)             write_coord(Origin[0])             write_coord(Origin[1])             write_coord(Origin[2])             write_byte(200)             write_byte(255)             write_byte(255)             write_byte(255)             write_byte(200)             write_byte(5)             write_byte(10)             message_end()             message_begin(MSG_BROADCAST, SVC_TEMPENTITY)             write_byte(14)             write_coord(Origin[0])             write_coord(Origin[1])             write_coord(Origin[2])             write_byte(100)             write_byte(100)             write_byte(10)             message_end()*/             new param[4]             param[0] = Origin[0]             param[1] = Origin[1]             param[2] = Origin[2]             param[3] = entity_get_edict(ptr, EV_ENT_owner)             remove_task(entity_get_edict(ptr, EV_ENT_owner) + 49734)             set_task(0.8, "DetonateBall", ptr + 75665, param, 4)             remove_entity(ptr)         }     }     return PLUGIN_CONTINUE } public DetonateBall(param[4]) {     return PLUGIN_CONTINUE }

I guess some day I will finish this up/ change the energy ball effect.
__________________
More updates for Matrix Mod!
knekter is offline
Send a message via AIM to knekter Send a message via MSN to knekter
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-23-2005 , 00:22  
Reply With Quote #24

Quote:
Originally Posted by GHW_Chronic
Code:
#define	SOLID_BBOX		2
#define	MOVETYPE_FLY	5

ent[i] = create_entity("info_target")
entity_set_string(ent,EV_SZ_classname,"ghw_health")
entity_set_model(ent,"models/ghw_health.mdl")
entity_set_origin(ent,origina)
entity_set_int(ent, EV_INT_solid,2)
entity_set_int(ent,EV_INT_movetype,5)
entity_set_int(ent,EV_INT_sequence,0)
entity_set_edict(ent,EV_ENT_owner,33)
entity_set_size(ent,mina,maxa)
Thats the main part of the script. mina, maxa, origina are already defined variables. Model is precached, model works and player can touch the object, object floats in air at the origin supplied. Just need the sequence part to work.
Why do you define variables and not use the define? Do you not understand the point of defines and how they work? Also, try adding this to your creation code:

Code:
entity_set_float(ent,EV_FL_framerate,1.5);
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 08-23-2005 , 00:23  
Reply With Quote #25

kneter helped me out, i've got it covered, thanks for all ur help
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 08-23-2005 , 00:40  
Reply With Quote #26

Quote:
Originally Posted by GHW_Chronic
Code:
#define	SOLID_BBOX		2
#define	MOVETYPE_FLY	5

ent[i] = create_entity("info_target")
entity_set_string(ent,EV_SZ_classname,"ghw_health")
entity_set_model(ent,"models/ghw_health.mdl")
entity_set_origin(ent,origina)
entity_set_int(ent, EV_INT_solid,2)
entity_set_int(ent,EV_INT_movetype,5)
entity_set_int(ent,EV_INT_sequence,0)
entity_set_edict(ent,EV_ENT_owner,33)
entity_set_size(ent,mina,maxa)
Thats the main part of the script. mina, maxa, origina are already defined variables. Model is precached, model works and player can touch the object, object floats in air at the origin supplied. Just need the sequence part to work.
you create your entity like this
ent[i] = create_entity("info_target")
And then input ur entities ID like this
entity_set_origin(ent,origina)

what happend to the [i]
Freecode is offline
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 08-23-2005 , 00:42  
Reply With Quote #27

i changed the code a bit on the rest of the lines to get rid of the "[i]" to make it less confusing for you while reading the post, missed that line...
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
Reply



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 20:38.


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