problem with ratio
#1

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

Код:
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.
Reply
#3

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

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

So you saying to make it like that

new Float:ratio = killerid/playerid;

or what? xD
Reply
#6

Код:
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...
Reply
#7

So you better use total kills and total deaths instead of that?
Reply
#8

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

Код:
	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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)