AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting headshot. (https://forums.alliedmods.net/showthread.php?t=17236)

pdoubleopdawg 08-27-2005 23:41

Getting headshot.
 
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 }

v3x 08-27-2005 23:47

http://amxmodx.org/funcwiki.php?go=func&id=147

Zenith77 08-27-2005 23:53

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]

XxAvalanchexX 08-27-2005 23:55

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

Zenith77 08-27-2005 23:59

hehe..whoops...made to many errors..i half asleep right now :/

pdoubleopdawg 08-28-2005 00:01

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 }

Xanimos 08-28-2005 00:50

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]++

pdoubleopdawg 08-28-2005 00:53

Still nothing -- the whole damn hud message doesnt show. (the pluggie is running tho)

Xanimos 08-28-2005 00:55

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.

pdoubleopdawg 08-28-2005 00:57

Oh, Well thanks [v3x pointed it out to me on AIM too, though.]


All times are GMT -4. The time now is 14:18.

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