SA-MP Forums Archive
Get data from an enum within another script file - 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: Get data from an enum within another script file (/showthread.php?tid=663374)



Get data from an enum within another script file - Nathan94 - 29.01.2019

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


Re: Get data from an enum within another script file - SytonicX - 29.01.2019

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;
}
*/



Re: Get data from an enum within another script file - Nathan94 - 29.01.2019

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.