• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] distributed enumerators - enums
#1
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?
  Reply
#2
(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.
Remember to always refer to J0sh as `J0sh...`



@ Networks/Servers

San Andreas Gaming Network (Owner/Founder)

San Andreas Gaming (Owner/Founder)

Grand Theft Cop's n Robber's (Owner)

Britannia Roleplay (Owner/Founder) [Retired]

Alpine RP (Owner/Founder)

Aluminium Network (Maintainer) [Disbanded]

AlphaDM (Tech Support) [Disbanded]



# Services

forum.open.mp (Forum Manager) (Formerly Burgershot.gg

open.mp (Member)



~ Languages/Frameworks

Pawn, C, C, C#, Javascript, Typescript, Lua, Python, Go, Rust, PHP, SQL,

Angular, React, Vue, Svelte, Laravel, Rocket
  Reply
#3
How about for CMD's when i switch to different levels
  Reply
#4
(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];

  Reply


Forum Jump: