Getting the name from an enum
#1

So i have this enum for an array here:
pawn Код:
enum pInfo
{
    username,
    password,
    email,
    datejoined,
    id,
    loggedin,
    score,
    money,
    bankstate,
    adminlevel,
    regular,
    armyaccess,
    madexaccess,
    robrank,
    ownedvehicle
};
Im making an sql gamemode and so i have a command saying
pawn Код:
public SavePlayerVariables(playerid)
{
    Players[playerid][money] = GetPlayerMoney(playerid);
    Players[playerid][score] = GetPlayerScore(playerid);
    new update[256],field[256],point,req[256],name[28];
    GetPlayerName(playerid,name,28);
    point = 18;
    format(update,sizeof(update),"UPDATE `users` SET score='%d', money='%d' WHERE username='%s' LIMIT 1",Players[playerid][score],Players[playerid][money],name);
    for(new i = 0; pInfo:i < pInfo; i++)
    {
      format(field,sizeof(field),"%s='%d', ",pInfo:i,Players[playerid][pInfo:i]);
      strins(update,field,point);
      point += sizeof(field);
    }
    format(req,sizeof(req),"WHERE username='%s' LIMIT 1",name);
    strins(update,req,point);*/
    samp_mysql_query(update);
    printf("MySQL Query Executed: %s",update);
    return 1;
}
But what i wanna know is how do i get the name of the actual array i guess ud call it in the enum. Like how do i extract score from the enum pInfo and write it out? when i say that i mean actually write out score, not the variable stored in it. Please help.
Reply
#2

Код:
enum pInfo
{
username,
password,
email,
datejoined,
id,
loggedin,
score,
money,
bankstate,
adminlevel,
regular,
armyaccess,
madexaccess,
robrank,
ownedvehicle
};

new Players[MAX_PLAYERS][pInfo];
Reply
#3

Quote:
Originally Posted by Delused
Код:
enum pInfo
{
username,
password,
email,
datejoined,
id,
loggedin,
score,
money,
bankstate,
adminlevel,
regular,
armyaccess,
madexaccess,
robrank,
ownedvehicle
};

new Players[MAX_PLAYERS][pInfo];
And the difference beside the indentation is?
Reply
#4

OnPlayerConnect

pawn Код:
GetPlayerName(playerid,Players[playerid][username],24);
And your way isn't a good one for my opinion.
Reply
#5

No, in the enum i want to type in pInfo:5 and i want it to write out the id. 5 corresponds to id in the enum array. Get what i mean?
Reply
#6

No not really sorry.
Reply
#7

Код:
enum pInfo
{
username,
password,
email,
datejoined,
id,
loggedin,
score,
money,
bankstate,
adminlevel,
regular,
armyaccess,
madexaccess,
robrank,
ownedvehicle
};
Now for my saved variables command, what i do is format the update query to say "UPDATE users SET " and then i go for(new i = 0; pInfo:i < pInfo; i++) to count the rows. Now under that i have it inserting a string after the end of the update one above ^^ and it now says "UPDATE users SET score = 'ex: 996', " but for it to write out the score the word score, i need to figure out how to pull it out of the enum
Reply
#8

So you want like a registation ID on the player enum? Each player has his own ID?
Reply
#9

i think he means instead of typing Players[playerid][id] he wants to be able to type pInfo:5, Why?
Reply
#10

But what
pInfo:5 should do?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)