Just few questions about enums
#1

Hey guys. I have few questions about enums. Is it okay if I have lot of enums because I have around 220 enums which are all player's stats and I don't want my server to be laggy. And also, is it a smart idea to beside files for player's stats use files to store vehicle's stats for each player. My enum for PlayerInfo has vModel, vColor1, vColor2 and so on, but would be a good idea to make system which saves player's vehicles to different file, and loads it into different enum? Thanks!

-Best regards, Dominik
Reply
#2

Your server won't begin lagging of it, dont worry, I got like over 200 enums in my script and nothing is wrong with that, also that thing with the vehicle's stats, dont worry about that either, so yes, it would be an good idea.

- Yours, LyNet
Reply
#3

As far as my knowledge goes... I dont think having so many enums is a bad thing, to make things more nicer and better to find you could make seperate data base files or a new folder with all the vehicle files in it (depending what you use for saving, you could use my filterscript for SQLite as a starting base).

I hope I helped you out and good luck!
Reply
#4

I assume you meant 220 indexes of enums and not 220 enums instead.

I used to use an enum for the player's data as well but not anymore. I can now use char whenever it's possible and reduce the size!

Well, that depends on what you use. For example, I guess y_ini would be fine but some other file systems not (since they're slow). Though, I'd go for SQL.
Reply
#5

thanks guys for fast reply! I appreciate it. Voxel, I will try to do something with your Tutorial about SQLite, but once I learn SQL.

Can anyone else say something about enums? I just want to make sure that I'm doing a good thing with having lot of enums.
EDIT: yeah Konstantinos, I meant 220 indexes. 220 enums would be too much I think. Can you show me some example of using char for stats, nothing too big.
Reply
#6

Quote:
Originally Posted by dominik523
Посмотреть сообщение
thanks guys for fast reply! I appreciate it. Voxel, I will try to do something with your Tutorial about SQLite, but once I learn SQL.

Can anyone else say something about enums? I just want to make sure that I'm doing a good thing with having lot of enums.
As Konstantinos said, as long as you have 220 indexes under 1 enum and not 220 enums seperate then there is no problem, Good luck with my filterscript and tutorial! SQLite is not that hard when you look at it for a few mins... I also suggest you take a look at Konstantino's tutorial for SQLite as that is what i used as well!

Nothing really left to say, allthough you could also check out the char stuff Konstantinos talked about (I use this aswell).

Good luck!
Reply
#7

Sure. When you want to store something that it will ALWAYS be in bounds of 0-255, then that's the part char is used (in 1D array).

For example:
pawn Код:
new
    User_Admin[ MAX_PLAYERS char ],
    bool: User_Muted[ MAX_PLAYERS char ]
;

// OnPlayerConnect:
User_Admin{ playerid } = 0;
User_Muted{ playerid } = false;

// NOTE: You must use { } instead of [ ] for the index of the player's ID.

// Few examples:

// We mute a player, so we set it to true:
User_Muted{ playerid } = true;

// We want to check if the player is not muted:
if( !User_Muted{ playerid } ) // do something

// Or we want to check if the player is already muted so we cannot re-mute again:
if( User_Muted{ playerid } ) // return error message that the player is already muted.
The admin level is let's say 0-10 so we can use char since it's always between 0 and 255.

You may used to reset few variables with -1 but with char using -1 will wrap the value until it's in bounds so use 255 instead.
Reply
#8

got it, thank you so much Konstantinos and Voxel
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)