Error 035: argument type mismatch (argument 1)
#1

Hi,
a have a little problem in my script. When I want to compile I have such error:
Код:
(480) : error 035: argument type mismatch (argument 1)
Here is my code, if you could tell me what's wrong
I hope you'll do it! Thanks.

Код:
new ColorName[6][20] = {
{"COLOR_WHITE"},
{"COLOR_FADE1"},
{"COLOR_FADE2"},
{"COLOR_FADE3"},
{"COLOR_FADE4"},
{"COLOR_FADE5"},
};
Код:
if(strcmp(cmd, "/write", true) == 0)
	{
		new string[256], tmp[256], kolor;
	    if(IsPlayerConnected(playerid))
	    {
	    	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "Mode: /write [color-id] [result]");
			}
			kolor = strval(tmp);
			if (IsPlayerAdmin(playerid))
			{
				new length = strlen(cmdtext);
				while ((idx < length) && (cmdtext[idx] <= ' '))
				{
					idx++;
				}
				new offset = idx;
				new result[256];
				while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
				{
					result[idx - offset] = cmdtext[idx];
					idx++;
				}
				result[idx - offset] = EOS;
				if(!strlen(result))
				{
					SendClientMessage(playerid, COLOR_WHITE, "Mode: /write [color-id] [result]");
					return 1;
				}
		   		format(string, sizeof(string), "%s", result);
  Line: 480 			SendClientMessageToAll(ColorName[kolor], string);
				printf("%s", string);
			}
		}
		return 1;
	}
Reply
#2

try
#define WHITE 0xFFFFFFAA
and put in argument 1 WHITE
( i dont know why are trying to use new becouse colors have to be defined )
Reply
#3

new ColorName[6][0] = {
{"COLOR_WHITE"},
{"COLOR_FADE1"},
{"COLOR_FADE2"},
{"COLOR_FADE3"},
{"COLOR_FADE4"},
{"COLOR_FADE5"},
};

Must be [0] not [20]!

Change
SendClientMessageToAll(ColorName[kolor], string);


to
SendClientMessageToAll(ColorName[kolor][0], string);
Reply
#4

Try:

pawn Код:
new ColorName[6] = {
{COLOR_WHITE},
{COLOR_FADE1},
{COLOR_FADE2},
{COLOR_FADE3},
{COLOR_FADE4},
{COLOR_FADE5}
};
Edit: Typo

You did #define those colours right?
Reply
#5

Quote:
Originally Posted by Zh3r0
Посмотреть сообщение
new ColorName[6][0] = {
{"COLOR_WHITE"},
{"COLOR_FADE1"},
{"COLOR_FADE2"},
{"COLOR_FADE3"},
{"COLOR_FADE4"},
{"COLOR_FADE5"},
};

Must be [0] not [20]!

Change
SendClientMessageToAll(ColorName[kolor], string);


to
SendClientMessageToAll(ColorName[kolor][0], string);
Dont post unless you know what you are talking about please, it just confuses people.


Since this array is filled with strings, it needs to have another dimension with at LEAST 2 cells (one character, and a terminating NULL character - this would be better done as an integer simply storing the ascii value of the character, but its just an example). The 20 however is wrong, well lets just say its not needed actually, as it isnt actually "wrong".

What you SHOULD be doing is leaving the second dimension completely blank and letting it fill itself in (BOTH dimensions should be doing this, actually, but meh).



Here's the correct declaration:

Код:
new ColorName[][] = 
{
    {"COLOR_WHITE"},
    {"COLOR_FADE1"},
    {"COLOR_FADE2"},
    {"COLOR_FADE3"},
    {"COLOR_FADE4"},
    {"COLOR_FADE5"} // no comma
};
You error is from you using a string when its asking for an integer (aka you using a color NAME instead of color. To fix this simply ...use a real color).


EDIT:

I reread your code and saw what you are trying to do. If these are defines, simply remove the second dimension, and all the double quotes around your defines. If they're not define, replace them with hex color codes (or simply...define them :P).

Here's how it should look provided they are defined:

Код:
new ColorName[] = 
{
    COLOR_WHITE,
    COLOR_FADE1,
    COLOR_FADE2,
    COLOR_FADE3,
    COLOR_FADE4,
    COLOR_FADE5 // no comma
};
Reply
#6

Quote:
Originally Posted by RobokoP
Посмотреть сообщение
Thank you very much!
It had to be like that (without "):
Код:
new ColorName[6][0] = {
{COLOR_WHITE},
{COLOR_FADE1},
{COLOR_FADE2},
{COLOR_FADE3},
{COLOR_FADE4},
{COLOR_FADE5}
};
and then
Код:
SendClientMessageToAll(ColorName[kolor][0], string);
I edited right as you posted lol. Remove the second dimension, and make the first dimension dynamic (like my example).

Also there is no need for the brackets, as those are used to fill in ARRAYS, which doesnt apply here since there's only one dimension.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)