Kills / Deaths Ratio.
#1

how to make Kills / Deaths Ratio.
And i need make for this save ini?
Enums
Code:
PlayerInfo[playerid][Kills]
PlayerInfo[playerid][Deaths]
Reply
#2

pawn Code:
new Float:ratio = floatdiv(PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths]);
Try this..
Reply
#3

How to add this to stats command or is save ini?
Reply
#4

You have to show us the /stat command and the place where you read and save player stats (kills, deaths).
Reply
#5

PHP Code:
stock ShowPlayerStats(playerid)
{
    
format(stringsizeof(string), "%s stats:"GetPlayerName(playerid));
    
SendClientMessage(playerid,-1,string);
    
format(stringsizeof(string), "Password:(%i) Level:(%i) AdmLevel:(%i) DonatorLevel:(%i)"PlayerInfo[playerid][Password], PlayerInfo[playerid][Level], PlayerInfo[playerid][AdmLevel], PlayerInfo[playerid][Donator]);
    
SendClientMessage(playerid,-1,string);
    
format(stringsizeof(string), "Score:(%i) Kills:(%i) Deaths:(%i) Sucide(%i) KDR:(%i)"PlayerInfo[playerid][Score], PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][Sucide], PlayerInfo[playerid][KDR]);
    
SendClientMessage(playerid,-1,string);
    
format(stringsizeof(string), "VehicleTicket:(%i) VehicleID:(%i) VehicleLock:(%i) VehicleColor:(%ix%i)"PlayerInfo[playerid][vTicket], PlayerInfo[playerid][vKey], PlayerInfo[playerid][vLock], PlayerInfo[playerid][vColor], PlayerInfo[playerid][vColor2]);
    
SendClientMessage(playerid,-1,string);
    return 
1;

here is my command
Reply
#6

pawn Code:
new Float:ratio = floatdiv(PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths]);
Thanks, B_Matt.
pawn Code:
stock ShowPlayerStats(playerid)
{
    format(string, sizeof(string), "%s stats:", GetPlayerName(playerid));
    SendClientMessage(playerid,-1,string);
    format(string, sizeof(string), "Password:(%i) Level:(%i) AdmLevel:(%i) DonatorLevel:(%i)", PlayerInfo[playerid][Password], PlayerInfo[playerid][Level], PlayerInfo[playerid][AdmLevel], PlayerInfo[playerid][Donator]);
    SendClientMessage(playerid,-1,string);
    format(string, sizeof(string), "Score:(%i) Kills:(%i) Deaths:(%i) Sucide(%i) KDR:(%f)", PlayerInfo[playerid][Score], PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][Sucide], ratio);
    SendClientMessage(playerid,-1,string);
    format(string, sizeof(string), "VehicleTicket:(%i) VehicleID:(%i) VehicleLock:(%i) VehicleColor:(%ix%i)", PlayerInfo[playerid][vTicket], PlayerInfo[playerid][vKey], PlayerInfo[playerid][vLock], PlayerInfo[playerid][vColor], PlayerInfo[playerid][vColor2]);
    SendClientMessage(playerid,-1,string);
    return 1;
}
EDIT: Lol, thanks Benzo.
Reply
#7

KDR = Kill/Death Ratio xD

so replace it with the ratio variable :P
Reply
#8

Code:
C:\Documents and Settings\CT\Desktop\HUYA TDM\gamemodes\HUYA.pwn(42) : error 017: undefined symbol "string"
C:\Documents and Settings\CT\Desktop\HUYA TDM\gamemodes\HUYA.pwn(42) : error 017: undefined symbol "string"
C:\Documents and Settings\CT\Desktop\HUYA TDM\gamemodes\HUYA.pwn(42) : error 029: invalid expression, assumed zero
C:\Documents and Settings\CT\Desktop\HUYA TDM\gamemodes\HUYA.pwn(42) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#9

Quote:
Originally Posted by HUYA
View Post
Code:
C:\Documents and Settings\CT\Desktop\HUYA TDM\gamemodes\HUYA.pwn(42) : error 017: undefined symbol "string"
C:\Documents and Settings\CT\Desktop\HUYA TDM\gamemodes\HUYA.pwn(42) : error 017: undefined symbol "string"
C:\Documents and Settings\CT\Desktop\HUYA TDM\gamemodes\HUYA.pwn(42) : error 029: invalid expression, assumed zero
C:\Documents and Settings\CT\Desktop\HUYA TDM\gamemodes\HUYA.pwn(42) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Please. If you understand English, you can quite easily understand what the problem is. You're using a variable called "string", yet there's no such variable. Obviously what you need to do, is declaring a variable called string.

pawn Code:
new
    string[ 103 ]
;
Without the formats, the text it 61 letters long, but you must take in consideration that integers can be up to 12 letters long. 12 * 5 = 60, 60 + 61 = 121. You could decrease this value, as vehiclecolor may only be from 0-255 - aka 3 letters. So take away 9 * 2 = 18 letters: 103. This might be the optimal amount of cells used for maximum values.

To count characters in a string, I recommend using a simple tool like Microsoft Word (although it's slow), or an online website like lettercount.com.

___

Reading (at least parts of) the SA:MP Wiki and the pawn-language.pdf is very essential if you don't understand basics like these - I really recommend looking them up.
Reply
#10

Uhh thanks man, now i understand THANKS YOU, But i still have problem;
Code:
C:\Documents and Settings\CT\Desktop\HUYA TDM\gamemodes\HUYA.pwn(44) : warning 202: number of arguments does not match definition
C:\Documents and Settings\CT\Desktop\HUYA TDM\gamemodes\HUYA.pwn(44) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
the lines;
Code:
    format(string, sizeof(string), "%s stats:", GetPlayerName(playerid));
    SendClientMessage(playerid,-1,string);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)