SA-MP Forums Archive
Kills / Deaths 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: Kills / Deaths Ratio. (/showthread.php?tid=408317)



Kills / Deaths Ratio. - HUYA - 17.01.2013

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



Re: Kills / Deaths Ratio. - B-Matt - 17.01.2013

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


Re: Kills / Deaths Ratio. - HUYA - 17.01.2013

How to add this to stats command or is save ini?


Re: Kills / Deaths Ratio. - Sasino97 - 17.01.2013

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


Re: Kills / Deaths Ratio. - HUYA - 18.01.2013

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


Re: Kills / Deaths Ratio. - RajatPawar - 18.01.2013

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.


Re: Kills / Deaths Ratio. - Threshold - 18.01.2013

KDR = Kill/Death Ratio xD

so replace it with the ratio variable :P


Re: Kills / Deaths Ratio. - HUYA - 18.01.2013

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.



Re: Kills / Deaths Ratio. - LarzI - 18.01.2013

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.


Re: Kills / Deaths Ratio. - HUYA - 19.01.2013

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