K/D ratio -
Wesley221 - 20.08.2011
Hey guys
Im trying to get my K/D ratio. I know it is (kills/deaths), but it isnt working.
In my script i did it like:
pawn Code:
format(KD, sizeof KD, "Kills: %i ~n~Deaths: %i ~n~K/D Ratio: %f",PlayerInfo[playerid][pRKills], PlayerInfo[playerid][pRDeaths], ((PlayerInfo[playerid][pRKills]) / (PlayerInfo[playerid][pRDeaths])));
But in my textdraw it just shows 0.0000000(not sure howmutch 0's, but there are some)
Also, yes i know the variables contain some kills/deaths (8/4). So my K/D should be 2, but its still 0.000000
Anyone know how to solve this?
Second question:
How can i get a password out of a file?
Im using y_ini, and trying to get a whirlpool hashed password out of it to compare it with the inputtext.
Ive tried to store it in a variable with INI_String, but that didnt work (Gave me the error Undefined symbol: INI_String)
Any help?
~Wesley
Re: K/D ratio -
Lorenc_ - 20.08.2011
use ' %0.2f ' It'll output as: 1.00
Re: K/D ratio -
Wesley221 - 20.08.2011
Quote:
Second question:
How can i get a password out of a file?
Im using y_ini, and trying to get a whirlpool hashed password out of it to compare it with the inputtext.
Ive tried to store it in a variable with INI_String, but that didnt work (Gave me the error Undefined symbol: INI_String)
|
^- bump for that question
Also, when i got like 500 kills, and 1 death it still shows 0.00, and not 500.00
Do you know what this can be?
Re: K/D ratio -
Machida - 20.08.2011
Try this:
new Float:Ratio;
Ratio = PlayerInfo[playerid][pRKills] / PlayerInfo[playerid][pRDeaths];
format(KD, sizeof KD, "Kills: %i ~n~Deaths: %i ~n~K/D Ratio: %f",PlayerInfo[playerid][pRKills], PlayerInfo[playerid][pRDeaths],Ratio);
Im a newbie, but that might work..
Re: K/D ratio -
Lorenc_ - 20.08.2011
I usally use floatdiv, seems to be much accurate
pawn Code:
new Float: ratio = floatdiv(kills, deaths);
No problem that code ^ I personally use it myself.
Q2:
You need to use INI_ParseFile & INI_WriteString ( Pretty sure its that function )
Re: K/D ratio -
Wesley221 - 20.08.2011
Thanks! K/d is solved
About the second question,
How would i do that? Atm i got:
pawn Code:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
forward LoadUser_data(playerid, name[], value[]);
public LoadUser_data(playerid, name[], value[])
{
//INI_String("Name", PlayerInfo[playerid][pName]);
//INI_String("Password", PlayerInfo[playerid][pPass]);
INI_Int("Money",PlayerInfo[playerid][pMoney]);
INI_Int("Score",PlayerInfo[playerid][pScore]);
INI_Int("Admin level",PlayerInfo[playerid][pAdmin]);
INI_Int("Vip level",PlayerInfo[playerid][pVip]);
INI_Int("RKills",PlayerInfo[playerid][pRKills]);
INI_Int("RDeaths",PlayerInfo[playerid][pRDeaths]);
INI_Int("RKD",PlayerInfo[playerid][pRKd]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("KD",PlayerInfo[playerid][pKd]);
return 1;
}
Ive already tried the INI_String, but like i said b4, it gives me the error: "error 017: undefined symbol "INI_String"
Re: K/D ratio -
Lorenc_ - 20.08.2011
You relise you haven't formatted the userfile.
pawn Code:
new userfile[24];
format(userfile, 24, "LoadUser_%s", playername);
Replace:
pawn Code:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
with
pawn Code:
INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
Though thats the wrong concept of doing it.
Re: K/D ratio -
Pinguinn - 20.08.2011
Try what he said above [misread it]
Re: K/D ratio -
Wesley221 - 20.08.2011
Quote:
Originally Posted by Lorenc_
You relise you haven't formatted the userfile.
pawn Code:
new userfile[24]; format(userfile, 24, "LoadUser_%s", playername);
Replace:
pawn Code:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
with
pawn Code:
INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
Though thats the wrong concept of doing it.
|
I just did this, but now the problem is still @ error 017: undefined symbol "INI_String"
Is there a different native for this, or what?
Note: Im trying to get a whirlpool-hashed password out of it, so INI_Int wont work
Re: K/D ratio -
Pinguinn - 20.08.2011
Open y_ini and look for INI_String
Re: K/D ratio -
Wesley221 - 20.08.2011
pawn Код:
#define INI_String(%1,%2,%3) \
if(!strcmp((%1),name,true)&&!sscanf(value,"s["#%3"]",%2))return;
//if (!strcmp((%1), name, true)) return %2(value)
#else
#define INI_Int(%1,%2) \
if(!strcmp((%1),name,true))return %2=strval(value)
#define INI_Float(%1,%2) \
if(!strcmp((%1),name,true))return _:(%2=floatstr(value))
#define INI_Hex(%1,%2) \
if(!strcmp((%1),name,true))return %2=hexstr(value)
#define INI_Bin(%1,%2) \
if(!strcmp((%1),name,true))return %2=binstr(value)
#define INI_Bool(%1,%2) \
if(!strcmp((%1),name,true))return %2=boolstr(value)
#define INI_String(%1,%2,%3) \
if(!strcmp((%1),name,true))return strcpy(%2,value,%3)
#endif
Its in the include, i opened pawno the right way, it is up-to-date, and still saying undefined symbol