SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   new or enum? (https://forum.sa-mp.com/showthread.php?t=671937)

Edvukas 19/01/2020 08:42 PM

new or enum?
 
Hi, what should I choose for storing variables? Like admin, vip, cuffed, has something etc... So Enum or new?

homelessdrop 19/01/2020 09:36 PM

Re: new or enum?
 
Enum's

Edvukas 20/01/2020 08:55 PM

Re: new or enum?
 
Why enums?

DomagojSellug 20/01/2020 09:14 PM

Re: new or enum?
 
pawn Code:
enum PlayerData
{
    Password,
    Admin,
    Money,
    Score
}
new Player[MAX_PLAYERS][PlayerData];

RogueDrifter 20/01/2020 09:44 PM

Re: new or enum?
 
Quote:

Originally Posted by Edvukas (Post 4128844)
Why enums?

Makes it easier to manage your script and access those variables through the enumerator when things get too much, such as player data (vip,admin,level...etc).

For one off things that aren't related and can't be attached into a group of variables (groups such as player data or vehicle data) you can declare those unique variables in a single shape using 'new' or 'static' depending on the usage.

Does either affect performance? No it's just to not make your project look like spaghetti code.


All times are GMT. The time now is 02:54 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.