saving player's rank name
#1

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

Your defining them as numbers

#define Private 7
#define Corporal 8
#define Sergeant 9

Save them as there defined.
Reply
#3

What happen after you save it?

What is the result
Reply
#4

@C00k(something) You mean this?
#define Pvt "Private"
If yes
Код:
error 047: array sizes do not match, or destination array is too small
@Romel
Reply
#5

what error is coming tell me i will fix it
Reply
#6

No errors. It save a big dot in my file
Rank=
Reply
#7

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;
}
Reply
#8

Now it doesn't save anything..
Reply
#9

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


Forum Jump:


Users browsing this thread: 1 Guest(s)