Enums or not? -
Adi007 - 15.07.2015
enum PlayerInfo
{
ConnectedTime,
AnotherVariable
};
new pInfo[MAX_PLAYERS][PlayerInfo];
OR
new ConnectedTime[MAX_PLAYERS],AnotherVariable[MAX_PLAYERS];
Which variable definition is better?
I ask this because currently i use first method (enum) and i have a variable named "ConnectedTime" like this
pInfo[playerid][ConnectedTime] = gettime(); // This is at login dialog.
I use some math like this:
new anothervar=gettime()-pInfo[playerid][ConnectedTime]
sometimes, anothervar is 0, but this is not the true...
The enums variables are the reason? They can't store big numbers like timestamps?
Sorry for bad english.
AW: Enums or not? -
Kaliber - 15.07.2015
Quote:
Originally Posted by Adi007
They can't store big numbers like timestamps?
|
This is bullshit
In Pawn all integer are 32-Bit Integer
And to the declaration question, it's doesn't matter
You can choose your favourite style
Re: Enums or not? -
Adi007 - 15.07.2015
Ok, thanks.
Now i have another question.
I have a problem which appear only sometimes after the server stayed online more than 24 hours without an restart:
-GeoIP plugin shows at country, ISP and City everytime "unknown".
-I can't add NPCs (some problem with editing npcmodels i think).
-I can't send rcon commands.
Everybody knows why this happens...and when?
Re: Enums or not? -
Sithis - 15.07.2015
Once your gamemode gets larger and you need to store more variables, I prefer enums because your code is easier to interpret. It all comes down to personal preference.
Re: Enums or not? -
Stanford - 15.07.2015
Enumerators make the code very organized, at least for me, same if you want to do defintions of something for example:
pawn Код:
enum {
NUMBER_ONE = 1,
NUMBER_TWO,
NUMBER_THREE
}
these three under the enum will get their proper values - number two will get two number three will get three (it's like defining all of them one by one, but I find this easier)
so yeah its personal preference!
I hope I helped any feedback is appreciated!
AW: Enums or not? -
Kaliber - 15.07.2015
Dont do that...because then you change the index...
why you would start with 1...instead of 0?
Re: Enums or not? -
Adi007 - 15.07.2015
Ok guys thanks for answers but try answer this please:
Now i have another question.
I have a problem which appear only sometimes after the server stayed online more than 24 hours without an restart:
-GeoIP plugin shows at country, ISP and City everytime "unknown".
-I can't add NPCs (some problem with editing npcmodels i think).
-I can't send rcon commands.
Everybody knows why this happens...and when?
Re: Enums or not? -
Stanford - 15.07.2015
The point was to change the index to have correct values for defines
Re: Enums or not? -
Adi007 - 16.07.2015
Quote:
Originally Posted by Adi007
Ok guys thanks for answers but try answer this please:
Now i have another question.
I have a problem which appear only sometimes after the server stayed online more than 24 hours without an restart:
-GeoIP plugin shows at country, ISP and City everytime "unknown".
-I can't add NPCs (some problem with editing npcmodels i think).
-I can't send rcon commands.
Everybody knows why this happens...and when?
|
bumb for this... (DON'T answer for enums anymore).