saving player's rank name -
newbienoob - 01.09.2012
I've been struggled for almost an hour to figure out how to save player's rank name like, Rank=Private.. etc. But I can't make it. Here's my script
pawn Код:
#define Private 7
#define Corporal 8
#define Sergeant 9
//moar ranks here
enum PlayerInfo
{
//some other shits here
Rank[10],
//moar shits here
}
forward GetPlayerRank(playerid);
public GetPlayerRank(playerid)
{
if(pInfo[playerid][Kills] >= 0)
{
pInfo[playerid][Rank] = Private;
}
else if(pInfo[playerid][Kills] >= 50)
{
pInfo[playerid][Rank] = Corporal;
}
return 1;
}
//onplayerdiconnect
INI_WriteString(file,"Rank",GetPlayerRank(playerid));
//somewhere
format(str,sizeof(str),"Rank: %s",GetPlayerRank(playerid));
TextDrawSetString(^);
So the problem is, It doesn't save in player's data in the scriptfiles. I want it to be like
Rank = Private (Or Corporal, Sergeant, ...etc)
Re: saving player's rank name -
C00K13M0N$73R - 01.09.2012
Your defining them as numbers
#define Private 7
#define Corporal 8
#define Sergeant 9
Save them as there defined.
Re: saving player's rank name -
JaKe Elite - 01.09.2012
What happen after you save it?
What is the result
Re: saving player's rank name -
newbienoob - 01.09.2012
@C00k(something) You mean this?
#define Pvt "Private"
If yes
Код:
error 047: array sizes do not match, or destination array is too small
@Romel
Re: saving player's rank name -
NaBeeL[NxT] - 01.09.2012
what error is coming tell me i will fix it
Re: saving player's rank name -
newbienoob - 01.09.2012
No errors. It save a big dot in my file
Rank=
Re: saving player's rank name -
Dan. - 01.09.2012
pawn Код:
INI_WriteString(file,"Rank",GetPlayerRank(playerid));
It's supposed to return the rank name, currently it's returning 1 not the rank name.
Try this:
pawn Код:
forward GetPlayerRank(playerid);
public GetPlayerRank(playerid)
{
new rank;
if(pInfo[playerid][Kills] >= 0 && pInfo[playerid][Kills] < 50)
{
rank = Private;
}
else if(pInfo[playerid][Kills] >= 50)
{
rank = Corporal;
}
return rank;
}
Re: saving player's rank name -
newbienoob - 01.09.2012
Now it doesn't save anything..
Re: saving player's rank name -
Dan. - 01.09.2012
pawn Код:
INI_WriteString(file,"Rank",GetPlayerRank(playerid));
When you use GetPlayerRank it actually returns a number (like 7 for Private etc). It isn't really a string. So you might using WriteInteger or whatever, never used INI.
E:// By the way, why are you saving the rank? Each time a player logs in you load his kills and set his rank again.