problem with ratio -
wallen - 26.01.2018
OnPlayerDeath
Код:
PlayerKills[killerid]++;
PlayerDeaths[playerid]++;
new iString[100];
new Float:ratio = PlayerKills[killerid]/PlayerDeaths[playerid];
format(iString, sizeof iString, "Kills: %i", PlayerKills[killerid]);
TextDrawSetString(KILLS[killerid], iString);
format(iString, sizeof iString, "Deaths: %i", PlayerDeaths[playerid]);
TextDrawSetString(DEATHS[playerid], iString);
format( iString, sizeof( iString ), "Ratio: %.2f", ratio);
TextDrawSetString(RATIO[playerid], iString);
Every time im killing and dying it's stuck at Ratio: 1.00, which i dont know whats wrong..
Re: problem with ratio -
RowdyrideR - 26.01.2018
Код:
PlayerKills[killerid]/PlayerDeaths[playerid];
This code is dividing the killer’s kills on the dead’s deaths.
It should be like:
Код:
PlayerKills[killerid]/PlayerDeaths[killerid];
You need to do every one alone. As a string and a ratio for killerid and show it, and the other for playerid and show it
This code is messed.
Re: problem with ratio -
wallen - 27.01.2018
Explain better, did everything but doesnt work... maybe give me the correct code because im stuck there like 1 day would be appreciated if you give the code with the descriptions
Re: problem with ratio -
Sew_Sumi - 27.01.2018
You fucked up your calculations...
Код:
new Float:ratio = PlayerKills[killerid]/PlayerDeaths[playerid];
K/D ratios are usually based on the player themselves. Not a combination of the players deaths and the killers kills, as in a 1 on 1, this will simply be 1 as for each kill, the player dies.
This isn't the place to hand out code either, as unless you learn the mistake you made, then pasting you code will not aid you in the longer term.
It's also not the section to be looking for code in such a simple situation as this.
Re: problem with ratio -
wallen - 27.01.2018
So you saying to make it like that
new Float:ratio = killerid/playerid;
or what? xD
Re: problem with ratio -
Sew_Sumi - 27.01.2018
Код:
new Float:ratio = PlayerKills[playerid]/PlayerDeaths[playerid];
...
Being that you're likely to be testing via 1 v 1, the ratio will always be 1:1 because there isn't a third or fourth player to take some of the kills/deaths...
Re: problem with ratio -
wallen - 27.01.2018
So you better use total kills and total deaths instead of that?
Re: problem with ratio -
Sew_Sumi - 27.01.2018
A K/D ratio is based on the players kills/deaths... You were doing the kills of the killer, / deaths of the player.
just fix the formula as I said about checking player deaths and kills, and kill/die more.
Re: problem with ratio -
iSteve - 27.01.2018
Код:
PlayerKills[killerid]++;
PlayerDeaths[playerid]++;
new iString[100];
new Float:ratio = PlayerKills[playerid]/PlayerDeaths[playerid];
format(iString, sizeof iString, "Kills: %i", PlayerKills[killerid]);
TextDrawSetString(KILLS[killerid], iString);
format(iString, sizeof iString, "Deaths: %i", PlayerDeaths[playerid]);
TextDrawSetString(DEATHS[playerid], iString);
format( iString, sizeof( iString ), "Ratio: %.2f", ratio);
TextDrawSetString(RATIO[playerid], iString);