[SOLVED]array problem :D
#1

im making a clan wars server /..... this is what i have
i am trying to make it so that if it recognizes the name then it will assign the person to a gang
Код:
new tc_t [] [] = {
	{"[TC]airsoft222"},
	{"[TC]Flyer"},
	{"[TC]Big_Al"},
	{"[TC]lizardking"}
};

new gt_t [][] =
{
	"[GT]JKL",
	"[GT]Kaweashkar",
	"[GT]eddie_quin",
	"[GT]KrazY",
	"[GT]Devin",
	"[GT]Wake",
	"[GT]T_Killah"
};
new gtr_t [][] =
{
	"[GTR]Mite",
	"[GTR]Big_Al",
	"[GTR]melis256",
	"[GTR]Ghostrider_09",
	"[GTR]hunter_cypert"
};
and below that i have

Код:
public s2t1(playerid)
{
	new name[300];
	GetPlayerName(playerid,name,sizeof(name));
	if(!strcmp(name,tc_t))
	gTeam[playerid] = tc;
	return 1;
}
public s2t2(playerid)
{
	new name[300];
	GetPlayerName(playerid,name,sizeof(name));
	if(!strcmp(name,gt_t))
	gTeam[playerid] = gt;
	return 1;
}
public s2t3(playerid)
{
	new name[300];
	GetPlayerName(playerid,name,sizeof(name));
	if(!strcmp(name,gtr_t))
	gTeam[playerid] = gtr;
	return 1;
}
and the errors i get are

Код:
C:\Users\Chandler\Desktop\[TC][GT][GTR]\gamemodes\ct.pwn(353) : error 048: array dimensions do not match
C:\Users\Chandler\Desktop\[TC][GT][GTR]\gamemodes\ct.pwn(361) : error 048: array dimensions do not match
C:\Users\Chandler\Desktop\[TC][GT][GTR]\gamemodes\ct.pwn(369) : error 048: array dimensions do not match
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#2

I tried helping him. But I couldn't figure it out.
Reply
#3

so gteam is a variable and you're trying to put a string into that variable if I understood correctly, you'd need to make gteam a string and then format it
Reply
#4

Код:
static gTeam[MAX_PLAYERS];
and that is on top of my script... do i still have to make it into a string ?
Reply
#5

Where is gtr created in your script?
Reply
#6

try:
pawn Код:
new
    tc_t[][] =
{
    {"[TC]airsoft222"},
    {"[TC]Flyer"},
    {"[TC]Big_Al"},
    {"[TC]lizardking"}
};


forward s2t1(playerid);
public s2t1(playerid)
{
    new
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    for(new i; i < sizeof(tc_t); i++)
    {
        if(!strcmp(name, tc_t[i]))
        {
            gTeam[playerid] = tc;
//          printf("Teszt: %s | %s", tc_t[i], name);
            return true;
        }
    }
    return false;
}
Reply
#7

Please specify the lines 353, 361 and 369 in your code.
And yea Phento's code should work.
Reply
#8

"[]" this sizes the array for you, it allocates the number of elements required when it's first used so the compiler/script doesn't have to keep looking up the size each time the variable is used. Keep this in mind when using that method or even better just count the size yourself and add it after before compiling (the largest string entry).

I'm not correcting anyone btw, I'm just giving out some information incase anyone wonders.

Ps. "lizardking", Doors fan ay ? "I'm the lizard king and I can do anything"
Reply
#9

thanks for all the help no mor errors
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)