(78) : error 035: argument type mismatch (argument 2)
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;
}
|
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 languages and pawn seems pretty weird lol.
|
if(isPlayerIn(playerid, "main") == false)
.if(strcmp("main", menu, true))
forward isPlayerIn(playerid, menu[]);
public isPlayerIn(playerid, menu[])
if(!strcmp("main", menu, true,4))
if(strcmp("main", menu, true,4)==0)
|
In my eyes, I am sending the string "main" to the parameter 'menu', so I don't know why Im getting this
. |
|
pawn Код:
and this should be pawn Код:
it will return 0 if this is a match so thats why i added the ! you can also write it like pawn Код:
Also its not it is actually checking to see if "menu" contains the string "main" regards, |
if(isPlayerIn(playerid, "main") == false)
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;
}
}