Can I use such arrays?
#1

Hello.

I'm currently working on battlefield server (writting from scratch) and after testing I noticed, that console outputs not array values from enum, but weird symbols and smiles.

So, my question is:

Can I use such arrays?
Код:
enum pInfo
{
	// 0 - assault, 1 - engineer, 2 - sniper, 3 - medic
	rank_lvl, // 30 total
	experience, // current experience points
	Float:health, Float:armor,
	credits, kills, deaths, score, timePlayed,
}
new PlayerInfo[MAX_PLAYERS][4][pInfo];
There gonna be 4 classes per player and each class will have different stats and player will need to increase stats and etc individually.

For example: Assault class rank_lvl = PlayerInfo[playerid][0][rank_lvl];
Reply
#2

Sometimes that happens when for example, instead of printing an integer, you're using '%s' which is for strings or the opposite, I don't remember.

Would you mind to show us the part that prints the values?
Reply
#3

pawn Код:
enum pInfo
{
    ranklvl,
    experience,
    Float:health,
    Float:armor,
    credits,
    kills,
    deaths,
    score,
    timePlayed,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#4

Quote:
Originally Posted by faff
Посмотреть сообщение
pawn Код:
enum pInfo
{
    ranklvl,
    experience,
    Float:health,
    Float:armor,
    credits,
    kills,
    deaths,
    score,
    timePlayed,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
I'm using such enum for account data, but as I said, I have four characters (classes) per account, so I need to store classes in different way. I need to have individual enum for each character (class).
Reply
#5

Quote:
Originally Posted by Darth1993
Посмотреть сообщение
I'm using such enum for account data, but as I said, I have four characters (classes) per account, so I need to store classes in different way. I need to have individual enum for each character (class).
Ahh, I dont know if it's possible.
I never tested it.. so ehmm.. I dont know.
Reply
#6

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Sometimes that happens when for example, instead of printing an integer, you're using '%s' which is for strings or the opposite, I don't remember.

Would you mind to show us the part that prints the values?
I just noticed that I'm using printf(PlayerInfo[playerid][classid][experience]);

Changed to printf("Exp: %d", PlayerInfo[playerid][classid][experience]); and it's showing the right value.

So, problem solved.
Reply
#7

If your going to use something like this....

new PlayerInfo[MAX_PLAYERS][4][pInfo];

At least make some defines.....

#define MAX_CLASSES 4
#define CLASS_CLASSNAME1 0
#define CLASS_CLASSNAME2 1
#define CLASS_CLASSNAME3 2
#define CLASS_CLASSNAME4 3

This is much easier to keep track of what your writing.

new PlayerInfo[MAX_PLAYERS][MAX_CLASSES ][pInfo];

for(new i = 0; i < MAX_CLASSES; i++)

if(PlayerInfo[playerid][CLASS_CLASSNAME][p_Kill] == 10) KillSpree = true;

It looks a lot better I think.
Reply
#8

For an array inside an enum (example would be pInfo) you'd have to do
PlayerInfo[playerid][pInfo][array];
So, for this you should try
pawn Код:
enum pInfo
{
  kills[4],
  deaths[4],
  score[4],
  // The rest of your pInfo enumerator.
}
new PlayerInfo[MAX_PLAYERS][pInfo];

// Insert this and edit where needed and appropriate.
if(PlayerInfo[playerid][pClass] == 0) { PlayerInfo[playerid][kills][0]++; } // And so on.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)