Page 1 of 1

Pagalba

Posted: 2019 Jan 10 18:49
by Molvas
Sveiki, susiduriau su problema, reiktu kad rodytu taikluma raundo pabaigoje, bet visada rodo 0proc. Vienas žmogus sake reikia eilutes kažkokios, kad galėčiau išgauti tai raudo pabaigoje, bet bandžiau kelis variantus jokio atsakymo. Dėkui :)

Code: Select all

#include <amxmodx>#include <amxmisc>#include <csstats> #define MIN_KILLS 1 new Kills[33];new Headshots[33]; public plugin_init(){    register_plugin("Best Player of the Round", "1.0", "hleV");        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, "* Taiklumas: %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} 

Re: Pagalba

Posted: 2019 Jan 10 19:21
by psychical
O kas yra stats funkcijoje OnRoundEnd()? Nes tas kintamasis visada tuščias...

Re: Pagalba

Posted: 2019 Jan 10 21:13
by Molvas
Tiesiog bandžiau iš vieno plugino pavogti koda ir įkelti į kita (gal jis čia ir nereikalingas). Koda emiau iš čia:
Esme tame, kad reiktu padaryti, kad rodytu raundo pabaigoje to žaidėjo taiklumo procenta, kurį jis padare per raunda. Bandžiau kelis variantus bet..

Code: Select all

 #include <amxmodx>#include <amxmisc>#include <csstats> public plugin_init() {        register_plugin(PLUGIN, VERSION, AUTHOR);        register_clcmd("say /rank", "cmdShowRank");} public cmdShowRank(id){       static stats[8], stats2[4], body[8]    new rank_pos = get_user_stats(id, stats, body);    new max_rank = get_statsnum();        get_user_stats2(id, stats2);        static host_name[32];    get_cvar_string("hostname", host_name, 31);        static motd[1501], len;        len = format(motd, 1500,"<body bgcolor=#000000><font color=#87cefa><pre>");    len += format(motd[len], 1500-len,"<center><img src=^"http://alkazone.freehostia.com/rank_stats.png^"></center></img>");    len += format(motd[len], 1500-len,"<center><h4><font color=^"blue^"> You'r statistics in '%s' </font></h4></center>", host_name);    len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Rank :</B> <font color=^"white^">%d / %d</color></left>^n", rank_pos, max_rank);    len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Kills :</B> <font color=^"white^"> %d</color></left>^n", stats[0]);    len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Deaths :</B> <font color=^"white^"> %d</color></left>^n", stats[1]);    len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Head Shots :</B> <font color=^"white^"> %d</color></left>^n", stats[2]);    len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Damage :</B> <font color=^"white^"> %d</color></left>^n", stats[6]);    len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Shots :</B> <font color=^"white^"> %d</color></left>^n", stats[4]);    len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Hits ;</B> <font color=^"white^"> %d</color></left>^n", stats[5]);    len += format(motd[len], 1500-len,"<left><font color=^"blue^">----------------------------------</color></left>^n");    len += format(motd[len], 1500-len,"<left><font color=^"red^">Eff : <font color=^"white^"> %3.0f%%</color></left>^n", effec(stats));    len += format(motd[len], 1500-len,"<left><font color=^"red^">Acc : <font color=^"white^"> %3.0f%%</color></left>^n", accuracy(stats));    len += format(motd[len], 1500-len,"<left><font color=^"blue^">----------------------------------</color></left>^n^n");    len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Defused Bombs :</B> <font color=^"white^">%d </color></left>^n", stats2[1]);    len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Planted Bombs :</B> <font color=^"white^">%d </color></left>^n", stats2[2]);    len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Exploded Bombs :</B> <font color=^"white^">%d </color></left>^n^n", stats2[3]);            show_motd(id, motd, "You'r Rank");        return 0;} 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} stock Float:effec(stats[8]){    if(!stats[0])        return ( 0.0 );    new Float:result    result = 100.0 * float( stats[0] ) / float( stats[0] + stats[1] );    return (result > 100.0) ? 100.0 : result} 

Re: Pagalba

Posted: 2019 Jan 10 22:19
by psychical
Jis dalina STATSX_SHOTS iš STATSX_HITS, kuriuos gauna iš statistikos, kuri saugoma... Tavo noras kopijuoti yra visiškai neteisingas, o ir galimybės, pagal tavo patiektus kodus išgauti tai ko tu nori, neįmanoma, nes pirmame kode turi neturi šūvių ir pataikymų, o antrame kode visa tai yra ne iš "live" žaidimo, o iš išsaugotos informacijos. Norint išvesti būtent šią statistiką, tau papildomai reikia šūvių ir pataikymų skaičiavimo.

Re: Pagalba

Posted: 2019 Jan 10 22:30
by Molvas
Supratau, o šūvius ir pataikymus neimano pritaikyti iš statsx plugino? O gal galėtum padėti tuo klausimu?

Re: Pagalba

Posted: 2019 Jan 10 22:40
by psychical
new rank_pos = get_user_stats(id, stats, body);

Re: Pagalba

Posted: 2019 Jan 11 10:14
by Molvas
psychical wrote:new rank_pos = get_user_stats(id, stats, body);
Kažka ne taip darau turbūt.. Atrodo paprasta dalyka noriu pasidaryt, bet..

Code: Select all

(45) : error 017: undefined symbol "id"(68) : error 017: undefined symbol "stats"(68) : error 001: expected token: ",", but found ";"

Code: Select all

#include <amxmodx>#include <amxmisc>#include <csstats> #define MIN_KILLS 1 new Kills[33];new Headshots[33]; public plugin_init(){    register_plugin("Best Player of the Round", "1.0", "hleV");       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(){            new players[32], num;            get_players(players, num);            new rank_pos = get_user_stats(id, stats, body);               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, "* Taiklumas: %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}

Re: Pagalba

Posted: 2019 Jan 11 21:46
by psychical

Code: Select all

#include <amxmodx>#include <amxmisc>#include <csstats> #define MIN_KILLS 1 new Kills[33], Headshots[33]; public plugin_init(){    register_plugin("Best Player of the Round", "1.0", "hleV");       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], body[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;    }        get_user_stats(best, stats, body);     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, "* Taiklumas: %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}

Re: Pagalba

Posted: 2019 Jan 12 14:59
by Molvas
Dėkui viskas kaip ir veikia, bet toks pastebėjimas, pagal statsx ir mano plugino procentai skiriasi, jei nušauna iš vienos kulkos rodo 100proc, o mano pluginas rodo pvz: 25proc. Iš keliu kartu rodo 50proc, o mano 24 ir pan. Ar normalu?