Defining help
#1

Hello

I have a problem.

I want to use variables like this:

PlayerInfo[playerid][ContactName][0] = "Test";
PlayerInfo[playerid][ContactNumber][0] = 5456;

Code:
enum pInfo
{
     ContactNumber[15], // 15 int variables made
     ContactName[30][15], // 15 string variables, but.. i get error(This is line 386)
}; [//Line 387
new PlayerInfo[50][pInfo];
Error:

C:\Users\...\Desktop\samp03e_svr_R2_win32\gamemode s\...(386) : error 001: expected token: "}", but found "["
C:\Users\...\Desktop\samp03e_svr_R2_win32\gamemode s\...(387) : error 010: invalid function or declaration


So how can i resolve this problem?
Reply
#2

pawn Code:
enum pInfo
{
     ContactNumber[15],
     ContactName[30][15] // on the last, we don't use ","
};
new PlayerInfo[50][pInfo];
Reply
#3

It didn`t help, the thing is that there are ContactName[30][15]. Two []. That`s wrong i think, but how i resolve this.
Reply
#4

Bring Up My Post, because i need help very fast, because i got errors because of it, and all i can do is waiting:P Someone knows the solution?
Reply
#5

pawn Code:
PlayerInfo[playerid][ContactName][0] = "Test"; // or format
PlayerInfo[playerid][ContactNumber] = 5456;
Reply
#6

This doesn't work.

pawn Code:
PlayerInfo[playerid][ContactName][0] = "Test";
You're going to have to use the format function for this.

pawn Code:
format(PlayerInfo[playerid][ContactName][0], 30, "Test");  // change test the names.
Reply
#7

I`m going to use it like this:

PlayerInfo[playerid][ContactName][0] = "My0Contact";
PlayerInfo[playerid][ContactName][1] = "My1Contact";
PlayerInfo[playerid][ContactNumber[0] = 3555;
PlayerInfo[playerid][ContactNumber[1] = 43267;

But the problem is in definition.

They are defined like this:
Code:
enum pInfo
{
     ContactNumber[15], // 15 int variables made
     ContactName[30][15], // 15 string variables, (30 is lenght of string) but.. i get error(This is line 386)
}; //Line 387
new PlayerInfo[50][pInfo];
But in definition i get this errors:

C:\Users\...\Desktop\samp03e_svr_R2_win32\gamemode s\...(386) : error 001: expected token: "}", but found "["
C:\Users\...\Desktop\samp03e_svr_R2_win32\gamemode s\...(387) : error 010: invalid function or declaration



// EDIT

Testing again
Reply
#8

Use my method above.
Reply
#9

Are you sure the problem is in using not in definition?
Reply
#10

Quote:
Originally Posted by Larry123
View Post
Are you sure the problem is in using not in definition?
It is, didnt noticed it in the other topic

You can only use one dimension within enum because an enum is just a list of constant variables!

The easist way would be to create a new array
pawn Code:
#define MAX_CONTACTS (15)

enum cInfo {
     ContactNumber,
     ContactName[30]
};
new ContactInfo[sizeof PlayerInfo][MAX_CONTACTS][cInfo];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)