AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Headshot counter (https://forums.alliedmods.net/showthread.php?t=3828)

hellraser 07-15-2004 19:58

Headshot counter
 
well well,i know how to get user frags but how would i get the number of headshots the user made?
like
if HS >= 50% of Frags would display a message otherwise nothing...

Thx ?[/code]

Ryan 07-15-2004 21:38

you'd need to make a death event that stores all player's headshot kills in a global variable. like so.

Code:
#define HEADSHOT_RATIO 0.50 new g_iHeadshots[33]; // Death event public Ev_Death() {     new kId = read_data( 1 );    // Killer Index     new iHeadshot = read_data( 3 );     if ( iHeadshot )         g_iHeadshots[kId] += 1;     // Display message if headshots > HEADSHOT_RATIO     new iKills = get_user_frags( kId );     new Float:fRatio = float( g_iHeadshots[kId] ) / float( iKills );     if ( fRatio >= HEADSHOT_RATIO )     {         new szMessage[64];         format( szMessage, 63, "%0.0f%s of your kills are headshots!", fRatio * 100.0, "%%" );         // display this message however you need.     }         return PLUGIN_CONTINUE; } public plugin_init() {     // .. do other initializing in here     register_event( "DeathMsg", "Ev_Death", "a" );     return PLUGIN_CONTINUE; }

I'm pretty sure you can display a % sign by stringing "%%", but i'm not 100% sure.

Hope this helps.

hellraser 07-16-2004 05:27

Thx m8

DanRaZor 07-16-2004 07:17

What do you think of that :

http://perso.wanadoo.fr/dan.web/plug.../hsd_stats.jpg

Search powwwwwwwwa ...

:wink:

DanRaZor 07-16-2004 07:20

Just kidding ... go HERE

:wink:

hellraser 07-16-2004 08:18

hehe thx ;)
One simple question how to i print a hudmessage to onlyone specific player??
I tried show_hudmessage(id, "Status : %d %",rnd)

But it prints it to everyone...

DanRaZor 07-16-2004 08:45

Verify that your id is right by printing it ( 0 is for all ... )

Do not use format in the show_hudmessage, don't know if it really works well :roll:

Do like that :

Code:
new text[64] format(text,63,"[%d] Status : %d %%",id,rnd) set_hudmessage( .... ) show_hudmessage(id, text)

PS : Add "%%" to show % ...

You will see a message like

Quote:

[12] Status : 10 %
And watch what is in [], if 0, all will see it ... and it is normal.


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

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