Help with strings
#1

What's worng here?

Код:
	CMD:ad(playerid, params[]) {
		new string[128], adprice, result[70];
		if(sscanf(params,"s[70]", result)) return SendClientMessage(playerid, -1, "Use: /ad [text]");
		if(scorelevel[playerid] < 500) return SendClientMessage(playerid, COLOR_RED, "You need 500 scores to use this command!");
		adprice = 1000;
		if(GetPlayerMoneyEx(playerid) < adprice) {
			format(string, sizeof(string), "You do not have %i $", adprice);
			SendClientMessageToAll(COLOR_WHITE, string);
			return 1;
		}
		if(mandouAD[playerid] == false) {
			SendClientMessage(playerid, -1, "Have you ever sent a recent announcement! Wait!");
			return 1;
		}
		new facdocara[32];
		if(fmembro[playerid] == 0) {
			facdocara = "NO-FACTION";
		}
		else if(fmembro[playerid] > 0) {
			new facid = fmembro[playerid];
			facdocara = FactionInfo[facid][facname];
		}
		format(string, sizeof(string), "[AD] [%s] %s(ID:%i): %s", facdocara, PlayerName(playerid), playerid, result);
		SendClientMessageToAll(COLOR_AD, string);
		GivePlayerMoneyEx(playerid,-adprice);
		mandouAD[playerid] = true;
		SetTimerEx("AdAgain", 60000, 0, "i", playerid);
		return 1;
    }
Error:
Код:
warning 229: index tag mismatch (symbol "FactionInfo")
Line
Код:
facdocara = FactionInfo[facid][facname];
FactionInfo
Код:
enum Factioninfos
{
    ID,
    facname[32],
	...
}
new FactionInfo[MAX_FACTIONS][Factioninfos];
Reply
#2

You can't do that (enums are not arrays) only way
pawn Код:
FactionInfo[facid][facname] = facdocara;
but not
pawn Код:
facdocara = FactionInfo[facid][facname];
solution:
pawn Код:
strcat(facdocara, FactionInfo[facid][facname]);
Reply
#3

Quote:

but not

That is not true.

You can do that if the arrays have the same size

For example:

PHP код:
#include <a_samp>
enum e {
    
str[32]
};
new 
test[2][e];
main() {
    new 
tmp[32],st[32] = "Hallo";
    
test[0][str] = st;
    
tmp test[0][str];

Works perfect

Greekz
Reply
#4

Ok yes its working, problem is in first letter if you use
pawn Код:
enum E {
warning 229: index tag mismatch (symbol "FactionInfo")

enum Factioninfos - not working
enum factioninfos - working
Reply
#5

Then i cant use high letter on enum's? Need change:
Код:
enum Houseinfos
{
    ID,
    Float:InPosX,
    Float:InPosY,
    Float:InPosZ,
    Float:OutPosX,
    Float:OutPosY,
    Float:OutPosZ,
    World,
	Price,
	Owner,
	Locked,
	Dono[30],
	Money,
	Maconha,
	FHQ,
    Interior,
	hlastlogin
}
new HouseInfo[MAX_HOUSES][Houseinfos];
To
Код:
enum houseinfos
{
    ID,
    Float:InPosX,
    Float:InPosY,
    Float:InPosZ,
    Float:OutPosX,
    Float:OutPosY,
    Float:OutPosZ,
    World,
	Price,
	Owner,
	Locked,
	Dono[30],
	Money,
	Maconha,
	FHQ,
    Interior,
	hlastlogin
}
new HouseInfo[MAX_HOUSES][houseinfos];
Reply
#6

If you want copy string like this
pawn Код:
new dono[30];
dono = houseinfos[houseid][Dono];
you need change
pawn Код:
enum Houseinfos
to
pawn Код:
enum houseinfos
otherwise you need use strcat

pawn Код:
strcat(dono, Houseinfos[houseid][Dono]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)