Print enum variables. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Print enum variables. (
/showthread.php?tid=272629)
Print enum variables. -
AhEaD_ - 29.07.2011
I have a pretty big enum and I want to print all it variables.
For example:
pawn Код:
enum
{
Kills,
Deaths,
Money,
PlayTime
}
I want a code that prints:
Kills
Deaths
Money
PlayTime
I know we can use enum loop to get the enum values, but I don't know how to do it to get the enum variables. Is it possible ?
Re: Print enum variables. -
Godhimself - 29.07.2011
pawn Код:
//enum..
enum pInfo
{
Kills,
Deaths,
Money,
PlayTime
}
new PlayerInfo[MAX_PLAYERS][pInfo];
//Wherever..
new string[100];
format(string, sizeof(string), "Kills: %d, Deaths: %d, Money: %d, PlayTime: %d", PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], GetPlayerMoney(playerid), PlayerInfo[playerid][PlayTime]);
SendClientMessage(playerid, 0x0, string);
EDIT:
If you want it to print in logs do:
pawn Код:
//Wherever..
new string[100];
format(string, sizeof(string), "Kills: %d, Deaths: %d, Money: %d, PlayTime: %d", PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], GetPlayerMoney(playerid), PlayerInfo[playerid][PlayTime]);
printf(string);
Re: Print enum variables. -
AhEaD_ - 30.07.2011
It's not that what I meant...
Whatever, I don't think its possible anyway.
Re: Print enum variables. -
CaHbKo - 01.08.2011
I know what you mean. You want to loop through an enum like it was an array. I need that too, I'm trying to make a function that saves all the enum data to a file (finally found use for tagof())
I think it's possible because sscanf somehow stores all the required info in the enum without actually passing it their names.
Quote:
Originally Posted by ******
pawn Код:
enum E_DATA { E_DATE_C, Float:E_DATA_X, E_DATA_NAME[32], E_DATA_Z }
main { new var[E_DATA]; sscanf("1 12.0 Bob c", "e<ifs[32]c>", var); }
|