enum pInfo
#1

How do you save enum pInfo to player file?

I need to save admin level to the player file, but i cant figure out how to.
The Admin is in "enum pInfo"

Everything is saved when disconnect, "Member" "Leader" "Status" "Request" "IsRequesting" Score" "Jail", and uses ""new "Member[MAX_PLAYERS];"" and not "enum pInfo" .

And i cant change admin the way "new "Member[MAX_PLAYERS];" etc is made, then i got errors, even if i put every part on right place.

Ill show you the code
pawn Code:
new Member[MAX_PLAYERS];
new Leader[MAX_PLAYERS];
new request[MAX_PLAYERS];
new IsRequesting[MAX_PLAYERS];
new Score[MAX_PLAYERS];
new Jail[MAX_PLAYERS];

enum pInfo
{
    Pass,
    Money,
    Admin,
    Level,
    Vip,
    Spawn,
};

public OnPlayerRegister(playerid, password[])
{
    if(IsPlayerConnected(playerid))
    {
        new file[64];
        new playername3[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername3, sizeof(playername3));
        format(file, sizeof(file), "/Users/%s.ini", playername3);

        if(dini_Exists(file))
        {
            return SendClientMessage(playerid,COLOR_GREY,"This account is already registered.");
        }
        else
        {
            dini_Create(file);
            new password2 = num_hash(password);
            PlayerInfo[playerid][Pass] = password2;
            dini_IntSet(file, "Password",password2);
            dini_IntSet(file, "Member", Member[playerid]);
            dini_IntSet(file, "Leader", Leader[playerid]);
            dini_IntSet(file, "Status", IsInOrg[playerid]);
            dini_IntSet(file, "Request", request[playerid]);
            dini_IntSet(file, "IsRequesting", IsRequesting[playerid]);
            dini_IntSet(file, "Score", Score[playerid]);
            dini_IntSet(file, "Jail", Jail[playerid]);
            ShowPlayerDialog(playerid, 1245, DIALOG_STYLE_INPUT,""ALB"Bun Venit",""ALB"Account succesfully registred!\n"ALB"Type your password here to log-in","Log-in","Quit");
        }
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new file[128];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file,sizeof(file),"/Users/%s.ini",name);
    if(dini_Exists(file))
    {
        dini_IntSet(file, "Member", Member[playerid]);
        dini_IntSet(file, "Leader", Leader[playerid]);
        dini_IntSet(file, "Status", IsInOrg[playerid]);
        dini_IntSet(file, "Request", request[playerid]);
        dini_IntSet(file, "IsRequesting", IsRequesting[playerid]);
        dini_IntSet(file, "Score", Score[playerid]);
        dini_IntSet(file, "Jail", Jail[playerid]);
    }
    gPlayerLogged[playerid] = 0;
    new playername3[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername3, sizeof(playername3));
    switch(reason)
    {
        case 0: format(string, sizeof(string), "%s has left the server. (Lost Connection)", playername3);
        case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", playername3);
        case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", playername3);
    }
    SendClientMessageToAll(0x33CCFFAA, string);

    return 1;
}

public OnPlayerLogin(playerid,password[])
{
    new file[64];
    new playername3[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername3, sizeof(playername3));

    format(file, sizeof(file), "/Users/%s.ini", playername3);

    if (dini_Exists(file))
    {
        new password2 = num_hash(password);
        if(dini_Int(file,"Password") == password2)
        {
            Member[playerid] = dini_Int(file, "Member");
            Leader[playerid] = dini_Int(file,"Leader");
            IsInOrg[playerid] = dini_Int(file,"Status");
            IsLaw[playerid] = dini_Int(file,"Law");
            request[playerid] = dini_Int(file,"Request");
            IsRequesting[playerid] = dini_Int(file,"Isrequesting");
            SetPlayerScore(playerid, dini_Int(file,"Score"));
            Jail[playerid] = dini_Int(file, "Jail");
        }
        else
        {
            gPlayerLogTries[playerid] += 1;
            ShowPlayerDialog(playerid, 1245, DIALOG_STYLE_INPUT,""ALB"Once againg!",""ALB"You have typed a wrong password\n"ALB"Type your password here to log-in!","Log-in","Quit");
            if(gPlayerLogTries[playerid] == 3) { Kick(playerid); }
            return 1;
        }
    }
    SpawnPlayer(playerid);
    return 1;
}
Reply
#2

pawn Code:
new PlayerData[MAX_PLAYERS][pInfo];

// To Save:
dini_IntSet(file, "Level", PlayerData[playerid][Level]);
Reply
#3

Quote:
Originally Posted by [L3th4l]
View Post
pawn Code:
new PlayerData[MAX_PLAYERS][pInfo];

// To Save:
dini_IntSet(file, "Level", PlayerData[playerid][Level]);
why level and not Admin?

This gives me errors
i have put Level on register/login/disconnect and
on top
pawn Code:
new PlayerData[MAX_PLAYERS][pInfo];
Error
pawn Code:
pwn(46) : error 017: undefined symbol "pInfo"
pwn(46) : error 009: invalid array size (negative, zero or out of bounds)
pwn(441) : error 028: invalid subscript (not an array or too many subscripts): "Level"
pwn(441) : warning 215: expression has no effect
pwn(441) : error 001: expected token: ";", but found "]"
pwn(441) : error 029: invalid expression, assumed zero
pwn(441) : fatal error 107: too many error messages on one line
line 46 is
pawn Code:
new PlayerData[MAX_PLAYERS][pInfo]
and line 441 is
pawn Code:
Level[playerid] = dini_Int(file, "Level");
Reply
#4

Well i used level because didn't noticed you had 'Admin'. Also, you are misinterpreting the usage of enums and variables.

Let's start:
pawn Code:
enum pInfo
{
    Admin
}
new PlayerData[MAX_PLAYERS][pInfo]; // Remember that this variable MUST be below the enum!
To save:
pawn Code:
dini_IntSet(file, "Admin", PlayerData[playerid][Admin]);
To load:
pawn Code:
PlayerData[playerid][Admin] = dini_Int(file, "Admin");
Also remember to clear the variables on player connect:
pawn Code:
public OnPlayerConnect(playerid)
{
    PlayerData[playerid][Admin] = 0;
    return 1;
}
Reply
#5

Quote:
Originally Posted by [L3th4l]
View Post
Well i used level because didn't noticed you had 'Admin'. Also, you are misinterpreting the usage of enums and variables.

Let's start:
pawn Code:
enum pInfo
{
    Admin
}
new PlayerData[MAX_PLAYERS][pInfo]; // Remember that this variable MUST be below the enum!
To save:
pawn Code:
dini_IntSet(file, "Admin", PlayerData[playerid][Admin]);
To load:
pawn Code:
PlayerData[playerid][Admin] = dini_Int(file, "Admin");
Also remember to clear the variables on player connect:
pawn Code:
public OnPlayerConnect(playerid)
{
    PlayerData[playerid][Admin] = 0;
    return 1;
}
The admin="blabla" is being created in the user file, but it doesnt get saved of some reason

EDIT: uhm..im complete blind! i had already """new PlayerInfo[MAX_PLAYERS][pInfo];"""
under enum, so now it does work! So thank you!, without you i had never figure out that i need to use """new PlayerInfo[MAX_PLAYERS][pInfo];""" for the enum info
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)