Getting the name from an enum -
tom_jonez - 25.03.2009
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.
Re: Getting the name from an enum -
Delused - 25.03.2009
Код:
enum pInfo
{
username,
password,
email,
datejoined,
id,
loggedin,
score,
money,
bankstate,
adminlevel,
regular,
armyaccess,
madexaccess,
robrank,
ownedvehicle
};
new Players[MAX_PLAYERS][pInfo];
Re: Getting the name from an enum -
Dujma - 25.03.2009
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?
Re: Getting the name from an enum -
MenaceX^ - 25.03.2009
OnPlayerConnect
pawn Код:
GetPlayerName(playerid,Players[playerid][username],24);
And your way isn't a good one for my opinion.
Re: Getting the name from an enum -
tom_jonez - 25.03.2009
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?
Re: Getting the name from an enum -
MenaceX^ - 25.03.2009
No not really sorry.
Re: Getting the name from an enum -
tom_jonez - 25.03.2009
Код:
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
Re: Getting the name from an enum -
MenaceX^ - 25.03.2009
So you want like a registation ID on the player enum? Each player has his own ID?
Re: Getting the name from an enum -
ICECOLDKILLAK8 - 25.03.2009
i think he means instead of typing Players[playerid][id] he wants to be able to type pInfo:5, Why?
Re: Getting the name from an enum -
MenaceX^ - 25.03.2009
But what
pInfo:5 should do?