Need help K/D Ratio
#1

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?
Reply
#2

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

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.
Reply
#4

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.
Reply
#5

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

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.
Reply
#7

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
Reply
#8

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;
}
Reply
#9

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.
Reply
#10

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])); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)