Raised This Month: $ Target: $400
 0% 

The Specialists - Brass Knuckles (Melee_Attack Usage)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Calimaw
Junior Member
Join Date: Dec 2006
Old 12-31-2006 , 03:02   The Specialists - Brass Knuckles (Melee_Attack Usage)
Reply With Quote #1

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <tsx> #include <tsfun> #define PLUGIN "Brass Knuckles" #define VERSION "1.0" #define AUTHOR "Calimaw" new bool:g_brassknuckles[33] public plugin_init() {  register_plugin(PLUGIN, VERSION, AUTHOR)  register_clcmd("say /brassknuckles", "cmdBrassKnuckles") } public client_connect(id) g_brassknuckles[id] = false public Event_Death() g_brassknuckles[read_data(2)] = false   public cmdBrassKnuckles(id) {         if(!is_user_alive(id))                 client_print(id, print_chat, "The dead cannot buy items!")         else if(g_brassknuckles[id])                 client_print(id, print_chat, "What good would that do?")         else         {                 g_brassknuckles[id] = true                 client_print(id, print_chat, "You bought a pair of brass knuckles!")         }         return PLUGIN_HANDLED } public Melee_Attack (id, Float:time, Float:damage) {  client_print(id, print_chat, "You attack like viper! Rrrrr")  return PLUGIN_CONTINUE }

The above code is the begining of my very first plugin, and I'm still very terrible

The portion that doesnt work thus far is the very bottom block, at public Melee_Attack.

What it should do is display the message "You attack like viper! Rrrrrr!" (for testing) when using Kung Fu, and when you have the brass knuckles.

Currently I was just trying to get it to work with ANY melee attack regardless of knuckles or not, and I cant even get that working.

Last edited by Calimaw; 12-31-2006 at 05:37.
Calimaw is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 12-31-2006 , 04:08   Re: The Specialists - Brass Knuckles (Melee_Attack Usage)
Reply With Quote #2

Here's the progress I've made so far. It displays the message (5 times, anyone know why?) when the user presses the attack button and is using Kung Fu.

Code:
#include <amxmodx> #include <fakemeta> #include <tsfun> #define PLUGIN "Brass Knuckles" #define VERSION "1.0" #define AUTHOR "Calimaw/stupok69" new bool:g_brassknuckles[33] new bool:g_is_in_kungfu[33] public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_message(get_user_msgid("WeaponInfo"), "WeaponInfo_function")         register_forward(FM_PlayerPreThink, "PlayerPreThink")         register_clcmd("say /brassknuckles", "cmdBrassKnuckles") } public client_connect(id) {     g_brassknuckles[id] = false     g_is_in_kungfu[id] = true } public Event_Death() {     new id = read_data(2)     g_brassknuckles[id] = false     g_is_in_kungfu[id] = true } public WeaponInfo_function(msg_id, msg_dest, msg_entity) {     if(!get_msg_arg_int(1))     {         g_is_in_kungfu[msg_dest] = true     }     else     {         g_is_in_kungfu[msg_dest] = false     } }   public cmdBrassKnuckles(id) {         if(!is_user_alive(id))                 client_print(id, print_chat, "The dead cannot buy items!")         else if(g_brassknuckles[id])                 client_print(id, print_chat, "What good would that do?")         else         {                 g_brassknuckles[id] = true                 client_print(id, print_chat, "You bought a pair of brass knuckles!")         }         return PLUGIN_HANDLED } public PlayerPreThink(id) {     if(!is_user_alive(id))         return FMRES_IGNORED         if(pev(id,pev_button) & IN_ATTACK && g_is_in_kungfu[id])     {         client_print(id, print_chat, "You attack like viper! Rrrrr")     }         return FMRES_HANDLED }

Last edited by stupok; 12-31-2006 at 04:18.
stupok is offline
Calimaw
Junior Member
Join Date: Dec 2006
Old 12-31-2006 , 05:04   Re: The Specialists - Brass Knuckles (Melee_Attack Usage)
Reply With Quote #3

As to why it says it 5 times, Im not sure, but my first stab at it would be that the attack is repeated 4 times during its life time? Like if you strike at a wall with some one behind you, and you turn quickly enough, it will catch them too.

EDIT: Found out what it is. It's when you hold the button down it keeps repeating.

I don't know how to fix that yet, but I fixed a few other things.

Code:
#include <amxmodx> #include <fakemeta> #include <tsfun> #define PLUGIN "Brass Knuckles" #define VERSION "1.0" #define AUTHOR "Calimaw/stupok69" new bool:g_brassknuckles[33] new bool:g_is_in_kungfu[33] public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_message(get_user_msgid("WeaponInfo"), "WeaponInfo_function") ///////////////////////// register_event("DeathMsg", "Event_Death", "a") ///////////////////////// register_forward(FM_PlayerPreThink, "PlayerPreThink") register_clcmd("say /brassknuckles", "cmdBrassKnuckles") } public client_connect(id) { g_brassknuckles[id] = false g_is_in_kungfu[id] = true } public Event_Death() { new id = read_data(2) g_brassknuckles[id] = false g_is_in_kungfu[id] = true } public WeaponInfo_function(msg_id, msg_dest, msg_entity) { if(!get_msg_arg_int(1)) { g_is_in_kungfu[msg_dest] = true } else { g_is_in_kungfu[msg_dest] = false } }   public cmdBrassKnuckles(id) { if(!is_user_alive(id)) client_print(id, print_chat, "The dead cannot buy items!") else if(g_brassknuckles[id]) client_print(id, print_chat, "What good would that do?") else { g_brassknuckles[id] = true client_print(id, print_chat, "You bought a pair of brass knuckles!") } return PLUGIN_HANDLED } public PlayerPreThink(id) { if(!is_user_alive(id)) return FMRES_IGNORED /////////////////////////// else if(!g_brassknuckles[id]) return FMRES_IGNORED ///////////////////////////   if(pev(id,pev_button) & IN_ATTACK && g_is_in_kungfu[id]) { client_print(id, print_chat, "You attack like viper! Rrrrr") }   return FMRES_HANDLED }

Last edited by Calimaw; 12-31-2006 at 05:35.
Calimaw is offline
Calimaw
Junior Member
Join Date: Dec 2006
Old 12-31-2006 , 06:10   Re: The Specialists - Brass Knuckles (Melee_Attack Usage)
Reply With Quote #4

Code:
#include <amxmodx> #include <fakemeta> #include <tsfun> #define PLUGIN "Brass Knuckles" #define VERSION "1.0" #define AUTHOR "Calimaw/stupok69" new bool:g_brassknuckles[33] new bool:g_is_in_kungfu[33] public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_message(get_user_msgid("WeaponInfo"), "WeaponInfo_function")     register_event("DeathMsg", "Event_Death", "a")     register_forward(FM_PlayerPreThink, "PlayerPreThink")     register_clcmd("say /brassknuckles", "cmdBrassKnuckles")     register_forward(FM_EmitSound, "EmitSound") } public plugin_precache() {         precache_sound("bknuckles/hit_01.wav")         precache_sound("bknuckles/swing_01.wav") } public client_connect(id) {     g_brassknuckles[id] = false     g_is_in_kungfu[id] = true } public Event_Death() {     new id = read_data(2)     g_brassknuckles[id] = false     g_is_in_kungfu[id] = true } public WeaponInfo_function(msg_id, msg_dest, msg_entity) {     if(!get_msg_arg_int(1))     {         g_is_in_kungfu[msg_dest] = true     }     else     {         g_is_in_kungfu[msg_dest] = false     } }   public cmdBrassKnuckles(id) {         if(!is_user_alive(id))                 client_print(id, print_chat, "The dead cannot buy items!")         else if(g_brassknuckles[id])                 client_print(id, print_chat, "What good would that do?")         else         {                 g_brassknuckles[id] = true                 client_print(id, print_chat, "You bought a pair of brass knuckles!")         }         return PLUGIN_HANDLED } public PlayerPreThink(id) {     if(!is_user_alive(id))         return FMRES_IGNORED     else if(!g_brassknuckles[id])         return FMRES_IGNORED         if(pev(id,pev_button) & IN_ATTACK && g_is_in_kungfu[id])     {         client_print(id, print_chat, "You attack like viper! Rrrrr")     }         return FMRES_HANDLED } public EmitSound(id, channel, sample[]) {  if(!is_user_alive(id))   return FMRES_IGNORED  {   if(g_brassknuckles[id])   {    if(equal(sample,"player/kungfuhit.wav"))    {     emit_sound(id, CHAN_WEAPON, "bknuckles/hit_01.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)     return FMRES_SUPERCEDE    }    else if(equal(sample,"player/closecombat.wav"))    {     emit_sound(id, CHAN_WEAPON, "bknuckles/swing_01.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)     return FMRES_SUPERCEDE    }   }  }  return FMRES_IGNORED }

Made some more problems to solve, Im using Cheap_Suits CS Brass Knuckls plugin as a refference point to learn from, but alot of it is useless towards TS due to the differences in the mods, so If his isnt the correct way for TS, I dont know which is. This script won't compile on lines 85-86, I don't know what the error means.
Calimaw is offline
|POW|Da_ghost
Senior Member
Join Date: Nov 2006
Location: http://snarkcafe.net
Old 12-31-2006 , 10:11   Re: The Specialists - Brass Knuckles (Melee_Attack Usage)
Reply With Quote #5

Well the error is because you had 2 extra "{" so here is the new one.
Code:
#include <amxmodx> #include <fakemeta> #include <tsfun> #define PLUGIN "Brass Knuckles" #define VERSION "1.0" #define AUTHOR "Calimaw/stupok69" new bool:g_brassknuckles[33] new bool:g_is_in_kungfu[33] public plugin_init() {  register_plugin(PLUGIN, VERSION, AUTHOR)  register_message(get_user_msgid("WeaponInfo"), "WeaponInfo_function")  register_event("DeathMsg", "Event_Death", "a")  register_forward(FM_PlayerPreThink, "PlayerPreThink")  register_clcmd("say /brassknuckles", "cmdBrassKnuckles")  register_forward(FM_EmitSound, "EmitSound") } public plugin_precache() {  precache_sound("bknuckles/hit_01.wav")  precache_sound("bknuckles/swing_01.wav") } public client_connect(id) {  g_brassknuckles[id] = false  g_is_in_kungfu[id] = true } public Event_Death() {  new id = read_data(2)  g_brassknuckles[id] = false  g_is_in_kungfu[id] = true } public WeaponInfo_function(msg_id, msg_dest, msg_entity) {  if(!get_msg_arg_int(1))  {   g_is_in_kungfu[msg_dest] = true  }  else  {   g_is_in_kungfu[msg_dest] = false  } } public cmdBrassKnuckles(id) {  if(!is_user_alive(id))   client_print(id, print_chat, "The dead cannot buy items!")  else if(g_brassknuckles[id])   client_print(id, print_chat, "What good would that do?")  else  {   g_brassknuckles[id] = true   client_print(id, print_chat, "You bought a pair of brass knuckles!")  }  return PLUGIN_HANDLED } public PlayerPreThink(id) {  if(!is_user_alive(id))   return FMRES_IGNORED  else if(!g_brassknuckles[id])   return FMRES_IGNORED    if(pev(id,pev_button) & IN_ATTACK && g_is_in_kungfu[id])  {   client_print(id, print_chat, "You attack like viper! Rrrrr")  }    return FMRES_HANDLED } public EmitSound(id, channel, sample[]) {  if(!is_user_alive(id))   return FMRES_IGNORED    if(g_brassknuckles[id])  {   if(equal(sample,"player/kungfuhit.wav"))   {    emit_sound(id, CHAN_WEAPON, "bknuckles/hit_01.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)    return FMRES_SUPERCEDE   }   else if(equal(sample,"player/closecombat.wav"))   {    emit_sound(id, CHAN_WEAPON, "bknuckles/swing_01.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)    return FMRES_SUPERCEDE   }  }  return FMRES_IGNORED }
__________________
If you want me to help you with something please contact me on msn or xfire(Daghost1337)
|POW|Da_ghost is offline
Send a message via AIM to |POW|Da_ghost Send a message via MSN to |POW|Da_ghost
Old 12-31-2006, 11:23
Hawk552
This message has been deleted by sawce the snail. Reason: thread derailment
Old 12-31-2006, 13:22
Calimaw
This message has been deleted by sawce the snail. Reason: thread derailment
Old 12-31-2006, 13:36
Hawk552
This message has been deleted by sawce the snail. Reason: thread derailment
Calimaw
Junior Member
Join Date: Dec 2006
Old 12-31-2006 , 14:05   Re: The Specialists - Brass Knuckles (Melee_Attack Usage)
Reply With Quote #9

Code:
#include <amxmodx> #include <fakemeta> #include <tsfun> #define PLUGIN "Brass Knuckles" #define VERSION "1.0" #define AUTHOR "Calimaw/stupok69" new bool:g_brassknuckles[33] new bool:g_is_in_kungfu[33] public plugin_init() {  register_plugin(PLUGIN, VERSION, AUTHOR)  register_message(get_user_msgid("WeaponInfo"), "WeaponInfo_function")  register_event("DeathMsg", "Event_Death", "a")  register_forward(FM_PlayerPreThink, "PlayerPreThink")  register_clcmd("say /brassknuckles", "cmdBrassKnuckles")  register_forward(FM_EmitSound, "EmitSound") } public plugin_precache() {  precache_sound("bknuckles/hit_01.wav")  precache_sound("bknuckles/swing_01.wav") } public client_connect(id) {  g_brassknuckles[id] = false  g_is_in_kungfu[id] = true } public Event_Death() {  new id = read_data(2)  g_brassknuckles[id] = false  g_is_in_kungfu[id] = true } public WeaponInfo_function(msg_id, msg_dest, msg_entity) {  if(!get_msg_arg_int(1))  {   g_is_in_kungfu[msg_dest] = true  }  else  {   g_is_in_kungfu[msg_dest] = false  } } public cmdBrassKnuckles(id) {  if(!is_user_alive(id))   client_print(id, print_chat, "The dead cannot buy items!")  else if(g_brassknuckles[id])   client_print(id, print_chat, "What good would that do?")  else  {   g_brassknuckles[id] = true   client_print(id, print_chat, "You bought a pair of brass knuckles!")  }  return PLUGIN_HANDLED } public PlayerPreThink(id) {  if(!is_user_alive(id))   return FMRES_IGNORED  else if(!g_brassknuckles[id])   return FMRES_IGNORED    if(pev(id,pev_button) & IN_ATTACK && g_is_in_kungfu[id])  {   client_print(id, print_chat, "You attack like viper! Rrrrr")  }    return FMRES_HANDLED } public EmitSound(id, channel, sample[]) {  if(!is_user_alive(id))   return FMRES_IGNORED    if(g_brassknuckles[id])  {   if(equal(sample,"player/kungfuhit.wav"))   {    emit_sound(id, CHAN_WEAPON, "bknuckles/hit_01.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)    client_print(id, print_chat, "Hit Sound!")    return FMRES_SUPERCEDE   }   else if(equal(sample,"player/closecombat.wav"))   {    emit_sound(id, CHAN_WEAPON, "bknuckles/swing_01.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)    client_print(id, print_chat, "Swing Sound!")    return FMRES_SUPERCEDE   }  }  return FMRES_IGNORED }

Okay, thanks to Da_Ghost the sounds play, but heres the kicker.

When you get hit by kung_fu or have hit some one, the sound emits from that player, so, whats going on is when I type /brassknuckles and get hit I will emit the sound. The sound that does not play at all currently is the swing sound.

I need to change it so that If the victim is hit by a player with the brass knuckles both players hear the new sound, as well as if the player has brass knuckles they need to emit the swing sound regardless of hitting or not.
Calimaw is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 12-31-2006 , 18:21   Re: The Specialists - Brass Knuckles (Melee_Attack Usage)
Reply With Quote #10

"player/kungfuhit.wav" passes through the EmitSound() function, but "player/closecombat.wav" does not. So you won't be able to change it, unfortunately. At least not with the fakemeta method; there may be some other method I'm not aware of. I'd wager it's client-side, and therefore untouchable.

You might be able to catch in prethink if a client has pushed the attack button and then check if an entity lost health, but that may not work and might be a bit hard to figure out...

Anyways, I played around with the code and changed a few things. I used the method from one of my other plugins to make the victim of the punch be knocked back when you hit him with brass knuckles, and the knuckles will do damage twice, meaning you do twice the amount of damage of a normal punch. I didn't bother replacing sounds, because I don't have your brass knuckles sound effects and you could only replace kungfuhit anyways.

I left code in there so you could see for yourself exactly what sound effects are passing through the function. Compiles fine, no errors.

I think the knock-back is entertaining enough.

Code:
#include <amxmodx> #include <fakemeta> #include <fun> #include <tsfun> #define PLUGIN "Brass Knuckles" #define VERSION "1.0" #define AUTHOR "Calimaw/stupok69" new bool:g_brassknuckles[33] new bool:g_is_in_kungfu[33] new g_damage public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_message(get_user_msgid("WeaponInfo"), "WeaponInfo_function")     register_event("PTakeDam", "PTakeDam_function", "a")     register_message(50, "killer_victim_function")         register_forward(FM_EmitSound, "EmitSound")         register_clcmd("say /brassknuckles", "cmdBrassKnuckles") } public client_connect(id) {     g_brassknuckles[id] = false     g_is_in_kungfu[id] = true } public Event_Death() {     new id = read_data(2)     g_brassknuckles[id] = false     g_is_in_kungfu[id] = true } public WeaponInfo_function(msg_id, msg_dest, msg_entity) {     if(!get_msg_arg_int(1))     {         g_is_in_kungfu[msg_dest] = true     }     else     {         g_is_in_kungfu[msg_dest] = false     } } public PTakeDam_function() {     g_damage = read_data(7) } public killer_victim_function(msg_id, msg_dest, msg_entity) {     new victim = get_msg_arg_int(2)     new killer = get_msg_arg_int(3)         if(!is_user_alive(killer)) return PLUGIN_HANDLED         new Float:aimvelocity[3]         if(g_brassknuckles[killer])     {         velocity_by_aim(killer, g_damage * 100, aimvelocity)         set_pev(victim, pev_velocity, aimvelocity)                 new health = get_user_health(victim)         if(health - g_damage >= 0)         {             set_user_health(victim, health-g_damage)         }     }     return PLUGIN_HANDLED } public cmdBrassKnuckles(id) {     if(!is_user_alive(id))         client_print(id, print_chat, "The dead cannot buy items!")     else if(g_brassknuckles[id])         client_print(id, print_chat, "What good would that do?")     else     {         g_brassknuckles[id] = true         client_print(id, print_chat, "You bought a pair of brass knuckles!")     }     return PLUGIN_HANDLED } public EmitSound(id, channel, sample[]) {     /*     if(!is_user_alive(id))         return FMRES_IGNORED     */     new name[32]     get_user_name(id, name, 31)     if(contain(sample, "spark") == -1)     {         client_print(0, print_chat, "%s %s", name, sample)     }     /*     if(g_brassknuckles[id])     {         if(equal(sample,"player/kungfuhit.wav"))         {             emit_sound(id, CHAN_WEAPON, "bknuckles/hit_01.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)             client_print(id, print_chat, "Hit Sound!")             return FMRES_SUPERCEDE         }         else if(equal(sample,"player/closecombat.wav"))         {             emit_sound(id, CHAN_WEAPON, "bknuckles/swing_01.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)             client_print(id, print_chat, "Swing Sound!")             return FMRES_SUPERCEDE         }     }     */     return FMRES_IGNORED }
stupok is offline
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 22:22.


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