SA-MP Forums Archive
Need help K/D Ratio - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help K/D Ratio (/showthread.php?tid=610654)



Need help K/D Ratio - Owen007 - 26.06.2016

hi everyone,

I am using a yini score kills death save system. i was in need of a k/d ratio system i readed a lot from wiki but get no luck.

can someone help?


Re: Need help K/D Ratio - WhiteGhost - 26.06.2016

I Want the same thing,i heard u got to divide the kills and deaths
Like Kills % Deaths


Re: Need help K/D Ratio - Konstantinos - 26.06.2016

pawn Код:
floatdiv(KILLS_HERE, DEATHS_HERE)
and returns the ratio. Avoid dividing integers directly because if you divide with 0 a run time error 11 will occur.


Re: Need help K/D Ratio - Owen007 - 26.06.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
floatdiv(KILLS_HERE, DEATHS_HERE)
and returns the ratio. Avoid dividing integers directly because if you divide with 0 a run time error 11 will occur.
too much pro can u make the thing wut u saying.


Re: Need help K/D Ratio - WhiteGhost - 26.06.2016

Quote:
Originally Posted by Owen007
Посмотреть сообщение
too much pro can u make the thing wut u saying.
Isnt it already there?


Re: Need help K/D Ratio - DRIFT_HUNTER - 26.06.2016

pawn Код:
new str[24];
format(str, sizeof(str), "Ratio %f", (pInfo[playerid][Kills]/pInfo[playerid][Deaths]));
SendClientMessage(playerid, -1, str);
Something like that. Now you need to replace pInfo[playerid][Kills] and pInfo[playerid][Deaths] with your variables.


Re: Need help K/D Ratio - Owen007 - 26.06.2016

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
pawn Код:
new str[24];
format(str, sizeof(str), "Ratio %f", (pInfo[playerid][Kills]/pInfo[playerid][Deaths]));
SendClientMessage(playerid, -1, str);
Something like that. Now you need to replace pInfo[playerid][Kills] and pInfo[playerid][Deaths] with your variables.
ty man that is wut i was in need of


Re: Need help K/D Ratio - K0P - 26.06.2016

Note: This is an example code

Код:
//Include zcmd for making easy commands
#include <zcmd>

//Global Variables
new Kills[MAX_PLAYERS];
new Deaths[MAX_PLAYERS];


public OnPlayerDeath(playerid, killerid, reason)
{
    //Put this code under OnPlayerDeath()
    if(killerid != INVALID_PLAYER_ID)
    { 
        Kills[killerid]++;
    }
    Deaths[playerid]++;
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    //Code under OnPlayerDeath
    Kills[playerid] = 0;
    Deaths[playerid] = 0;
    return 1;
}

CMD:kdratio(playerid, params[])
{
    new str[50];
    format(str, sizeof(str), "You K/D Ratio: %f", floatdiv(Kills[playerid], Deaths[playerid]));
    SendClientMessage(playerid, 0xFFFFFFFF, str);
    return 1;
}



Re: Need help K/D Ratio - Owen007 - 26.06.2016

Quote:
Originally Posted by K0P
Посмотреть сообщение
Note: This is an example code

Код:
//Include zcmd for making easy commands
#include <zcmd>

//Global Variables
new Kills[MAX_PLAYERS];
new Deaths[MAX_PLAYERS];


public OnPlayerDeath(playerid, killerid, reason)
{
    //Put this code under OnPlayerDeath()
    if(killerid != INVALID_PLAYER_ID)
    { 
        Kills[killerid]++;
    }
    Deaths[playerid]++;
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    //Code under OnPlayerDeath
    Kills[playerid] = 0;
    Deaths[playerid] = 0;
    return 1;
}

CMD:kdratio(playerid, params[])
{
    new str[50];
    format(str, sizeof(str), "You K/D Ratio: %f", floatdiv(Kills[playerid], Deaths[playerid]));
    SendClientMessage(playerid, 0xFFFFFFFF, str);
    return 1;
}
ty sir for your kind help.


Re: Need help K/D Ratio - Dayrion - 27.06.2016

Mine :
PHP код:
if(PlayerDMStats[playerid][dmDeath] == 0format(str1sizeof(str1), RED_U"- "WHITE_U"Ratio : "BLUE_U"None\n");
    else 
format(str1sizeof(str1), RED_U"- "WHITE_U"Ratio : "BLUE_U"%0.2f\n"floatdiv(PlayerDMStats[playerid][dmKills],PlayerDMStats[playerid][dmDeath]));