open.mp forum
[Pawn] distributed enumerators - enums - Printable Version

+- open.mp forum (https://forum.open.mp)
+-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
+--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
+--- Thread: [Pawn] distributed enumerators - enums (/showthread.php?tid=339)



distributed enumerators - enums - hastlaking - 2019-04-18

example:



Code:
enum E_ADMIN_DATA { ? ? ? e_admin_position_none = 0, ? ? ? e_admin_position_admin = 1 } enum E_PLAYER_DATA { ? ? ?e_id, ? ? ?e_name[MAX_PLAYER_NAME], ? ? ?E_ADMIN_DATA:e_admin, } new player[MAX_PLAYERS][E_PLAYER_DATA]; .... public OnPlayerConnect(playerid) { ? ? ?// will it be like so.....? ? ? ?player[playerid][e_admin] = E_ADMIN_DATA:e_admin_position_none; ? ? ?return 1; } RetrieveAdminLevel(playerid, E_ADMIN_DATA:level) { ? ? ? ?switch(level) { .... } ? ? ? ?return level; }



can any of the code i gave as an example will help distributing data into enums/arrays to its usage?


RE: distributed enumerators - enums - JustMichael - 2019-04-18

(2019-04-18, 12:34 AM)hastlaking Wrote: example:



Code:
enum E_ADMIN_DATA { ? ? ? e_admin_position_none = 0, ? ? ? e_admin_position_admin = 1 } enum E_PLAYER_DATA { ? ? ?e_id, ? ? ?e_name[MAX_PLAYER_NAME], ? ? ?E_ADMIN_DATA:e_admin, } new player[MAX_PLAYERS][E_PLAYER_DATA]; .... public OnPlayerConnect(playerid) { ? ? ?// will it be like so.....? ? ? ?player[playerid][e_admin] = E_ADMIN_DATA:e_admin_position_none; ? ? ?return 1; } RetrieveAdminLevel(playerid, E_ADMIN_DATA:level) { ? ? ? ?switch(level) { .... } ? ? ? ?return level; }



can any of the code i gave as an example will help distributing data into enums/arrays to its usage?



As far as I am aware what you are doing is perfectly acceptable. However you don't need to re-tag the assignment since both variables are already tagged with the same tag



so this

PHP Code:
player[playerid][e_admin] = E_ADMIN_DATA:e_admin_position_none;



can be just this

PHP Code:
player[playerid][e_admin] = e_admin_position_none;





this works because `e_admin_position_none` is already part of the enum `E_ADMIN_DATA` so already has the tag

and because you've declared the tag on `e_admin` inside the enum.


RE: distributed enumerators - enums - hastlaking - 2019-04-18

How about for CMD's when i switch to different levels


RE: distributed enumerators - enums - Ihnify - 2019-04-18

(2019-04-18, 10:56 AM)hastlaking Wrote: How about for CMD's when i switch to different levels


An example of what you want? And the not quite understand

From what I understand, this is what you need.

PHP Code:
stock E_ADMIN_DATA:RetrieveAdminLevel(playerid) { ? ??return player[playerid][e_admin]; }