Get data from an enum within another script file
#1

Hello everyone, I was wondering whether it is possible to make a function which would fetch data from an enum. I want to do this so I can access the enum's data in another file that I have included like this:

Код:
// The main gamemode file
#include "scripts/anotherfile.pwn"
An example of what I want to achieve:

Код:
// The main gamemode file
enum Ply_Data
{
	Ply_Level,
	Float:Ply_Armour
}
new Ply_Info[MAX_PLAYERS][Ply_Data];

FetchDataFromPly_Data(playerid, Ply_Data:data)
{
	return Ply_Info[playerid][Ply_Data:data];
}
and then in another file I do this:

Код:
// The included file
hook OnPlayerConnect(playerid)
{
	if(FetchDataFromPly_Data(playerid, Ply_Data:Ply_Level) > 0)
	{
		// Maybe set his level to 3 with a SetDataToPly_Data function??
	}
}
It is currently giving me an error in the included file that the symbol "Ply_Level" is undefined.

Would be glad if someone can help me solve this
Reply
#2

Try using
Код:
Ply_Info[MAX_PLAYERS][Ply_Data] //place the things inside the Ply_Data instead of the " Ply_Data "
/*
Example:
If(FetchDataFromPly_Data(playerid, Ply_Data:Ply_Level) > 0)
{
      Ply_Info[playerid][Ply_Level] = 3;
}
*/
Reply
#3

Quote:
Originally Posted by SytonicX
Посмотреть сообщение
Try using
Код:
Ply_Info[MAX_PLAYERS][Ply_Data] //place the things inside the Ply_Data instead of the " Ply_Data "
/*
Example:
If(FetchDataFromPly_Data(playerid, Ply_Data:Ply_Level) > 0)
{
      Ply_Info[playerid][Ply_Level] = 3;
}
*/
I don't understand what you mean by "place the things inside the Ply_Data instead of the " Ply_Data ".
Also I can't access "Ply_Info" in the other file. It is declared in the main file only. That's the point of creating such a function at first.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)