Easier way?
#1

Is there an easier way to save skills instead of making
skill1
skill2
skill3 etc?

This is my PlayerInfo, Loading and Saving.

pawn Код:
enum pInfo
{
    // other stats here
    pJob,
    pSkill1,
    pSkill2,
    pSkill3,
    pSkill4,    
}
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    // other stats here
    INI_Int("Job",PlayerInfo[playerid][pJob]);
    INI_Int("Skill1",PlayerInfo[playerid][pSkill1]);
    INI_Int("Skill2",PlayerInfo[playerid][pSkill2]);
    INI_Int("Skill3",PlayerInfo[playerid][pSkill3]);
    INI_Int("Skill4",PlayerInfo[playerid][pSkill4]);
        return 1;
}
pawn Код:
stock SaveChar(playerid)
{
    if(Connected[playerid] == 1)
    {
        // other stats here
        INI_WriteInt(File,"Job",PlayerInfo[playerid][pJob]);
        INI_WriteInt(File,"Skill1",PlayerInfo[playerid][pSkill1]);
        INI_WriteInt(File,"Skill2",PlayerInfo[playerid][pSkill2]);
        INI_WriteInt(File,"Skill3",PlayerInfo[playerid][pSkill3]);
        INI_WriteInt(File,"Skill4",PlayerInfo[playerid][pSkill4]);
        INI_Close(File);
            return 1;
     }
        else
        {
            new string[100];
        format(string, 100, "%s's character failed to save.", GetName(playerid));
        print(string);
    }
    return 1;
}
Reply
#2

you can do it like this
pawn Код:
enum pInfo
{
    // other stats here
    pJob,
    pSkill[4]  
}
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    // other stats here
    INI_Int("Job",PlayerInfo[playerid][pJob]);
    for(new x=0; x<4; x++)
   {
      new temp[10];
      format(temp,sizeof(temp),"Skill%d",x+1);
      INI_Int(temp,PlayerInfo[playerid][pSkill][x]);
   }
    return 1;
}
pawn Код:
INI_WriteInt(File,"Job",PlayerInfo[playerid][pJob]);
    for(new x=0; x<4; x++)
   {
      new temp[10];
      format(temp,sizeof(temp),"Skill%d",x+1);
      INI_WriteInt(File,temp,PlayerInfo[playerid][pSkill][x]);
   }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)