(78) : error 035: argument type mismatch (argument 2)
#1

error:
pawn Код:
(78) : error 035: argument type mismatch (argument 2)
pawn Код:
forward isPlayerIn(playerid, menu);
public isPlayerIn(playerid, menu)
{
    if(strcmp("main", menu, true)) //if "main" == menu (menu being a string parameter with the name of a menu screen, ie. "main", "weapons", "cars" etc.....)
    {
        //opening users .txt file
        new readLine[64];
        new str[50], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(str,sizeof(str),"/Users/%s.txt",name);
        new File:example = fopen(str, io_read);
       
        while(fread(example, readLine)) //reads the file line-by-line
        {
            if(strcmp(readLine, "inMenu = true", true)) //if a line in the example file has "inMain = true"
            {
                fclose(example);
                return true;
            }
        }
        fclose(example);
    }
    return false;
}
Can someone help?
Reply
#2

You didn't define 'menu' as being string? Ahh ... Don't you have to set a string size to it so the compiler knows it's a string in your comparison ?
Reply
#3

Quote:
Originally Posted by antonio112
Посмотреть сообщение
You didn't define 'menu' as being string? Ahh ... Don't you have to set a string size to it so the compiler knows it's a string in your comparison ?
Thank you, sorry I come from other programming languages and pawn seems pretty weird lol.
Reply
#4

Quote:
Originally Posted by LeetModz
Посмотреть сообщение
Thank you, sorry I come from other languages and pawn seems pretty weird lol.
That's okay ... But does it work ?
Reply
#5

Quote:
Originally Posted by antonio112
Посмотреть сообщение
That's okay ... But does it work ?
Sure does, but I have a "tag mismatch" warning on my call to this function if you dont mind helping me to fix it :P

warning was for this:
pawn Код:
if(isPlayerIn(playerid, "main") == false)
In my eyes, I am sending the string "main" to the parameter 'menu', so I don't know why Im getting this .

Oh, and Im not sure what you meant about, having to set a string size in my comparison.

in this?:
pawn Код:
if(strcmp("main", menu, true))
Reply
#6

pawn Код:
forward isPlayerIn(playerid, menu[]);
public isPlayerIn(playerid, menu[])
if menu is a string you have to define it as such
and this should be

pawn Код:
if(!strcmp("main", menu, true,4))
its checking the var "menu" too see if the first 4 chars are "main"
it will return 0 if this is a match so thats why i added the !

you can also write it like
pawn Код:
if(strcmp("main", menu, true,4)==0)
this is the same thing.





Also
Quote:
Originally Posted by LeetModz
Посмотреть сообщение
In my eyes, I am sending the string "main" to the parameter 'menu', so I don't know why Im getting this .
its not it is actually checking to see if "menu" contains the string "main"






regards,
Reply
#7

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
pawn Код:
forward isPlayerIn(playerid, menu[]);
public isPlayerIn(playerid, menu[])
if menu is a string you have to define it as such
and this should be

pawn Код:
if(!strcmp("main", menu, true,4))
its checking the var "menu" too see if the first 4 chars are "main"
it will return 0 if this is a match so thats why i added the !

you can also write it like
pawn Код:
if(strcmp("main", menu, true,4)==0)
this is the same thing.





Also


its not it is actually checking to see if "menu" contains the string "main"






regards,
For some reason I still am getting the tag mismatch on this line:
pawn Код:
if(isPlayerIn(playerid, "main") == false)

Heres all of it:

pawn Код:
forward isPlayerIn(playerid, menu[]);
public isPlayerIn(playerid, menu[])
{
    if(!strcmp("main", menu, true, 4)) //if "main" == menu (menu being a string parameter with the name of a menu screen, ie. "main", "weapons", "cars" etc.....)
    {
        //opening users .txt file
        new readLine[64];
        new str[50], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(str,sizeof(str),"/Users/%s.txt",name);
        new File:example = fopen(str, io_read);

        while(fread(example, readLine)) //reads the file line-by-line
        {
            if(strcmp(readLine, "inMenu = true", true)) //if a line in the example file has "inMain == true"
            {
                fclose(example);
                return true;
            }
        }
        fclose(example);
    }
    return false;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
 if(strcmp(cmdtext, "/admin") == 0 && isPlayerIn(playerid, "main") == false)
    {
        return 1;
    }
       
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)