PlayerVars abstraction using macros - 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)
+--- Thread: PlayerVars abstraction using macros (
/showthread.php?tid=663676)
PlayerVars abstraction using macros -
PeanutButter - 08.02.2019
Hello,
I'm trying to make an abstraction on top of a PlayerVars array using macros.
I want to write something like this:
PHP код:
SET_VARS PlayerVars [
MAKE_PVAR(ID),
MAKE_PVAR(IsConnected),
MAKE_PVAR(Name[MAX_PLAYER_NAME]),
MAKE_PVAR(SkinID),
Float: MAKE_PVAR(Position[3]),
]
Which should be rewritten as this:
PHP код:
enum enum_PlayerVars {
MAKE_PVAR(ID),
MAKE_PVAR(IsConnected),
MAKE_PVAR(Name[MAX_PLAYER_NAME]),
MAKE_PVAR(SkinID),
Float: MAKE_PVAR(Position[3]),
}
new PlayerVars[MAX_PLAYERS][enum_PlayerVars];
Is it possible to do that? And how should I do it?
Re: PlayerVars abstraction using macros -
PeanutButter - 08.02.2019
The obscurity has a reason. It's part of a framework that I'm trying to make where the implementer does not have to know the underlying data structure to make these type of variables. So I would consider this as an abstraction in the situation that I'm using it in.
I tried this but it's wrong. Is it actually possible to make a macro like that? I don't have much experience with it.
PHP код:
#define SET_MODEL_VARS%0[%1] enum enum_%0 {%1}; new %0[MAX_MODEL_INSTANCES][enum_%0];