2 Errors
#1

This is command for show items.

/p [find/list]
Код:
error 047: array sizes do not match, or destination array is too small
warning 219: local variable "idx" shadows a variable at a preceding level
Код:
    if(!strcmp(cmdtext, "/p", true))
	{
	
			new idx,option[128];
			option = strtok(cmdtext, idx);
			if(!strlen(option))
			{
				SendClientMessage(playerid, -1, "Użyj: /p [szukaj/lista].");
			}
			else if(strcmp(option,"szukaj",true) == 0)
			{
			   
			}
			else if(strcmp(option,"lista",true) == 0)
			{
			    new dialog[512];

				new idx, item, amount;
				while(GetPlayerItems(playerid, idx, item, amount))
				{
				    format(dialog, 512, "%s%d x %s (ID:%d)\n", dialog, amount, GetItemName(item), item);
				}
				ShowPlayerDialog(playerid, DIALOG_ITEMSGUI, DIALOG_STYLE_LIST, "Przedmioty", dialog, "Wybierz", "Zamknij");
			}
	        else
			{
	            SendClientMessage(playerid, -1, "Niepoprawna opcja."); //bad option msg
			}
		return 1;
	}
What's wrong?
Reply
#2

variable idx is already defined on top of your script so remove it from your /p command so it looks like this:
(or remove it on top of your script)
pawn Код:
new option[128];
option = strtok(cmdtext, idx);
//rest of code...
//...
And about the other error im not sure, my guess is you have a enum somewhere which doesnt not have a big enough value like:
pawn Код:
enum example[5]//5 might be to small or to big depending on what you are using it for.
{
    blabla,
    blabla1
}
Well I hope I helped you and good luck man!
Reply
#3

so cool, but:
Код:
error 047: array sizes do not match, or destination array is too small
Код:
new idx,option[128];
when i change it to 256 its good, but isnt optimal. what can i do?
Reply
#4

Quote:
Originally Posted by cnoopers
Посмотреть сообщение
when i change it to 256 its good, but isnt optimal. what can i do?
Nothing. Although since you care (and good for you) about optimization, I'd recommend you NOT to use strcmp + strtok because they're too slow/outdated. Use ZCMD or y_commands + sscanf instead.
Reply
#5

Right, so can you remake this for sscanf2, but with strcmp?
Код:
    if(!strcmp(cmdtext, "/p", true))
	{
	
			new idx,option[256];
			option = strtok(cmdtext, idx);
			if(!strlen(option))
			{
				SendClientMessage(playerid, -1, "Użyj: /p [szukaj/lista].");
			}
			else if(strcmp(option,"szukaj",true) == 0)
			{
			   
			}
			else if(strcmp(option,"lista",true) == 0)
			{
			    new dialog[512];

				new item, amount;
				while(GetPlayerItems(playerid, idx, item, amount))
				{
				    format(dialog, 512, "%s%d x %s (ID:%d)\n", dialog, amount, GetItemName(item), item);
				}
				ShowPlayerDialog(playerid, DIALOG_ITEMSGUI, DIALOG_STYLE_LIST, "Przedmioty", dialog, "Wybierz", "Zamknij");
			}
	        else
			{
	            SendClientMessage(playerid, -1, "Niepoprawna opcja.");
			}
		return 1;
	}
its too not work.
Reply
#6

pawn Код:
if(!strcmp(cmdtext, "/p", true))
{
    new option[7];
    if(sscanf(cmdtext, "s[7]", option)) return SendClientMessage(playerid, -1, "Użyj: /p [szukaj/lista].");
    if(strcmp(option,"szukaj",true) == 0)
    {
        // code..
    }
    else if(strcmp(option,"lista",true) == 0)
    {
        new dialog[512], item, amount;
        while(GetPlayerItems(playerid, idx, item, amount))
        {
            format(dialog, 512, "%s%d x %s (ID:%d)\n", dialog, amount, GetItemName(item), item);
        }
        ShowPlayerDialog(playerid, DIALOG_ITEMSGUI, DIALOG_STYLE_LIST, "Przedmioty", dialog, "Wybierz", "Zamknij");
    }
    else SendClientMessage(playerid, -1, "Niepoprawna opcja.");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)