Raised This Month: $ Target: $400
 0% 

Getting headshot.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pdoubleopdawg
Senior Member
Join Date: Aug 2005
Old 08-27-2005 , 23:41   Getting headshot.
Reply With Quote #1

Hi, I'm updating my easyinfo plugin. I was trying to add headshots. (I thought it was read_data(3) in the CurWeapon event, maybe I'm wrong.)

Here's what I got, and it always displays 0 for headshots.

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> public plugin_init() {     register_plugin("Stats","0.2","Dah-Veeeed")     set_task(2.0,"the_main",0,_,_,"b")     register_event("Damage","damage_event","b","2!0","3=0","4!0")     register_cvar("amx_info","1") } new damage[33] = 0 new headshot[33] = 0 public client_putinserver(id) {     damage[id] = 0     headshot[id] = 0 } public client_disconnect(id) {     damage[id] = 0     headshot[id] = 0 } public damage_event(id) {     new attacker = get_user_attacker(id)     new dmg = read_data(2)     new hs = read_data(3)         damage[attacker] += dmg     headshot[attacker] += hs } public the_main() {     if(!get_cvar_num("amx_info")) {         return PLUGIN_HANDLED     }     new players[32],num,i     new message[200]     get_players(players,num)     for(i = 0; i <= num; i++)     {         new id = players[i]                 if(is_user_connected(id)) {             new name[33]             new ping             new loss             get_user_name(id,name,32)             new frags = get_user_frags(id)             new deaths = get_user_deaths(id)             get_user_ping(id,ping,loss)                         set_hudmessage (0,0,255, 0.01, 0.29, 0, 6.0, 2.0, 0.1, 0.2, 4 )             format(message,199," %s ^n Frags: %i ^n Deaths: %i ^n Headshots: %i ^n Total Damage: %i ^n Ping: %i",name,frags,deaths,headshot[id],damage[id],ping)             show_hudmessage(id,message)         }     }     return PLUGIN_CONTINUE }
pdoubleopdawg is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 08-27-2005 , 23:47  
Reply With Quote #2

http://amxmodx.org/funcwiki.php?go=func&id=147
__________________
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
Zenith77
Veteran Member
Join Date: Aug 2005
Old 08-27-2005 , 23:53  
Reply With Quote #3

Use this as a guide....


add this to plugin init

Code:
register_event( "DeathMsg", "death", "b" )

add this to the bottom

Code:
   public death(id) {    new weapon    new hitzone    new attacker    get_user_attacker( attacker, weapon, hitzone)     if( hitzone == 3 ) { // hitzone will return 3 if it was a hs!  //bla bla bla     } }

Rember you can use the code..just put it in the proper place...i too tired to tell you right now :/
[/small]
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-27-2005 , 23:55  
Reply With Quote #4

Code:
new weapon, hitzone, attacker = get_user_attacker(id,weapon,hitzone); if(hitzone == HIT_HEAD) {     // headshot }

EDIT: Just saw Zenith's code which is similar to mine but sucks. a) don't need three lines for three variables, b) you can't get the attacker of a non-existant player, c) using defines is much more human-readable than pure numbers
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 08-27-2005 , 23:59  
Reply With Quote #5

hehe..whoops...made to many errors..i half asleep right now :/
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
pdoubleopdawg
Senior Member
Join Date: Aug 2005
Old 08-28-2005 , 00:01  
Reply With Quote #6

This makes it not show up..
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> public plugin_init() {     register_plugin("Stats","0.2","Dah-Veeeed")     set_task(2.0,"the_main",0,_,_,"b")     register_event("Damage","death","b","2!0","3=0","4!0")     register_cvar("amx_info","1") } new damage[33]=0 new headshot[33]=0 public client_putinserver(id) {     damage[id] = 0     headshot[id] = 0 } public client_disconnect(id) {     damage[id]=0     headshot[id]=0 } public damage_event(id)     {     new dmg = read_data(2)         new weapon, hitzone, attacker = get_user_attacker(id,weapon,hitzone);     if(hitzone == HIT_HEAD) {         headshot[id]++     }       damage[attacker] += dmg } public the_main(id) { if(is_user_connected(id)) {     if(!get_cvar_num("amx_info")) {         return PLUGIN_HANDLED     }         new players[32],num,i     new message[200]     get_players(players,num)     for(i = 0; i <= num; i++)         {         new id = players[i]                 if(is_user_connected(id)) {             new name[33]             new ping             new loss             get_user_name(id,name,32)             new frags = get_user_frags(id)             new deaths = get_user_deaths(id)             get_user_ping(id,ping,loss)                         set_hudmessage (0,0,255, 0.01, 0.29, 0, 6.0, 2.0, 0.1, 0.2, 4 )             format(message,199," %s ^n Frags: %i ^n Deaths: %i ^n Headshots: %i ^n Total Damage: %i ^n Ping: %i",name,frags,deaths,headshot[id],damage[id],ping)             show_hudmessage(id,message)         }     } } return PLUGIN_CONTINUE }
pdoubleopdawg is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 08-28-2005 , 00:50  
Reply With Quote #7

cuz the way you have it your adding one headshot to the person who got shot not the attacker.

so change
Code:
headshot[id]++
to
Code:
headshot[attacker]++
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
pdoubleopdawg
Senior Member
Join Date: Aug 2005
Old 08-28-2005 , 00:53  
Reply With Quote #8

Still nothing -- the whole damn hud message doesnt show. (the pluggie is running tho)
pdoubleopdawg is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 08-28-2005 , 00:55  
Reply With Quote #9

Code:
    new weapon, hitzone, attacker = get_user_attacker(id,weapon,hitzone);     if(hitzone == HIT_HEAD) {         headshot[id]++     }

thats the lines i was refering too which you still left.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
pdoubleopdawg
Senior Member
Join Date: Aug 2005
Old 08-28-2005 , 00:57  
Reply With Quote #10

Oh, Well thanks [v3x pointed it out to me on AIM too, though.]
pdoubleopdawg 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 14:18.


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