Raised This Month: $51 Target: $400
 12% 

ACC


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Igor69
Junior Member
Join Date: Feb 2014
Old 01-09-2019 , 08:35   ACC
Reply With Quote #1

Hello, why plugin do not show acc %? When round end always shows 0% acc. Maybe can help? Thanks.

Code:
#include <amxmodx>
#include <amxmisc>
#include <csstats>

#define MIN_KILLS 1

new Kills[33];
new Headshots[33];

public plugin_init()
{
    register_plugin("Best", "1.0", "eV");
    
    register_event("HLTV", "OnHltv", "a", "1=0", "2=0");
    register_event("DeathMsg", "OnDeathMsg", "a");
    
    register_logevent("OnRoundEnd", 2, "1=Round_End");
}

public client_disconnected(id)
    Kills[id] = Headshots[id] = 0;
    
public OnHltv()
{
    arrayset(Kills, 0, sizeof Kills);
    arrayset(Headshots, 0, sizeof Headshots);
}
public OnDeathMsg()
{
    new id = read_data(1);
    
    if (!is_user_connected(id))
        return;
        
    Kills[id]++;
    
    if (read_data(3))
        Headshots[id]++;
}

public OnRoundEnd()
{
	static stats[8]
	new players[32], num;
	get_players(players, num);
    
    if (!num)
        return;
    
    new best = players[0];
    
    for (new i = 1, id; i < num; i++)
    {
        id = players[i];
        
        if (Kills[id] > Kills[best] || (Kills[id] == Kills[best] && Headshots[id] > Headshots[best]))
            best = id;
    }
    
    if (Kills[best] < MIN_KILLS) // Minimum amount of kills
        return;

    new name[32];
    get_user_name(best, name, charsmax(name));    
    client_print(0, print_chat, "* Best is %s!", name);
    client_print(0, print_chat, "* He killed %d players, including %d headshots.", Kills[best], Headshots[best]);
    client_print(0, print_chat, "* ACC: %2.0f%%", accuracy(stats));
}  
stock Float:accuracy(stats[8])
{
	if(!stats[4])
		return ( 0.0 );
	new Float:result
	result = 100.0 * float( stats[5] ) / float( stats[4] );
	return (result > 100.0) ? 100.0 : result
}

Last edited by Igor69; 01-09-2019 at 08:36.
Igor69 is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 01-09-2019 , 09:20   Re: ACC
Reply With Quote #2

PHP Code:
 client_print(0print_chat"* ACC: %2.0f%%"accuracy(stats)); 

PHP Code:
 client_print(0print_chat"* ACC: %s"accuracy(stats)); 
not sure
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-09-2019 , 09:42   Re: ACC
Reply With Quote #3

Quote:
Originally Posted by Nutu_ View Post
PHP Code:
 client_print(0print_chat"* ACC: %2.0f%%"accuracy(stats)); 

PHP Code:
 client_print(0print_chat"* ACC: %s"accuracy(stats)); 
not sure

Not correct

%s for formating a string or an array.

%.2f is for a float with two digits on the right (1.00)
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Igor69
Junior Member
Join Date: Feb 2014
Old 01-09-2019 , 09:58   Re: ACC
Reply With Quote #4

so must be -> %.2f ?
Igor69 is offline
shauli
Member
Join Date: Jun 2018
Old 01-09-2019 , 10:16   Re: ACC
Reply With Quote #5

You didn't use get_user_stats or whatever it's called. 'stats' is always empty.
shauli is offline
SomewhereLost
AlliedModders Donor
Join Date: Mar 2014
Location: Tomorrowland
Old 01-09-2019 , 10:35   Re: ACC
Reply With Quote #6

Quote:
Originally Posted by Igor69 View Post
so must be -> %.2f ?
%.02f < for 2 decimal points.
__________________
SomewhereLost is offline
Send a message via Skype™ to SomewhereLost
Igor69
Junior Member
Join Date: Feb 2014
Old 01-09-2019 , 11:21   Re: ACC
Reply With Quote #7

Quote:
Originally Posted by shauli View Post
You didn't use get_user_stats or whatever it's called. 'stats' is always empty.

So then how best to get it? Can help?
Igor69 is offline
Igor69
Junior Member
Join Date: Feb 2014
Old 01-09-2019 , 14:41   Re: ACC
Reply With Quote #8

So, what I need to add to make it work acc? Maybe can anyone wirte the code? Thanks.
Igor69 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-09-2019 , 15:07   Re: ACC
Reply With Quote #9

Quote:
Originally Posted by shauli View Post
You didn't use get_user_stats or whatever it's called. 'stats' is always empty.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Igor69
Junior Member
Join Date: Feb 2014
Old 01-09-2019 , 15:45   Re: ACC
Reply With Quote #10

Can you add in code full line?
Igor69 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 13:57.


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