Problem string strcat
#1

Any can help me to fix it?

Error
Код:
strcat(name, FactionInfo[facid][facname]);
Код:
warning 224: indeterminate array size in "sizeof" expression (symbol "maxlength")
CODE \/


Код:
	CMD:fcreate(playerid,params[])
	{
		//new string[40],
		new query[128], localfname[32];
		if(sscanf(params,"s", localfname)) return SendClientMessage(playerid, -1, "Use: /fcreate [name]");
		//if(scorelevel[playerid] < 500) return SendClientMessage(playerid, COLOR_RED, "Vocк precisa ter score/level 500 para criar uma faction");
		if(GetPlayerMoneyEx(playerid) < 500000) return SendClientMessage(playerid, COLOR_RED, "You do not have 500.000");
		if(fmembro[playerid] > 0) return SendClientMessage(playerid, COLOR_RED, "Vocк jб tem uma faction");

		format(query,sizeof query,"SELECT COUNT(*) AS `exists` FROM factions WHERE facname='%s'",localfname);
		mysql_function_query(ConnectMYSQL,query,true,"r@MySQL_CheckFaction","ds",playerid, localfname);
		// /\ importante deixar o cache como TRUE.
		return 1;
	}
Код:
public r@MySQL_CheckFaction(playerid, name[]) {
	new field[11], exists;
	cache_get_field_content(0, "exists", field, ConnectMYSQL);
	exists = strval(field);

	if(exists) {
		// jб existe
		return 1;
	}

	new query[128];
	format(query, sizeof query, "INSERT INTO factions (facname) VALUES ('%s');", name);
	mysql_function_query(ConnectMYSQL,query,true,"r@MySQL_CreateFaction","d",playerid);
	
	new facid = fmembro[playerid];
	strcat(name, FactionInfo[facid][facname]);	// warning 224: indeterminate array size in "sizeof" expression (symbol "maxlength")
	return 1;
}
public r@MySQL_CreateFaction(playerid) {
	new novafacid = cache_insert_id(ConnectMYSQL);
	fmembro[playerid] = novafacid;
	fcargo[playerid] = 5;
	GivePlayerMoneyEx(playerid,-500000);
	SendClientMessage(playerid,-1,"Faction successfully created!");
	
	new ept[30];
	ept = "Empty";
	new seunome[30];
	seunome = PlayerName(playerid);
	FactionInfo[fmembro[playerid]][lider1] = seunome;
	FactionInfo[fmembro[playerid]][lider2] = ept;
	FactionInfo[fmembro[playerid]][lider3] = ept;
	FactionInfo[fmembro[playerid]][membro1] = ept;
	FactionInfo[fmembro[playerid]][membro2] = ept;
	FactionInfo[fmembro[playerid]][membro3] = ept;
	FactionInfo[fmembro[playerid]][membro4] = ept;
	FactionInfo[fmembro[playerid]][membro5] = ept;
	FactionInfo[fmembro[playerid]][membro6] = ept;
	FactionInfo[fmembro[playerid]][membro7] = ept;
	FactionInfo[fmembro[playerid]][membro8] = ept;
	FactionInfo[fmembro[playerid]][membro9] = ept;
	FactionInfo[fmembro[playerid]][membro10] = ept;
	FactionInfo[fmembro[playerid]][membro11] = ept;
	FactionInfo[fmembro[playerid]][membro12] = ept;
	return 1;
}
Reply
#2

You can do this:

PHP код:
strcat(nameFactionInfo[facid][facname], sizeof(name));
//or this:
format(name,sizeof(name),FactionInfo[facid][facname]); 
Reply
#3

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
You can do this:

PHP код:
strcat(nameFactionInfo[facid][facname], sizeof(name));
//or this:
format(name,sizeof(name),FactionInfo[facid][facname]); 
I want put
FactionInfo[facid][facname] = name;

Idk work with strings
I try your codes \/
Код:
strcat(name, FactionInfo[facid][facname], sizeof(name));
Код:
warning 224: indeterminate array size in "sizeof" expression (symbol "")
...


Код:
format(name,sizeof(name),FactionInfo[facid][facname]);
Код:
warning 224: indeterminate array size in "sizeof" expression (symbol "")
Reply
#4

Use format
Reply
#5

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Use format
How?
Reply
#6

Show us how you identify the variable facname

Using format can be done by this method:

Код:
format(name,sizeof(name),"%s",FactionInfo[facid][facname]);
Reply
#7

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
Show us how you identify the variable facname

Using format can be done by this method:

Код:
format(name,sizeof(name),"%s",FactionInfo[facid][facname]);
Ty to try help
But it's don't work too...
Код:
warning 224: indeterminate array size in "sizeof" expression (symbol "")
Reply
#8

You need set faction name to enum so should be

pawn Код:
FactionInfo[facid][facname][0] = EOS; // clear string
strcat(FactionInfo[facid][facname], name, 30); // 30 is the size of facname[30] in enum
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)