Raised This Month: $ Target: $400
 0% 

[Help] Aim @player shows total kills?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
trehmilou
Junior Member
Join Date: Apr 2006
Old 11-25-2006 , 15:43   [Help] Aim @player shows total kills?
Reply With Quote #1

Hello,

I want to show a players' total kills in a small hudmessage when pointing at that guy.
My problem: after "Killz:" everybody seems to have the same value.

Here is my code so far:
Code:
public client_PreThink(id) {     new u_guy, body;     get_user_aiming(id, u_guy, body)     new u_stats[8]     new u_hits[8]     if (is_user_alive(u_guy))     {         get_user_stats(u_guy, u_stats, u_hits)                 set_hudmessage(10, 255, 10, 0.5, 0.55, 0, 6.0, 0.1)         show_hudmessage(id, "Killz: %i", u_stats[0])     } }

BIG THX!

@mods: sorry for all the mess :/

Last edited by trehmilou; 11-25-2006 at 15:48.
trehmilou is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 11-26-2006 , 22:56   Re: [Help] Aim @player shows total kills?
Reply With Quote #2

I don't see a reason for that code not to work, but I'd like to suggest two changes.

1. Make the body variable a global one, since you don't use it anyway, so that it is not re-created every frame.

2. Remove if_user_alive(u_guy), I don't think you can look at a dead player, I may be wrong.

Also, I don't know if you know this:
Quote:
Gets overall stats which are stored in file on server and updated on every respawn or user disconnect.
stupok is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-27-2006 , 00:08   Re: [Help] Aim @player shows total kills?
Reply With Quote #3

Quote:
Originally Posted by stupok69 View Post
2. Remove if_user_alive(u_guy), I don't think you can look at a dead player, I may be wrong.
its just a simple way to check if its a player and not a different ent or not an ent at all
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
dutchmeat
Senior Member
Join Date: Sep 2006
Old 11-27-2006 , 02:43   Re: [Help] Aim @player shows total kills?
Reply With Quote #4

Make sure you realise that the stats get's updated by respawn:
Quote:
Gets overall stats which are stored in file on server and updated on every respawn or user disconnect
Also you might want to debug u_guy...

Code:
public client_PreThink(id) {     new u_guy, body;     get_user_aiming(id, u_guy, body)     new u_stats[8]     new u_hits[8]     new name[33]     if (is_user_alive(u_guy))     {         get_user_name(id, name, 32)         set_hudmessage(10, 255, 10, 0.5, 0.55, 0, 6.0, 0.1)         show_hudmessage(id, "Players name: %s", name)     } }
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.
dutchmeat is offline
trehmilou
Junior Member
Join Date: Apr 2006
Old 11-28-2006 , 09:06   Re: [Help] Aim @player shows total kills?
Reply With Quote #5

Thx for helping me guys

- I'll make the body variable global. Won't that get inconsistent values as I point at several players? Recreating the value every time was the secure way
- I get the kill value from rank stats. Every round start the rank seems to update, so that works good so far
- Is there any other way to update the kill display, but still using rank stats? Cuz now the kills only update every round start.

I dunno know why but somehow the kill values are shown correctly for each player now. I just deleted the csstats.dat file and now everything works fine? LOL

Last edited by trehmilou; 11-28-2006 at 09:14.
trehmilou is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 11-28-2006 , 09:42   Re: [Help] Aim @player shows total kills?
Reply With Quote #6

You could count the kills youself, like i did on esf:

Code:
new kills[33] public Kills(msg_id, msg_dest, msg_entity){ //Count the kills new killer = get_msg_arg_int(1) new victim = get_msg_arg_int(2) if(killer == 0 || killer == victim || killer > 32) //first argument is the killer, 0 if worldspawn           return PLUGIN_HANDLED   kills[killer]++ //we count all the kills made return PLUGIN_CONTINUE }
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.
dutchmeat is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 11-28-2006 , 17:07   Re: [Help] Aim @player shows total kills?
Reply With Quote #7

The reason I would make the body variable global is because you don't ever make use of the data stored in that variable. If you do use that data elsewhere in the plugin, don't make it global. It's not a big deal either way, just a slight optimization.

With dutchmeat's example, hook onto the DeathMsg event.
stupok is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 11-29-2006 , 06:15   Re: [Help] Aim @player shows total kills?
Reply With Quote #8

sorry, i forgot,

Code:
register_message(get_user_msgid("DeathMsg"), "Kills")
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.
dutchmeat is offline
trehmilou
Junior Member
Join Date: Apr 2006
Old 12-01-2006 , 09:46   Re: [Help] Aim @player shows total kills?
Reply With Quote #9

Ah thx dutchmeat i'll try that.
trehmilou 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 06:57.


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